#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSMutableString *new1 = [NSString stringWithFormat: @"12 , 34"]; // 这个最好前边的也是NSString
NSMutableString *new2 = [new1 copy]; // 这里不对,对不可变数组执行copy是浅复制,应该换成[new1 mutableCopy],然后你再试试
NSRange *rang = [new2 rangeOfString: @ "34"];
NSMutableString *new = [new2 deleteCharactersInRange:rang];
NSLog(@"%@",new);
return 0;
}
|