2011-12-09 39 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