标签:io os ar for sp on bs as res
1.NSString *str = [[NSString alloc]init]; //简单粗暴,基本用不到
2.NSString *str = [[NSString alloc]initWithFormat:@"xxx%@", str]; //最喜欢的常见方式了
3.NSString *str = [[NSString alloc]initWithString:str];
4.NSString *str = [[NSString alloc]initWithNSData:(NSData *) encoding:(NSStringEncoding)]; //转换编码格式
注:编码格式:NSUTF8StringEncoding等.
NSData* 转 NSString* :NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString * 转 NSData* :NSData* xmlData = [@"testdata" dataUsingEncoding:NSUTF8StringEncoding];
5.[str isEqualToString: nsstr]; //比较字符串
6.[str uppercaseString]; //大写
7.[str lowercaseString]; //小写
8.[str capitalizedString]; //首字母大写
9.[string1 rangeOfString:string2]; //字符穿搜索
10.[string1 substringToIndex:3]; //从字符串的开头一直截取到指定的位置,但不包括该位置的字符
11.[string1 substringFromIndex:3]; //以指定位置开始(包括指定位置的字符),并包括之后的全部字符
12.[string1 substringWithRange:NSMakeRange(0, 4)]; //按照所给出的位置,长度,任意地从字符串中截取子串
13.NSString *str = @"dd ss dd";
NSArray *array = [str componentsSeparatedByString:@" "]; //分割字符串
标签:io os ar for sp on bs as res
原文地址:http://www.cnblogs.com/Lxiaolong/p/4055349.html