2012-09-24 87 views
1

剛剛完成我的第一個iOS遊戲(大部分)。它的一切準備就緒,只需要在Game Center中鏈接。然而,這證明是...煩人的。我的應用程序全部在iTunes Connect上註冊,所有Game Center代碼均直接從Apple獲取。那麼爲什麼NONE這個工作?遊戲中心的問題

第一:認證總是失敗;

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; 

localPlayer.authenticateHandler = ^(UIViewController *loginVC, NSError *error) { 
    if ([GKLocalPlayer localPlayer].authenticated) { 
     // authentication successful 
    } 
    else if (loginVC) { 
     // player not logged in yet, present the vc 
     [self presentViewController:loginVC animated:YES completion:nil]; 
    } 
    else { 
     // authentication failed 
    } 
}; 

有了錯誤「的請求的操作已被取消」

其必然結果是,試圖在未來呈現遊戲中心VC yeilds一個「球員沒有在消息簽署」

二:這個

GKScore *score = [[GKScore alloc] init]; 
if (score) { 
    score.value = self->selectedScore; 
    NSArray* scoreArray = [[NSArray alloc]initWithObjects:score, nil]; 
    //score.category = @"High Scores"; 

    UIActivityViewController *avc = [[UIActivityViewController alloc] 
            initWithActivityItems:scoreArray applicationActivities:nil]; 
    avc.completionHandler = ^(NSString *activityType, BOOL completed) { 
     if (completed) 
      [self dismissViewControllerAnimated:YES completion:nil]; 
    }; 

    if (avc) 
     [self presentViewController:avc animated:YES completion:nil]; 
} 

yeilds一個'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'

我從根本上做錯了什麼?感謝任何可以提供任何幫助的人。

+0

您在第一個代碼塊中似乎有複製錯誤,請問您能糾正它嗎? – Kevin

+0

抱歉。固定!感謝提高 –

回答

3

嘗試使用您的測試用戶帳戶在Game Center應用程序中註銷/註銷。
檢查答案:https://stackoverflow.com/a/4420457/89364

+0

雅,奇怪的是,工作。更奇怪的是爲什麼我從來沒有想過這樣做。儘管如此,感謝您花時間閱讀/回覆!不勝感激! –