I want to add some view controller objects to a mutable array. Below is my code.
- (void) viewDidLoad
{
[super viewDidLoad];
[_vc addObject:[self viewControllerAtIndex:0]];
NSLog(@"VC Count is %lu",(unsigned long)[_vc count]));
}
- (UIViewController *)viewControllerAtIndex:(NSUInteger)index
{
if (index == 0){
QSG0Controller *QSG0Controller = [self.storyboard instantiateViewControllerWithIdentifier:@"QSG0Controller"];
return QSG0Controller;
}
else {
return nil
}
}
And in the output window, it shows that VC count is 0.
Can anyone tell me why??? Thanks a lot!!!
You need create _vc
first. Try _vc = [NSMutableArray new]
before [_vc addObject:[self viewControllerAtIndex:0]];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.