- #import <Foundation/Foundation.h>
- int main(int argc, const char * argv[])
- {
- //定义字符串
- NSString * str = @"iphoneAndroid";
- //将不可变字符串str的值赋值给可变字符串mstr
- NSMutableString * mstr = [NSMutableString stringWithFormat:@"%@", str];
- //截取Android
- NSRange r = { 6, 7 };
- //删除Android
- // mstr = [mstr deleteCharacterInRange: r]; // <--- 这里错了, 这个方法没有返回值...
- [mstr deleteCharactersInRange:r]; // <--- 改成这样
- NSLog(@"%@", mstr);
- return 0;
- }
复制代码 |