Alexander
Alexander

Reputation: 770

FBFriendPickerViewController select friends programmatically

I want to implement "Select All" feature on FBFriendPickerViewController, but I don't really see any ability to select friends from code. Maybe I'm missing something?

Upvotes: 1

Views: 164

Answers (1)

Lorenzo S
Lorenzo S

Reputation: 1397

I don't know how exactly is the procedure in StackOverflow for similar questions, anyway if it can still be of any help, the solution is posted here.

Quoting:

I have an NSDictionary dict whose key is the facebook user id and the value is the name. Roughly, this is the code:

NSMutableArray *results = [[NSMutableArray alloc] init];
for (id key in dict) {
  NSString *name = [dict valueForKey:key];
  id<FBGraphUser> user = (id<FBGraphUser>)[FBGraphObject graphObject];
  user.id = key;
  [user setName:name]; // This is not mandatory
  if (user) {
    NSLog(@"adding user: %@", user.name);
    [results addObject:user];
  }
}
// And finally set the selection property
friendPickerController.selection = results;

Upvotes: 1

Related Questions