【发布时间】:2014-07-22 21:16:05
【问题描述】:
这是我收到的错误消息: 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSCFString authenticationChanged]:无法识别的选择器已发送到实例 0x176769a0” 首先抛出调用堆栈: (0x30496ecb 0x3ac31ce7 0x3049a7f7 0x304990f7 0x303e8058 0x30458f01 0x303ccd69 0x30db8cc5 0x3102f43b 0x3b11ad53 0x3b11ad3f 0x3b11d6c3 0x30461641 0x3045ff0d 0x303ca729 0x303ca50b 0x353396d3 0x32d2b871 0xb8591 0x3b12fab7) libc++abi.dylib:以 NSException 类型的未捕获异常终止
我将游戏中心集成到应用程序中,这是可能导致崩溃的代码:
- (id)init {
if ((self = [super init]))
{
gameCenterAvailable = [self isGameCenterAvailable];
if (gameCenterAvailable) {
NSNotificationCenter *nc =
[NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(authenticationChanged)
name:GKPlayerAuthenticationDidChangeNotificationName
object:nil];
}
}
return self;
}
- (void)authenticationChanged {
if ([GKLocalPlayer localPlayer].isAuthenticated && !userAuthenticated) {
NSLog(@"Authentication changed: player authenticated.");
userAuthenticated = TRUE;
} else if (![GKLocalPlayer localPlayer].isAuthenticated && userAuthenticated) {
NSLog(@"Authentication changed: player not authenticated");
userAuthenticated = FALSE;
}
【问题讨论】:
-
您能否在您的问题中添加 authenticationChanged 方法?
-
那是非常糟糕的代码。对不起,我很抱歉,但我建议你回到你的基础。
-
ups,我粘贴时代码格式不正确。已编辑。
标签: ios ios7 crash game-center unrecognized-selector