str=[NSString stringWithFormat:
@"Person1:%7@,Person2:%7@,Person3:%7@",
@"Ann",@"Peter",@"jackson"];
我希望将它显示为:
Ann Peter jackson
而不是:
Ann,Peter,jackson
答案 0 :(得分:1)
NSString *original = @"Ann,Peter,Jackson";
NSArray *originalParts = [original componentsSeparatedByString:@","];
NSMutableString *newString = [NSMutableString new];
for (NSString *string in originalParts) {
[newString appendString:[string stringByPaddingToLength:string.length + 7 withString:@" " startingAtIndex:0]];
}
NSLog(@"Finished Product: %@", newString);
将输出:
Finished Product: Ann Peter Jackson