Can anyone help, i have some code and i am checking the retainCount but its always -1, it should be 1 at least?
here is my code, what am i doing wrong?
NSNumber* n = [[NSNumber alloc] initWithInt:100];
NSLog(@"Count of n : %i",[n retainCount]);
NSNumber* n1 = n;
NSLog(@"Count of n : %i",[n retainCount]);
NSLog(@"Count of n1: %i",[n1 retainCount]);
NSLog(@"Address of n : %p", n);
NSLog(@"Address of n1: %p", n1);
The other strange thing i get is regarding the %i, saying that it actually returns a uint, so i replaced the %i to a %u and now i get a really long figure for the retainCount – 4294967295
A little confused, any ideas?
Thanks in advance
The result of
-retainCountis worthless at your abstraction level, and this is another reason why.…but to get on with your question:
NSUIntegerMaxindicates an immortal object.You can find references to this in some documentation: