字符串查找指定字符,并插入换行符

将字符串转化为可变字符串,再根据指定字符查找该字符,再在该字符前面插入换行符

NSMutableString * name = [NSMutableString stringWithFormat:@"%@",model.name];
            NSRange range = [name rangeOfString:@"("];
            if (range.location != NSNotFound) {
                [name insertString:@"\n" atIndex:range.location];
            }

你可能感兴趣的:(字符串查找指定字符,并插入换行符)