I am displaying images in UITableview
using json data and get images. But the data is displayed in UITablevewcells
. But images are not displyed. It will take time and after images are displayed. so I want to displayed the images for my uitableview asynchronously using GCD.But I have no idea of asynchronous GCD Concept.Please give me any idea how to applicable asynchronous GCD concept in my coding. please give me guidance any body.
This is my code.
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible=YES;
NSError *err;
NSString *strResponse=[[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"response is %@",strResponse);
dit=[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:&err];
NSArray *arrResults = [dit valueForKey:@"classifieds_mst"];
listOfObjects = [NSMutableArray array];
for(dictRes in arrResults) {
Attributes *at = [[Attributes alloc]init];
at.classimage=[dictRes valueForKey:@"image_name"];
[listOfObjects addObject:at];
}
[tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier=@"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"identifier"];
}
classifiedimage=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 300, 80)];
[cell.contentView addSubview:classifiedimage];
NSString *str;
str=att.classimage;
if(str==nil) {
classifiedimage.image=[UIImage imageNamed:@"image.png"];
} else{
url=@"My url";
NSString *addurl=[url stringByAppendingString:str];
classifiedimage.image = [UIImage imageNamed:addurl];
}
return cell;
}