How to determine CoreFoundation _CFXNotificationPost crash

2.9k Views Asked by At

I'm facing several crashes when developing a game, probably due to some sort of sound management bugs. This is what my trace says about them:

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x000000019599bbd0 objc_msgSend + 16
1  CoreFoundation                 0x00000001851d4ae4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
2  CoreFoundation                 0x0000000185113220 _CFXNotificationPost + 2060
3  AVFoundation                   0x0000000183a4af8c __avplayeritem_fpItemNotificationCallback_block_invoke + 5336
4  libdispatch.dylib              0x0000000195fcd3ac _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x0000000195fcd36c _dispatch_client_callout + 16
...

The line #3 is about AVFoundation and a AVPlayerItem so I guess I have something wrong with my music AVPlayerItems objects, but what... ? :)

Any advice is much appreciated!

2

There are 2 best solutions below

0
On BEST ANSWER

Add this code in your ViewController

-(void) viewWillDisappear:(BOOL)animated
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super viewWillDisappear:animated];
}

And add this observer again in viewWillAppear method.

0
On
-(void)dealloc{

    // remove all observer of this "CURRENT" screen
    [[NSNotificationCenter defaultCenter] removeObserver:self name: @"NAME_OF_UR_OBSERVER" object:nil];

    // "OR" all observer from NSNotificationCenter
    [[NSNotificationCenter defaultCenter] removeObserver:self];

}