i want to set uiimage to a variable outside the scope of function .i tried the code below but it doesn't work . code below is used in custom uitable view cell class . so i just cannot alloc and init it . as this will cause to initialize it every time cell is displayed/ scrolled
uiimage *img;
[manager downloadWithURL:[NSURL URLWithString:friendData.picUrl] options:SDWebImageRefreshCached progress:^(NSInteger receivedSize, NSInteger expectedSize) {
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
img =image; ////this is not working !!
}];
dispatch_async(dispatch_get_main_queue(), ^{
[cell.profileImage setImage:img]; //and off course this wont work too
});