Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to append String To Mutable string

Tags:

iphone

Hi i am new to iphone development,can any one help how to append string to mutable string. im trying to string By appending String Format .application Is crashes...

like image 582
Sumanth Avatar asked Sep 04 '11 04:09

Sumanth


2 Answers

Sample code NSMutableString:

NSMutableString* mutString = [[NSMutableString alloc] init];
    for(int index=0;index<10;index++)
    {
        [mutString appendString:[NSString stringWithFormat:@"%d",index]];
    }
    NSLog(@"Content in MutableString: %@",mutString);

Regarding crash: post your code that crashes. What does it say ?

like image 160
0x8badf00d Avatar answered Sep 29 '22 19:09

0x8badf00d


There is a crash when you try to append nil to a NSMutableString - check that. Also while it does not crash during append - if your NSMutablestring is not initialized - then nothing works and your app might crash later in the code because there is nothing in your string. Post the crash report, I am sure it will tell you what is going wrong.

like image 41
user387184 Avatar answered Sep 29 '22 17:09

user387184