Aug 28, 2008, 04:14 AM
| #2 |
|
Contributor
Join Date: Jun 2000
|
loadView is called because self.view doesn't exist. When you call self.view and the view doesn't exist yet, the view controller automatically calls loadView to set it up. But since you're calling self.view inside loadView, it keeps calling loadView recursively forever. So don't use self.view, use the view you're creating. If you're loading the view from a nib, don't override loadView and instead override viewDidLoad.
About your dealloc question, the OS won't always call dealloc if you're quitting the app because when you quit the OS frees up all the memory associated with your app automatically, so it's a waste of time to manually call dealloc. |
|
|
Aug 28, 2008, 05:11 AM
| #3 | |
|
Thread Starter
macrumors regular
|
Quote:
I am not talking about manually calling "dealloc"... As my app is having many levels of view controller ( say 6..7 levels).. I am trying to deallocate the present view controller, when i pop That view controller... All that stuffs are doing perfectly.... And moreover... how come OS will re-collect all the memory, as there no GC in iPhone.. (Not asking the OS functionality ...: ) what i thought was i want to deallocate each and every stuffs i used.. before quitting the app... OS will do it even in iPhone ,, right? Also i notyice that my loadView is not calling if i am attaching the ViewController to a NavigationController, then that navigationController to a TabbArController... Thanks...a lot for the self.view tip.... | |
|
|
Aug 28, 2008, 05:17 AM
| #4 |
|
macrumors Demi-God
Join Date: Jul 2002
Location: London
|
Garbage Collection and the OS recovering all memory from a process when it ends are totally and completely different. GC runs during the process and automatically frees objects not referenced. This is not available on the iPhone. The OS recovering all memory when a process ends is just that: when the process ends all of the resources it had are returned to the OS.
__________________
My App Store Apps: DLR Times |
|
|
Aug 28, 2008, 05:56 AM
| #5 |
|
macrumors regular
Join Date: Nov 2007
|
As somebody mentioned above, the job of loadView is to create the object you are trying to reference when you call self.view, but it doesn't exist when you call self.view hence the infinite loop.
I suspect you are probably missing a call to [super loadView] at the top of your overridden loadView method. |
|
|




1947

被折叠的 条评论
为什么被折叠?



