Based on the following code, please advise
NSString *str= [[NSString alloc] initWithString:@"Hello world"];
NSLog(@"Length: %lu\n", [str length]); // 11
NSLog(@"Retain count is %lu\n", [str retainCount]); //1152921504606846975
[str release];
NSLog(@"%lu\n", [str length]); // 11
NSLog(@"Retain count is %lu\n", [str retainCount]); //1152921504606846975
Originally I was wondering why the number was so large but then saw a a post explaining it. Let me ask this instead ... Why does this number change greatly whether i use
%d
vs%lu
. Originally, i used%d
, but got a warning saying that "Conversion specified type int but the argument has the type NSUInteger (aka unsigned long). A fix was to change%d
to%lu
"Why doesn't the retain count decrement? Large number still shows up unchanged, after the
str
is sentrelease
Why am i still able to access the
str
, after it was sentrelease
?