[Study Notes] [OC language] NSString, ocnsstring
1. Fast creation of strings
NSStirng * str = @ "Hello ";
2. Create using static methods
3. Use % @ to output the string
NSString * name = @ "dssf ";
NSLog (@ "My name is % @", name );
4. Code
1 # import <Foundation/Foundation. h> 2 3 @ interface Person: NSObject 4 {5 // char * _ name; 6 NSString * _ name; 7} 8 @ end 9 10 int main () 11 {12/* 13 // The simplest way to create a string 14 NSString * str = @ "isdssf"; 15 16 char * name = "isdssf "; 17 18 19 NSLog (@ "my classes at % @", str); 20 // NSLog (@ "% s", name ); 21 */22 23 int age = 15; 24 int no = 5; 25 NSString * name = @ "Haha jan "; 26 // The length method calculates the number of characters 27 int size = [name length]; 28 29 NSLog (@ "% d", size ); 30 31 // create an OC string in another way 32 NSString * newStr = [NSString stringWithFormat: @ "My age is % d and no is % d and name is % @", age, no, name]; 33 34 35 NSLog (@ "---- % ld", [newStr length]); 36 37 return 0; 38}