标签:style blog io ar color sp for on div
NSString是不可变的
1 #pragma mark buffer string create 2 void stringCreate() 3 { 4 NSMutableString *mutStr = [[NSMutableString alloc] initWithCapacity:10]; 5 [mutStr setString:@"Go!"]; 6 NSLog(@"%@", mutStr); 7 [mutStr appendString:@"Hello"]; 8 [mutStr appendFormat:@",age is %i and height is %.2f", 12, 1.54]; 9 NSLog(@"%@", mutStr); 10 11 //Replace string 12 NSRange r = [mutStr rangeOfString:@"age"]; 13 [mutStr replaceCharactersInRange:r withString:@"number"]; 14 NSLog(@"%@", mutStr); 15 16 //Insert string 17 [mutStr insertString:@"insert" atIndex:2]; 18 NSLog(@"%@", mutStr); 19 20 //Delete string 21 NSRange r2 = [mutStr rangeOfString:@"height"]; 22 [mutStr deleteCharactersInRange: r2]; 23 NSLog(@"%@", mutStr); 24 }
[OC Foundation框架 - 6] NSMutableString
标签:style blog io ar color sp for on div
原文地址:http://www.cnblogs.com/hellovoidworld/p/4119400.html