【问题标题】:How to find where NSInvalidArgumentException ("data parameter is nil") get's thrown?如何找到抛出 NSInvalidArgumentException ("data parameter is nil") 的位置?
【发布时间】:2014-10-08 11:09:35
【问题描述】:

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

我收到这个信息量很大的错误:

*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“数据参数为零”

我想,我把它限制在这个 sn-p:

@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 得到打印并且两个变量都存在。但是第二个和第三个(应该在第一个之后立即调用)都不会被打印出来。

有什么想法,怎么继续?

【问题讨论】:

    标签: ios objective-c cocoa cocoa-touch


    【解决方案1】:

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

    How to add the exception-breakpoint

    【讨论】:

      【解决方案2】:

      使用 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>
      

      【讨论】:

      • 那是 Java,不是吗?
      • 这个答案与这个问题完全没有关系,应该删除。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-22
      • 1970-01-01
      • 1970-01-01
      • 2020-01-06
      • 1970-01-01
      • 2020-06-05
      相关资源
      最近更新 更多