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?
Asked
Active
Viewed 159 times
3
-
I don't know Objective-C or iPhone development, but viewDidUnload does not sound like a method that is used to release an object. – OregonGhost Feb 25 '10 at 14:34
3 Answers
7
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?"
0
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
- 51,577
- 12
- 107
- 152