Crashing app when i want to go rootview from other view controller
I want to go Root view Controller from another view controller but i got the terminating error. following is the error message in console,
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray removeObjectsInRange:]: index (4) beyond bounds (1)'
开发者_运维百科
This is my code for that
NSArray *arr=self.navigationController.viewControllers;
[self.navigationController popToViewController:[arr objectAtIndex:2] animated:YES];
So any one can give me the suggestion on it so can remove the crash
The NavigationController has a method called to pop to its root view controller. Maybe you should use this one instead.
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated
精彩评论