1

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

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 对象有问题,但是什么......?:)

非常感谢任何建议!

4

2 回答 2

4

在您的 ViewController 中添加此代码

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

viewWillAppear并在方法中再次添加这个观察者。

于 2014-12-18T18:00:53.547 回答
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];

}
于 2015-07-18T00:42:38.000 回答