Here is my code
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *str = [[NSString alloc]initWithString:@"This is string object"];
NSLog(@"%lu", [str retainCount]);
[pool drain];
return 0;
}
I expected the output to be 1 becase it is newly created object, but the result is 1152921504606846.
What is wrong here ?
Three important points:
allocd, so it not added to the poolretainCountfor debugging. See the answers to this question