Why keep the score negative?
Possible duplicate:
NSString save count
Is it possible that any object has to store count in a negative value?
I have this code
NSString *str = [[NSString alloc] initWithString:@"Hello World"];
NSLog(@"String Retain Count: %i", [str retainCount]);
this will return the value store -1.
Why did this happen?
I did it too
NSString *str = [[NSString alloc] init]
still its negative negative value in conserving quantity .
How does this happen?
Please help to understand this thing !!!!!
source to share
retainCount
does not return the reference count of the object. - it returns unrelated nonsense.
(For performance reasons, immutable constant strings return when copied self
. If you compare a pointer with @""
and [[NSString alloc] initWithString:@""]
, they are equal.)