Saturday 29 March 2014

Loading Table view Cell image form URL

 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0) , ^{
                    NSData *imgData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"Image url here"]];
                    if (imgData) {
                        UIImage *image = [UIImage imageWithData:imgData];
                        if (image) {
                            dispatch_async(dispatch_get_main_queue(), ^{
                                MyCustomCell  *cell = (id)[tableView cellForRowAtIndexPath:indexPath];
                                if (cell)
                                    cell.myCellImgView.image=image;
                            });
                        }
                    }
                });

No comments:

Post a Comment