Reputation: 1423
HI i have questions on Memory Management If I alloc object 1 time then i retain 2 time And then release 4 time & then retain 1 time for same object. what will be my final ans?
Upvotes: 0
Views: 80
Reputation: 16296
The object will be dealloced after the third release (when the retainCount
hits zero) and the fourth release
will be sent to a non-valid object, resulting in a crash.
If you want an object to exist for a little while after you've released it, you should look into the autorelease
method.
Upvotes: 1