what is convenience constructor.
if I use init method like this
NSNumber *zero = [[NSNumber alloc] initWithInteger:0];
[self setCount:zero];
[zero release];
it is me to retain or release zero object. but if I do like this
NSNumber *zero = [NSNumber numberWithInteger:0];
[self setCount:zero];
the apple documents says no need to retain or release zero.
what is the detail memory state of when using numberWithInteger:
? the object returned by Class method numberWithInteger:
doesn't have the retain count 1 or the zero object retain count 1? It seems the count of the object pointed by pointer zero is already 1 when returned by numberWithInteger:
. If I invoke setCount:
, the count plus 1 to 2. there seems a potential memory leak.