NSMutableString to NSString

March 4, 2013 in iOS Snippets

Method 1, making a copy:


NSString* str = [mutableStr copy];

Method 2, also making a copy:


NSString* str = [NSString stringWithString:mutableStr];

Method 3, passing the original mutable string as an NSString by casting (almost never used):


NSString* immutableRefToMutableString = (NSString*)mutableStr;