字符串查找指定字符,并插入换行符
2017-05-22 本文已影响28人
心底碎片
将字符串转化为可变字符串,再根据指定字符查找该字符,再在该字符前面插入换行符
NSMutableString * name = [NSMutableString stringWithFormat:@"%@",model.name];
NSRange range = [name rangeOfString:@"("];
if (range.location != NSNotFound) {
[name insertString:@"\n" atIndex:range.location];
}