如果我有一個UIViewControllers的NSArray並將發佈發送到數組,那麼是否會爲每個UIViewControllers調用viewDidUnload或dealloc?或兩者都不?將發佈發送到UIViewControllers的NSArray?
下面是我在做什麼:
- (void) viewDidLoad {
UIViewController* profileController = [[ProfileController alloc] init];
..........
//all the other controllers get allocated same way
self.viewControllers = [[NSMutableArray alloc] initWithObjects: profileController, dietController, exerciseController, progressController, friendsController, nil];
[profileController release];
//other controllers get released same way ....
}
- (void) dealloc {
[viewControllers release];
NSLog("DEALLOC!");
//I know dealloc is being called
//what happens to the view controllers?
}
我把一個斷點在viewDidUnload和dealloc的方法每個視圖控制器,他們不會被調用。
哇。我完全錯過了......你是完全正確的。我通常使用一個臨時變量,如NSMutableArray a = [[NSMutableArray alloc] init ...],然後[釋放],但是這次我保持簡潔並且錯過了它。謝謝 –