自动填充NSString中的空白

时间:2012-03-20 19:46:35

标签: objective-c nsstring

如何以编程方式转换:

@"This is any NSString with some blanks"

到此?

@"This+is+any+NSString+with+some+blanks"`

1 个答案:

答案 0 :(得分:8)

NSString *firstString = @"This is any NSString with some blanks";
NSString *secondString = [firstString stringByReplacingOccurrencesOfString:@" " withString:@"+"];