#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSMutableString *str = [NSMutableString string];//空的字符串
//增
[str appendString:@"http://"];//拼接字符串
[str appendFormat:@"www.baidu.com/%d",100];//格式化拼接字符串
[str insertString:@"abcd" atIndex:3];
//删
[str deleteCharactersInRange:NSMakeRange(3, 4)];
//改
[str replaceCharactersInRange:NSMakeRange(1, 2) withString:@"ab"];
//查
unichar ch = [str characterAtIndex:3];//查某个位置上的元素
NSLog(@"%c",ch);
}
return 0;
}
|
|