Cemre Mengü
Cemre Mengü

Reputation: 18754

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?

Upvotes: 5

Views: 2720

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726509

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

[myString replaceOccurrencesOfString:@":"
                          withString:@" "
                             options:NSLiteralSearch
                               range:NSMakeRange(0, myString.length)];

Upvotes: 11

Related Questions