I found that the iphone have viewDidUnload, and dealloc. I want to release the object. Which method should I use to release the object? What's the different between them?
+7
A:
Send release
or autorelease
to release an object. You shouldn't send dealloc
; the Obj-C runtime will do that.
If you're asking where you should release an owned object, read: "When should I release objects in -(void)viewDidUnload rather than in -dealloc?"
outis
2010-02-25 14:37:06
A:
The difference is that viewDidUnload
is used to release "spare" objects in low memory situations while dealloc
is used to release all objects when the view is no longer needed.
This means that you will almost always have a dealloc
method but have a viewDidUnload
method only where it makes sense.
Stephen Darlington
2010-02-25 14:43:42