2012-11-04 41 views
0

在某些設備上我的應用程序,是因爲以下錯誤的崩潰: NSInvalidArgumentException: - [OS_dispatch_data notifyDelegateOnWillFinish]:無法識別的選擇發送到實例0x2082d7a0iOS:應用程序崩潰,因爲[OS_dispatch_data notifyDelegateOnWillFinish]?

我無法重現此問題。我使用亂七八糟的分析跟蹤崩潰,並且一些用戶似乎遇到了這個問題。

我試圖谷歌這個錯誤沒有成功。所以希望這裏有人知道這意味着什麼。

非常感謝!

編輯: 在我的代碼的唯一部分,我使用的調度是這個

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

EDIT2: 這裏是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"); 
    } 
} 

是否有與此代碼的問題?請指教!非常感謝!

+0

聽起來象是得到了過早釋放。 – CodaFi

回答

0

我覺得你還沒有在你的課上實現notifyDelegateOnWillFinish方法。

您應該在調用委託方法之前添加檢查。

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