objective c - release problem
Posted
by amir
on Stack Overflow
See other posts from Stack Overflow
or by amir
Published on 2010-06-06T20:29:29Z
Indexed on
2010/06/06
20:32 UTC
Read the original article
Hit count: 227
objective-c
Hello, I have the following code:
NSNumber *number = [NSNumber numberWithInt:5];
int i = [number retainCount];
[number release];
i = [number retainCount];
[number release];
i = [number retainCount];
the problem is that in line 2 , the value of parameter i is 2 and in line 4 the value is 1. then in line 6 the value is still 1.????????
first i dont understand why after init *number the retaincount is 2 and not 1?? second i dont understand why after release it 2 times retaincount is not 0? it doesnt matter how many times i release the object the retaincount stay 1.
© Stack Overflow or respective owner