NSString *string1;
string1=@"aa bb cc dd";
[string1 stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSLog(@"------string1 is %@--------", string1);
I expect aabbccdd but its still aa bb cc dd. the space didn’t got taken out.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
NSString is not mutable, so
stringByReplacingOccurrencesOfString:withString:is returning a new NSString, that you’ll have to assign to a variable.