------------NSString----------------------
NSString *str = @"hello";
NSString *str1 = [[NSString alloc] initWithString : str];
NSString *str = [[NSString alloc] initWithString :@"hello"];
NSString *str = [[NSString alloc] initWithUTF8String:"hello"];//C string
NSString *str = [[NSString alloc] initWithFormat: @"hello %d %c",5,'A'];
//临时字符串
NSString *str = [NSString stringWithUTF8String:"hello"];
NSString *str = [NSString stringWithFormat:@"%d %@",1,@"hello"]
NSString *str = [NSString stringWithString:str];
BOOL ret = [str isEqualToString:str1];
NSLog(@"%d",ret);
NSComparisonResult ret = [str compare:str1];//-1,0,1
NSString *subString = @"a";
NSSRange range = [str rangeOfString:subString];
NSLog(@"%lu,%lu",range.location, range.length);//start with zero
NSString *str1 = [str substringToIndex:6];//从0提取到第5个,生成新的字符串,返回地址
NSString *str2 = [str substringFromIndex:6 ];//闭区间,包括第6个
NSRange range = {3,4};
NSString *str1 = [str substirngWithRange: range];
NSString *str1 = [str substringWithRagnge:NSMakeRange(3,4)];
---------NSMutableString----------------------
NSMutableString 继承自NSString
add delete change search
append delete replace
NSMutableString * str = @"hellp"; // X wrong!
NSMutableString *str =[[NSMutableString alloc ] init];
[str setString:@"hello"];
[str appendString:@"world"];
[str appendFormat:@"%c",'D'];
[str insertString:@"XXX" atIndex:4];//start with zero
[str insertString:[NSString stringWithFormat:@"%d",5] atIndex:4]
[str deleteCharactersInRange:NSMakeRange:(3,5)];
[str replaceCharactersInRange:NSMakeRange:(1,2) withString:@"RR"];