NSString *str = @"abcd abcd Abcd";
str = [str stringByReplacingOccurrencesOfString:@"a" withString:@"-"];
str = [str stringByReplacingOccurrencesOfString:@"a" withString:@"-" options:NSBackwardsSearch range:NSMakeRange(0, str.length) ];
NSString *string = @" shui shi yingxun ";
//取掉字符串两端的空格
string =[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
//用空格分割字符串
NSArray *array = [string componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
//用谓词处理数组
array = [array filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self <> ''"]];//谓词筛选出非空数组
//拼接数组
NSString *resultStr = [array componentsJoinedByString:@" "];
NSString *str = [NSString stringWithFormat:@"%.02f",M_PI];//保留两位小数
NSInteger count = 15;
NSString *str1 = [NSString stringWithFormat:@"%03ld",count];//不足位用0补
//带特殊符号
NSString *str2 = [NSString stringWithFormat:@"%ld%%",count];
NSString *str3 = [NSString stringWithFormat:@"%ld\"",count];