Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple way of replacing a parts of NSMutableString/NSString

I am new to iPhone development (using iOS 5) and I am trying to replace : with spaces in an NSMutableString. I have been struggling with this since an hour and it forces me to use replaceOccurrencesOfString:@":" withString:@" " options:nil range:; (I thought I could use it without options and range). I have tried almost everything (especially for the range parameter) but it keeps complaining about various stuff such as bad receiver type.

Any suggestions about how to achieve this?

like image 630
Cemre Mengü Avatar asked Sep 17 '12 21:09

Cemre Mengü


1 Answers

This is how you invoke replaceOccurrencesOfString: to produce the desired effect:

[myString replaceOccurrencesOfString:@":"
                          withString:@" "
                             options:NSLiteralSearch
                               range:NSMakeRange(0, myString.length)];
like image 99
Sergey Kalinichenko Avatar answered Nov 13 '22 11:11

Sergey Kalinichenko