我正在研究UIPageViewController
,并且我在代码中的属性中为全局实例强大了:
UIViewController* aController = someviewController;//(I am getting the aController value)
NSArray* viewControllers = [[NSArray alloc] initWithObjects:aController, nil];
//(I am getting the viewControllers value as well).
[self.pageController setViewControllers:viewControllers
direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
//(I am getting crash here saying [__NSArrayM insertObject:atIndex:]: object cannot be nil').
所有实例都持有的值不知道viewControllers
在哪里变为零。
请让我知道
0 CoreFoundation 0x0000000105471e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010626ddeb objc_exception_throw + 48
2 CoreFoundation 0x00000001053388c5 -[__NSArrayM insertObject:atIndex:] + 901
3 0x0000000103df0b5e -[MZDashBoardViewController viewDidLoad] + 1470
4 UIKit 0x00000001071fbf98 -[UIViewController loadViewIfRequired] + 1198
5 UIKit 0x00000001071fc2e7 -[UIViewController view] + 27
6 UIKit 0x00000001077d57df -[UIPageViewController _setViewControllers:withScrollInDirection:animated:completion:] + 585
7 UIKit 0x00000001077d59fb -[UIPageViewController setViewControllers:direction:animated:completion:] + 166
8 0x0000000103decba5 -[MZMainDashViewController viewDidLoad] + 2997
9 UIKit 0x00000001071fbf98 -[UIViewController loadViewIfRequired] + 1198
10 UIKit 0x0000000107240651 -[UINavigationController _layoutViewController:] + 54
11 UIKit 0x0000000107240f26 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 462
12 UIKit 0x0000000107241098 -[UINavigationController _startTransition:fromViewController:toViewController:] + 126
13 UIKit 0x00000001072422f1 -[UINavigationController _startDeferredTransitionIfNeeded:] + 890
14 UIKit 0x00000001072433af -[UINavigationController __viewWillLayoutSubviews] + 57
15 UIKit 0x00000001073e9ff7 -[UILayoutContainerView layoutSubviews] + 248
16 UIKit 0x000000010711c4a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
17 QuartzCore 0x0000000106d8359a -[CALayer layoutSublayers] + 146
18 QuartzCore 0x0000000106d77e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
19 QuartzCore 0x0000000106d77cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
20 QuartzCore 0x0000000106d6c475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
21 QuartzCore 0x0000000106d99c0a _ZN2CA11Transaction6commitEv + 486
22 QuartzCore 0x0000000106d9a37c _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
23 CoreFoundation 0x000000010539d367 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
24 CoreFoundation 0x000000010539d2d7 __CFRunLoopDoObservers + 391
25 CoreFoundation 0x0000000105392f2b __CFRunLoopRun + 1147
26 CoreFoundation 0x0000000105392828 CFRunLoopRunSpecific + 488
27 GraphicsServices 0x000000010988fad2 GSEventRunModal + 161
28 UIKit 0x0000000107065610 UIApplicationMain + 171
29 0x0000000103dd2d3f main + 111
30 libdyld.dylib 0x00000001086e092d start + 1
31 ??? 0x0000000000000001 0x0 + 1
答案 0 :(得分:0)
显然,您正在尝试将对象插入不可变数组,而不是可变数组。在viewDidLoad里面的某个地方。请记住,因为变量的类型为NSMutableArray *并不意味着它。