Reputation: 38920
I have an NSString that is like @"nice car" and would like to create an NSString that is @"nice,car". Is there a way to do this?
Upvotes: 1
Views: 152
Reputation: 54435
You could use the NSString stringByReplacingOccurrencesOfString:withString:
method to achieve this as follows:
NSString *stringWithSpaces = @"nice car";
NSString *stringWithCommas = [stringWithSpaces stringByReplacingOccurrencesOfString:@" " withString:@","];
Upvotes: 3