Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append a string to NSMutableString

Tags:

i'm an absolute newbie with objective-c

with this code

NSMutableString *teststring; [teststring appendString:@"hey"]; NSLog(teststring); 

nothing gets displayed in the console.

Surely i'm doing something wrong here... :-)

like image 568
murze Avatar asked Feb 07 '12 17:02

murze


1 Answers

You need to create the string first.

NSMutableString *teststring = [[NSMutableString alloc]init];  [teststring appendString:@"hey"];  NSLog(teststring); 

Now, it will print.

like image 198
Apurv Avatar answered Sep 19 '22 02:09

Apurv