char bytes[] = { 1, 2, 3, 4};
NSString * f = [[NSString alloc] initWithBytes:bytes length:4 encoding:NSASCIIStringEncoding];
[f release];
NSLog(@"%@", [f description]); // Why no 'message sent to deallocated instance "?
[f release];
It only give me warning only, no crash..
Test1(26194,0xacf302c0) malloc: *** error for object 0x757c2f0: double free
Because
NSStringis weird. (It’s a class cluster, and it’s toll-free-bridged toCFString.)Try the same thing with a more ordinary object (like
NSObject, for the simplest possible case) and you’ll see things behaving more as expected. (But note that you will probably not get a “message sent to deallocated instance” error at all unless you enable guard malloc or a similar debug option.)