nsmutablestring

Generating a list of Strings in Obj C

Hi It seems that Objective C jumps thru hoops to make seemingly simple tasks extremely difficult. I simply need to create a sequence of strings, image1.jpg, image2.jpg, etc etc ie in a loop var imgString:String='image'+i+'.jpg; I assume a best practice is to use a NSMutableString with appendString method? What am I doing wrong?? NSM...

removing the rtf format and tags from nsMutableString

hello everyone. I am trying to display the contents of a rtf file in uiwebview. I do this by taking the contents of rtf into nsmutablestring and loading it into uiwebview. The problem is along with the content of rtf, the rtf tags and format is also passed in the nsmutablestring. so i the entire content is displayed along with the rtf ...

Reusing NSMutableString correctly on the iPhone

Using objective-c on the iPhone, what is wrong with this code? Is it leaking memory? Why? How would I do this correctly? NSMutableString *result = [NSMutableString stringWithFormat:@"the value is %d", i]; ... then later in my code... I might need to change this to: result = [NSMutableString stringWithFormat:@"the value is now %d", i...

An Important Question About NSDictionaries

I have an NSDictionary with NSStrings Some of the valueForKey:@"Key" have no entry so it's (null) NSMutableString* addressDictionaryToString = [NSMutableString string]; // use mutable string! for (NSDictionary* item in address) { // use fast enumeration! [addressDictionaryToString appendFormat:@"%@, %@, %@, %@", [...

NSMutableString defining and redefining

I am at a loss as hot to properly initiate a NSMutableString, I have tried: NSMutableString *string = @"some text"; which is the same method one assigns a string to an NSString but have hade no luck. Additionally I have not been able to figure out how to redefine the string contained with the NSMutableString. I would imagine it would ...

Replace a char into NSString

Hi all! I want simply replace all occourrencies of "+" with a blank " " char... I tried some sample listed here, also used NSSMutableString, but the program crash... what's the best way to replace a char from another?? thanks ...

Objective C NSMutableString* property retain count oddity

Hi everyone, if I create an nsmutablestring and then release it , shouldn't the retain count be 0? my retain count stays 1. NSMutableString *text = [[NSMutableString alloc]init]; [text release]; NSLog(@"retain count %d ", [text retainCount]); Am I missing something ? thanks. ...

NSMutableArray of NSStrings contains actual data or just pointers to the data

I'm relatively new to Objective C and while I've been trucking right along writing iPhone apps, I think I need some help understanding something. I'm storing a dynamic list of strings in an NSMutableArray, which is a property of my main class. In my initialization I alloc and init to store 100 items: stringList = [[NSMutableArray alloc...

Clearing rather than releasing a NSMutableString

I've got a rather large loop that gets a string, does something to it, than goes onto the next one. I was originally releasing it then reallocating it but thought that is a bit of waste of resources but can't figure out how to just clear it out to reuse it. ...

NSMutableString appendString generates a SIGABRT

This makes no sense to me. Maybe someone here can explain why this happens. I've got an NSMutableString that I alloc at the top of my iPhone app, then append to later in the process. It results in a SIGABRT, which doesn't add up to me. Here's the code: Header File (simplified): @interface MyAppDelegate : NSObject <UIApplicationDele...

How to make an NSMutableString blank

If I have an NSMutableString containing a random string, then how do I remove all characters from it so that it becomes an empty string? ...

deleteCharactersInRange work something wrong

HI all! I am using message deleteCharactersInRange from NSMutableString. And there is a problem that this finction deletes range in a wrong way. Here is a sample of code that works wrong: -(void) btnClick { NSRange deleteRange = NSMakeRange(0, 1); [valueStr deleteCharactersInRange:deleteRange]; [self ShowNumber]; } I have a mutable str...