2011-12-09 74 views
6

我在定義的排行榜遞歸函數中使用下面的代碼加載照片:遊戲中心無法加載照片幾個玩家ID

-(void)loadPhotos { 
[((GKPlayer*)[players objectAtIndex:i]) loadPhotoForSize:GKPhotoSizeSmall withCompletionHandler: ^(UIImage *photo, NSError *error) { 

      if (error != nil) 
      { 

       NSLog(@"Error: %@", error); 
      } 
      if (photo != nil) 
      { 

       [friendPhotos addObject:photo]; 
       [globalTable reloadData]; 
       i++; 
       if (i< [players count]){ 
        [self loadPhotos]; 
       } 
      } 
     }]; 
} 

我們目前正在測試的應用程序在兩個設備,所以我們有我們的沙箱環境中有2名玩家。然而第一次調用的第一個球員加載照片,但是第二張照片,我無法加載,我打印了以下錯誤:

Error: Error Domain=GKErrorDomain Code=3 "The requested operation could not be completed due to an error communicating with the server." UserInfo=0x1b19f0 {NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server.} 

有什麼建議?

Ps。在循環中也嘗試迭代。同樣的錯誤,我認爲這是因爲我經常打電話。

+0

並且玩家是從GKLeaderboard請求返回的數組中初始化的玩家數組。 –

回答

1

此類錯誤的一個可能的原因是您沒有啓用正確的端口轉發。見this Apple doc