I have an NSMutableString, how can I convert it to an NSString?
NSMutableString
is a subclass of NSString
, so you could just typecast it:
NSString *string = (NSString *)mutableString;
In this case, string
would be an alias of mutalbeString
, but the compiler would complain if you tried to call any mutable methods on it.
Also, you could create a new NSString with the class method:
NSString *string = [NSString stringWithString:mutableString];