Game Center Friend List

后端 未结 2 1786
清酒与你
清酒与你 2021-01-21 18:38

All

I made a game for the Apple iOS. Now I would like to show my friend list in Apple\'s Game Center.

How can I show the Game Center friend list of a logged in p

2条回答
  •  甜味超标
    2021-01-21 19:10

    For a single Block:

    -(void)loadPlayerData:(void (^)(NSArray * playerObjects))complete
    {
        GKLocalPlayer *lp = [GKLocalPlayer localPlayer];
        if (lp.authenticated)
        {
            [lp loadFriendsWithCompletionHandler:^(NSArray *friends, NSError *error)
             {
                 if (friends != nil)
                 {
                     [GKPlayer loadPlayersForIdentifiers:friends withCompletionHandler:^(NSArray *players, NSError *error)
                      {
    
                          if (error != nil)
                          {
    //                            return @[error];
                              // Handle the error.
                          }
                          else
                          {
                              complete (players);
    
                          }
                      }];
                 }
             }];
        }
    }
    

提交回复
热议问题