2012-01-13 66 views
0

我有一個由主線程啓動的計時器。來自定時器處理程序我正在發送通知 在5個案例中的1箇中,當執行發佈通知代碼時,我得到EXC_BAD_ACCESS。發送來自定時器處理程序的通知cocoa

//Registering Notification 
    [[NSNotificationCenter defaultCenter] addObserver:self 
     selector:@selector(TestNotification:) 
        name:@"TestNotification" object:nil]; 

//Starting timer 
     timer = [NSTimer scheduledTimerWithTimeInterval:2 
               target:self 
               selector:@selector(timerhandler:) 
               userInfo:nil 
               repeats:YES];  


    //Posting notification from timer handler  
     [[NSNotificationCenter defaultCenter] 
      postNotificationName:@"TestNotification" object:nil]; 

有人可以幫忙。

感謝

+1

請發佈'TestNotification:'方法。問題很可能在那裏。 – spudwaffle 2012-01-13 16:57:52

回答

1

起初,這看起來有registered收到通知讓deallocated之前沒有unregister的對象。
導致通知中心將消息發送到釋放對象。

但沒有更多的代碼很難說更多。

相關問題