【问题标题】:iOS: App crash because of [OS_dispatch_data notifyDelegateOnWillFinish]?iOS:由于 [OS_dispatch_data notifyDelegateOnWillFinish] 导致应用程序崩溃?
【发布时间】:2012-11-04 09:26:04
【问题描述】:

在某些设备上,由于以下错误,我的应用程序崩溃了: NSInvalidArgumentException:-[OS_dispatch_data notifyDelegateOnWillFinish]:无法识别的选择器发送到实例 0x2082d7a0

我无法重现此行为。我使用 Flurry 分析跟踪崩溃,一些用户似乎遇到了这个问题。

我试图用谷歌搜索这个错误,但没有成功。所以希望这里有人知道这意味着什么。

非常感谢!!

编辑: 我的代码中唯一使用 dispatch 的部分是这个

- (void) callDelegateOnMainThread: (SEL) selector withArg: (id) arg error: (NSError*) err
{
    dispatch_async(dispatch_get_main_queue(), ^(void)
               {
                   [self callDelegate: selector withArg: arg error: err];
               });
}

编辑2: 这里是 callDelegate 方法:

- (void) callDelegate: (SEL) selector withArg: (id) arg error: (NSError*) err
{
    assert([NSThread isMainThread]);
    if([delegate respondsToSelector: selector])
    {
        if(arg != NULL)
        {
            [delegate performSelector: selector withObject: arg withObject: err];
        }
        else
        {
            [delegate performSelector: selector withObject: err];
        } 
    }
    else
    {
        DebugLog(@"Missed Method");
    }
}

这段代码有问题吗?请指教!非常感谢!

【问题讨论】:

  • 听起来有些东西被提前释放了。

标签: iphone ios ipad crash


【解决方案1】:

我认为你还没有在你的类中实现 notifyDelegateOnWillFinish 方法。

您应该在调用委托方法之前添加检查。

if([delegate respondsToSelector:selector])
    [self callDelegate: selector withArg: arg error: err];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-17
    • 2016-08-05
    相关资源
    最近更新 更多