Cocoa: Testing to find if an NSString is immutable or mutable?
This produces an immutable string object: NSString* myStringA = @"A"; //CORRECTED FROM: NSMutableString* myStringA = @"A"; This produces a mutable string object: NSMutableString* myStringB = [NSMutableString stringWithString:@"B"]; But both objects are reported as the same kind of object, "NSCFString": NSLog(@"myStringA is type: %@, myStringB is type: %@", [myStringA class], [myStringB class]); So what is distinguishing these objects internally, and how do I test for that, so that I can easily determine if a mystery string variable is immutable or mutable before doing something evil to it? The