OC-Q&A

How to declare a string in Objective-C ?

A C string is just like in C.

char myCString[] = "test";
An NSString uses the @ character: NSString *myNSString = @"test";//////////////////////////////////
If you need to manage the NSString's memory: NSString *myNSString = [NSString stringWithFormat:@"test"];
NSString *myRetainedNSString = [[NSString alloc] initWithFormat:@"test"];
Or if you need an editable string: NSMutableString *myMutableString = [NSMutableString stringWithFormat:@"test"];
You can read more from the Apple NSString documentation.
上一篇:详解CSS position属性


下一篇:3D游戏图形引擎