GameCenter功能崩溃应用程序 - 任何人都可以帮忙解决?

时间:2012-09-09 15:56:53

标签: iphone objective-c delegates crash game-center

我的当前iPhone应用程序的崩溃日志是象征性的,但我无法破译问题仍然存在。

基本问题是在某些设备(特别是旧设备)上我的应用程序崩溃回主屏幕。似乎是用户在一段时间后回到我的游戏 - 这会启动到游戏中心的登录过程。我已粘贴以下崩溃日志的相关部分:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x2e000000
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x37c11f7e objc_msgSend + 22
1   Transfer Quiz                   0x000023c4 -[GameCenterManager callDelegate:withArg:error:] (GameCenterManager.m:113)
2   Transfer Quiz                   0x0000230c __60-[GameCenterManager callDelegateOnMainThread:withArg:error:]_block_invoke_0 (GameCenterManager.m:103)
3   libdispatch.dylib               0x346fdc52 _dispatch_call_block_and_release + 6
4   libdispatch.dylib               0x346ffee0 _dispatch_main_queue_callback_4CF$VARIANT$mp + 188
5   CoreFoundation                  0x358432a6 __CFRunLoopRun + 1262
6   CoreFoundation                  0x357c649e CFRunLoopRunSpecific + 294
7   CoreFoundation                  0x357c6366 CFRunLoopRunInMode + 98
8   GraphicsServices                0x37462432 GSEventRunModal + 130
9   UIKit                           0x332d2cce UIApplicationMain + 1074
10  Transfer Quiz                   0x000030d4 main (main.m:16)
11  Transfer Quiz                   0x000021a8 start + 32

以下是GameCenterManager callDelegate的以下代码:

- (void) callDelegate: (SEL) selector withArg: (id) arg error: (NSError*) err
{
assert([NSThread isMainThread]);
if([delegate respondsToSelector: selector])
{
    if(arg != NULL)
    {
        [delegate performSelector: selector withObject: arg withObject: err];
    }
    else
    {
        [delegate performSelector: selector withObject: err];
    }
}
else
{
    NSLog(@"Missed Method");
}
}

代码是外部教程网站教程的一部分 - 我无法确定导致我的应用程序在此崩溃的问题。

有谁知道代码导致崩溃的原因?任何帮助将非常感激。我发现很难在任何设备上复制崩溃,并且使用NSZombies也可能因为我无法重新创建崩溃而无法正常工作。

提前谢谢大家。

1 个答案:

答案 0 :(得分:0)

您正在调用的选择器似乎有两个参数:'arg'和'error'。现在的问题是,如果'arg'为nil,你将选择器调用仅一个参数 - 所以第二个参数基本上是垃圾,并且当调用选择器的对象尝试时访问第二个参数,它崩溃了。总而言之,您不需要if() - 始终将两个参数传递给选择器,并让委托检测其第一个参数是否为nil。

相关问题