2014-03-06 32 views
1

我從Parse獲取Facebook朋友列表以及所有數據在任何數組中。例如:iOS獲取解析Facebook朋友的姓名和分數

(
"<PFUser:npzU2fuydD:(null)> { 
\n HS = 99; 
\n fbId = 1000000000000000; 
\n profile =  { 
\n  facebookId = 100000748420227; 
\n  name = \"Name Lastname"; 
\n  pictureURL = \"https://graph.facebook.com/100000000000000/picture?type=large&return_ssl_resources=1\"; 
\n }; 
\n username = k49vitcfqbb22p0pu40ejy6oh;\n}" 

下面的代碼:

[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
    if (!error) { 
     // result will contain an array with your user's friends in the "data" key 
     NSArray *friendObjects = [result objectForKey:@"data"]; 
     NSMutableArray *friendIds = [NSMutableArray arrayWithCapacity:friendObjects.count]; 
     // Create a list of friends' Facebook IDs 
     for (NSDictionary *friendObject in friendObjects) { 
      [friendIds addObject:[friendObject objectForKey:@"id"]]; 
     } 

     // Construct a PFUser query that will find friends whose facebook ids 
     // are contained in the current user's friend list. 
     PFQuery *friendQuery = [PFUser query]; 
     [friendQuery whereKey:@"fbId" containedIn:friendIds]; 

     // findObjects will return a list of PFUsers that are friends 
     // with the current user 
     NSArray *friendUsers = [friendQuery findObjects]; 
     NSLog(@"Firends: %i", friendUsers.count); 
     NSLog(@"%@", friendUsers); 

     [[PFUser currentUser] saveInBackground]; 
    } 
}]; 

所以,現在,從NSArray中friendUsers我需要另一個數組一樣friendNames,其中有擺脫使用鍵「輪廓」 friendUsers信息,其中關鍵是「名字」。我無法找到如何編寫這個工作......此外,我將在TableView中使用的數組「friendNames」。

回答