2012-01-13 4 views
0

메인 스레드가 시작한 타이머가 있습니다. 타이머 처리기에서 알림을 보내고 있습니다 5 개 중 1 개에서 게시 알림 코드가 실행될 때 EXC_BAD_ACCESS가 표시됩니다.타이머 핸들러에서 알림 보내기

//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

답변

1

은 먼저 알림이 deallocated을 얻기 전에 unregister을하지 않았다받을 registered이 객체처럼 보인다.
알림 센터에서 결과적으로 할당 취소 된 개체로 메시지를 보냅니다.

그러나 더 많은 코드가 없으면 더 말할 수 없습니다.