如何找到NSInvalidArgumentException("数据参数为nil")被抛出的位置?

时间:2014-10-08 11:09:35

标签: ios objective-c cocoa cocoa-touch

我正在写一个iPad应用程序,今天我意识到,没有互联网连接时出现了问题。

我得到了这个非常有用的错误:

  

***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'data parameter is nil'

我想,我将其限制在这个片段中:

@implementation WebviewPanelFactory

- (WebviewPanelViewController *)webviewPanelForSection:(NSDictionary *)section {
    WebviewPanelViewController *webviewPanel = [[WebviewPanelViewController new] initWithNibName:@"WebviewPanel" bundle:nil];
    webviewPanel.sectionTitle = section[@"Title"];

    NSLog(@"HERE I AM. %@ %@", webviewPanel, section);

    [self setupURLsForWebview:webviewPanel withSection:section];

    NSLog(@"HERE I STILL AM");

    [webviewPanel initWebviewPanel];
    return webviewPanel;
}

- (void)setupURLsForWebview:(WebviewPanelViewController *)webviewPanel withSection:(NSDictionary *)section {

    NSLog(@"HERE I AM. %@", section);

    ...
}

@end

第一个NSLog get打印,两个变量都存在。但是第二个和第三个(应该在第一个之后立即调用)都不会被打印出来。

任何想法,如何继续?

2 个答案:

答案 0 :(得分:2)

在XCode中,您可以添加Exception-Breakpoint,它将在崩溃之前暂停应用程序。你应该试试这个,如果它能正常工作,它会暂停在代码行上,这会使你的应用崩溃。

How to add the exception-breakpoint

答案 1 :(得分:0)

使用spring 3版本

弹簧配置: springService.xml

<context:component-scan base-package=" com.service.impl" />

<!-- Scheduler : Initial delay =5 minutes (5*60000 seconds) and repeat interval= 5 minutes-->
    <task:annotation-driven executor="myExecutor"
        scheduler="myScheduler" />
    <task:executor id="myExecutor" pool-size="1" />
    <task:scheduler id="myScheduler" pool-size="1" />

    <task:scheduled-tasks scheduler="myScheduler">
        <task:scheduled ref="batchUpdateServiceImpl"
            method="updateMe" fixed-delay="300000" initial-delay="300000"/>
        <task:scheduled ref="batchUpdateServiceImpl"
            method="updateYou"
            fixed-delay="300000"  initial-delay="300000"/>
    </task:scheduled-tasks>



Package Code :
com.service.impl

Class Name:
@Service
public class BatchUpdateServiceImpl {
    public void updateMe(){
    System.out.println(“update me”);
    }
    public void updateYou(){
    System.out.println(“update You”);
    }

}

Web.xml :
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
            /WEB-INF/springService.xml
        </param-value>
  </context-param>