Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know where crash for postNotificationName:object:userInfo

Is there some method to know crash reason in Xcode 4.6?

The crash stack is :
Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0xd9f2c061
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                     0x3a74f5aa objc_msgSend + 10
1   Foundation                          0x33157599 -[NSNotificationCenter postNotificationName:object:userInfo:] + 73
2   UIKit                               0x347830cd -[UIApplication _handleApplicationSuspend:eventInfo:] + 733
3   UIKit                               0x346f91e7 -[UIApplication handleEvent:withNewEvent:] + 2459
4   UIKit                               0x346f86cd -[UIApplication sendEvent:] + 73
5   UIKit                               0x346f811b _UIApplicationHandleEvent + 6155
6   GraphicsServices                    0x363ee5a3 _PurpleEventCallback + 591
like image 934
Jason Wu Avatar asked Mar 22 '23 14:03

Jason Wu


1 Answers

When you add an observer to the notification centre you have to remove it when the object is being dealloced/destroyed. Otherwise Notification Centre would send the notification to the destroyed object resulting in crash.

1 - check if you properly handle the removing from notification centre. (typically you do this on dealloc method)

2 - If step 1 doesn't help, profile your application with instruments & zombies. it would point out which object is destroyed but still receiving messages.

like image 174
nsuinteger Avatar answered Apr 25 '23 01:04

nsuinteger