2012-08-23 42 views
0

我目前正在使用Facebook的api的FBFriendPicker獲取一個選定的朋友的名字。我怎樣才能同時獲得朋友的用戶ID。以下功能用於名稱。如何使用FBFriendPicker從Facebook獲取用戶ID iOS API a

// Facebook integration 
- (void)facebookViewControllerDoneWasPressed:(id)sender { 
    NSString *text; 

    // we pick up the users from the selection, and create a string that we use to update the text view 
    // at the bottom of the display; note that self.selection is a property inherited from our base class 
    for (id<FBGraphUser> user in self.friendPickerController.selection) { 
     self.name.text = user.name; 
    } 

    [self dismissModalViewControllerAnimated:YES]; 
} 

回答

1
for (id<FBGraphUser> user in self.friendPickerController.selection) { 
    NSLog(@"Name: %@ ID: %@", user.name, user.id); 
} 

我知道名字和採摘將在日誌這種方式顯示朋友的ID ..

因此,而不是使用「名」,只是用「身份證」,多數民衆贊成如果你想使用它作爲一個字符串.. :)

0

你可以得到ID爲所有選擇的朋友,可以按照以下添加到陣列:

///得到selsected朋友ID ////////

  • (void)facebookViewControllerDoneWasPressed:(id)sender {

    NSMutableString * text = [[NSMutableString alloc] init]; selectIDs = [[NSMutableArray alloc] init];

    //我們從選擇中選取用戶,並創建一個字符串,用於更新顯示屏底部的文本視圖 ;注意,self.selection是一個屬性從我們的基類繼承 爲(在self.friendPickerController.selection ID用戶){

    if ([text length]) { 
        [text appendString:@", "]; 
    } 
    [text appendString:user.name]; 
    [selectIDs addObject:user.id]; 
    

    } [自dismissModalViewControllerAnimated:YES]; }

相關問題