我一直在关注一个教程,似乎无法让它超越某一点,我已经完成了原来的项目,感觉就像是ttothcomb,但却找不到错误。< / p>
异常没有多大帮助,调试不允许我进一步深入代码。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Post *post1 = [[Post alloc] initPost:@"Heading 1" content:@"Some content" location:@"Landaaan" rating:3 thumbImage:[UIImage imageNamed:@"potatoBugThumb.jpg"] fullImage:[UIImage imageNamed:@"potatoBug.jpg"]];
Post *post2 = [[Post alloc] initPost:@"Heading 2" content:@"Some more content" location:@"Narwich" rating:5 thumbImage:[UIImage imageNamed:@"centipedeThumb.jpg"] fullImage:[UIImage imageNamed:@"centipede.jpg"]];
Post *post3 = [[Post alloc] initPost:@"Heading 3" content:@"Some sdfsdfdf" location:@"Landaaan" rating:2 thumbImage:[UIImage imageNamed:@"wolfSpider.jpgThumb.jpg"] fullImage:[UIImage imageNamed:@"wolfSpider.jpg"]];
Post *post4 = [[Post alloc] initPost:@"Heading 4" content:@"Some content" location:@"Landaaan" rating:4 thumbImage:[UIImage imageNamed:@"ladybugThumb.jpg"] fullImage:[UIImage imageNamed:@"ladybug.jpg"]];
NSMutableArray *posts = [NSMutableArray arrayWithObjects:post1, post2, post3, post4, nil];
UINavigationController *navController = (UINavigationController *) self.window.rootViewController;
MasterViewController *masterController = [navController.viewControllers objectAtIndex:0];
masterController.posts = posts;
// Override point for customization after application launch.
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
splitViewController.delegate = self;
return YES;
}
错误发生在masterController.posts = posts;
堆栈跟踪为:
2015-11-21 01:08:18.323 unfoldIos[17542:359798] -[MasterViewController topViewController]: unrecognized selector sent to instance 0x7aeebab0
2015-11-21 01:08:18.325 unfoldIos[17542:359798] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MasterViewController topViewController]: unrecognized selector sent to instance 0x7aeebab0'
*** First throw call stack:
(
0 CoreFoundation 0x00a4da84 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0050ee02 objc_exception_throw + 50
2 CoreFoundation 0x00a56dd3 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x00994cdd ___forwarding___ + 1037
4 CoreFoundation 0x009948ae _CF_forwarding_prep_0 + 14
5 unfoldIos 0x00037562 -[AppDelegate application:didFinishLaunchingWithOptions:] + 1506
6 UIKit 0x00fd97d4 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 337
7 UIKit 0x00fdac02 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3863
8 UIKit 0x00fe22c7 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1971
9 UIKit 0x01006e4d __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3208 + 68
10 UIKit 0x00fdefb4 -[UIApplication workspaceDidEndTransaction:] + 163
11 FrontBoardServices 0x045f3ca4 __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71
12 FrontBoardServices 0x045f377b __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54
13 FrontBoardServices 0x046111a3 -[FBSSerialQueue _performNext] + 184
14 FrontBoardServices 0x046115da -[FBSSerialQueue _performNextFromRunLoopSource] + 52
15 FrontBoardServices 0x046108d6 FBSSerialQueueRunLoopSourceHandler + 33
16 CoreFoundation 0x00967d1f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
17 CoreFoundation 0x0095d9ab __CFRunLoopDoSources0 + 523
18 CoreFoundation 0x0095cdc8 __CFRunLoopRun + 1032
19 CoreFoundation 0x0095c706 CFRunLoopRunSpecific + 470
20 CoreFoundation 0x0095c51b CFRunLoopRunInMode + 123
21 UIKit 0x00fde854 -[UIApplication _run] + 540
22 UIKit 0x00fe41eb UIApplicationMain + 160
23 unfoldIos 0x00038a6a main + 138
24 libdyld.dylib 0x032b0a21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
非常感谢任何帮助。
编辑:我已从控制器中删除了所有黄色三角形,仍然存在相同的错误。
答案 0 :(得分:0)
[splitViewController.viewControllers lastObject]
这不会回归你的想法。 NSLog(@"%@",[[splitViewController.viewControllers lastObject] class])
。我的猜测是记录MasterViewController。