如何确定CoreFoundation _CFXNotificationPost崩溃

时间:2014-12-18 17:52:48

标签: ios sprite-kit avfoundation avplayeritem

我在开发游戏时遇到了几次崩溃,可能是由于某种声音管理错误。这就是我对他们的描述:

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

第3行是关于AVFoundation和AVPlayerItem所以我想我的音乐AVPlayerItems对象有问题,但是......? :)

非常感谢任何建议!

2 个答案:

答案 0 :(得分:4)

在ViewController中添加此代码

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

再次在viewWillAppear方法中添加此观察者。

答案 1 :(得分:1)

-(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];

}