我在看這段代碼:Objective-C的保留澄清
NSMutableArray *controllers = [[NSMutableArray alloc] init];
for (unsigned i = 0; i < kNumberOfPages; i++) {
[controllers addObject:[NSNull null]];
}
self.viewControllers = controllers;
[controllers release];
後來......
- (void)dealloc {
[viewControllers release];
...
}
我看到self.viewControllers和控制器現在指向同一個分配的內存(類型NSMutableArray *),但是當我調用[控制器發佈]不是self.viewControllers以及設置self.viewControllers =控制器會自動保留該內存?