Muju Muju - 4 months ago 15
Objective-C Question

how to replace the content of NSMutablestring in objective c

I am new in objective c. I want to replace the content of mutable string I am using code as

NSMutableString *myMutableStringObj = [myMutableStringObj stringByReplacingOccurrencesOfString:@" & " withString:@"And"];


But It Shows me warning
Incomparable pointer types assigning to
NSMutableString *
from
NSString *


Any Suggestion about this. I am using
MutableString
.

Answer

It tells you this function returns NSString *. If you want to clean that warning. Just do like this:

NSMutableString *myMutableStringObj = [[myMutableStringObj stringByReplacingOccurrencesOfString:@" & " withString:@"And"] mutableCopy];