Quantcast
Channel: Get newsfeed with Facebook GraphApi in iOS App - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Get newsfeed with Facebook GraphApi in iOS App

$
0
0

I need to view the facebook newsfeeds in my UITableView. I send an asynchronous request to the server and I have obtained the list of newsfeeds. The problem is that i do not obtain, for each feed, the size of the image, and so I must send another asynchronous request to the server nested to previous asynchronous request. This code is very low efficent because I must reload my UITableView repeatedly (see my code).

I need get the image size so as set the height of the UITableCell and the dimension of UIImageView inside the cell.

Any idea to solve my problem ?

Below my code:

-(void)loadData{    //self.tableView.rowHeight = UITableViewAutomaticDimension;    screenRect = [[UIScreen mainScreen] bounds];    screenWidth = screenRect.size.width;    screenHeight = screenRect.size.height;    self.imgDic=[[NSMutableDictionary alloc]init];    self.desArr=[[NSMutableArray alloc]init];    self.mexArr=[[NSMutableArray alloc]init];    self.udidArr=[[NSMutableArray alloc]init];    [FBRequestConnection startWithGraphPath:@"/guide/feed" completionHandler:^(FBRequestConnection *connection,id result,NSError *error){        NSDictionary *data = [result objectForKey:@"data"];        for(NSDictionary *dic in data) {            if([dic objectForKey:@"description"]==nil){                [self.desArr addObject:@""];            }else{                [self.desArr addObject:[dic objectForKey:@"description"]];            }            if([dic objectForKey:@"object_id"]==nil){                [self.udidArr addObject:@""];            }else{                [self.udidArr addObject:[dic objectForKey:@"object_id"]];                [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"/%@",[dic objectForKey:@"object_id"]] completionHandler:^(FBRequestConnection *connection,id result,NSError *error) {                    [self.imgDic setObject:[result objectForKey:@"images"] forKey:[result objectForKey:@"id"]];                    //NSLog(@"%@",[result objectForKey:@"id"]);                    //NSLog(@"%@",[result objectForKey:@"images"]);                    [self.tableView reloadData];                 }];            }            if([dic objectForKey:@"message"]==nil){              [self.mexArr addObject:@""];            }else{              [self.mexArr addObject:[dic objectForKey:@"message"]];            }        }        [self.tableView reloadData];     }];}- (void)viewDidLoad {    [super viewDidLoad];    [self loadData];}

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images