2015-09-29 43 views
1

我想在我的iOS 9应用中执行偷看和流行。有问题的观点有一个UITableView,所以我必须在我的代码:在iOS 9应用崩溃中偷看

- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location { 

    // check if we're not already displaying a preview controller 
    if ([self.presentedViewController isKindOfClass:[WebViewController class]]) { 
     return nil; 
    } 

    // shallow press: return the preview controller here (peek) 
     self.webViewController = [[[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]] autorelease]; 




    return self.webViewController; 
} 
- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit { 

    // deep press: bring up the commit view controller (pop) 
    self.webViewController = [[[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]] autorelease]; 


    [self showViewController:self.webViewController sender:self]; 
} 

WebViewController是我已经设置了选择的tableview的一行时,显示内容的ViewController。我得到的错误是:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument' 
*** First throw call stack: 
(0x182160f5c 0x19764bf80 0x182160ea4 0x182fb8868 0x1001307a4 0x1876cf9ac 0x1876cf720 0x187a025f8 0x187960844 0x18796cde4 0x1876a91e4 0x182117c30 0x1821159d4 0x182115e04 0x182044dc0 0x18d4e0088 0x18771ef60 0x10014ca68 0x197e6a8b8) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
+0

听起来像是一个很好的时间谷歌“Xcode异常断点” –

+0

@GradyPlayer随着这一点,应用程序崩溃之前,甚至发生任何事情。除了断点外,它运行良好,直到偷看。 – user717452

+1

听起来像你激活“所有异常断点”。例如,如果使用NSURLSession,则会立即抛出,因为它们使用控制流的异常。选择“仅使用Objc断点”。 – HAS

回答

2

你的日志它在说什么是你的代码错误:

- [__ NSCFConstantString stringByAppendingString:]:无参数”

您正在执行stringByAppendingString传递值为nil

此外,autorelease不再使用,如果你正在使用ARC(它现在是默认的)