I have trouble displaying list friend facebook, I'm using FBRequest, I have already get list friend but it's not showing in UITableView
Here is my code:
- (void)viewDidLoad
{
[self.tblView setDataSource:self];
[self.tblView setDelegate:self];
[super viewDidLoad];
[self loadFirst];
_itemsNamesFriend = [[NSMutableArray alloc] init];
if (FBSession.activeSession.isOpen) {
FBRequest *friendRequest = [[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:@"me/friends"];
[friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSDictionary *resultDictionary = (NSDictionary *)result;
_itemsNamesFriend = [resultDictionary objectForKey:@"data"];
NSLog(@"%@",_itemsNamesFriend); //--> have data
}];
NSLog(@"%@",_itemsNamesFriend); //--> data is empty
[self.tblView reloadData];
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// NSLog(@"%d",_itemsNamesFriend.count);
return _itemsNamesFriend.count;
}
Any modification done to variables inside the block don't show outside of it. So, you need to declare them with __block for the modifications done inside the block to be visible outside.
This is what you need to do in your .h file
That should solve you problem.