-1
-(void)viewDidLoad { 
    [super viewDidLoad]; // Do any additional setup after loading the view from its nib. self.navigationItem.title = @"New Arrivals";

    [super viewDidLoad]; idsArray=[[NSMutableArray alloc]init]; namesArray=[[NSMutableArray alloc]init]; imagesArray=[[NSMutableArray alloc]init];

    // create the URL we'd like to query

    NSURL *myURL = [[NSURL alloc]initWithString:@"http://www.bikrionline.com/nwarvl-json.php"];

    // we'll receive raw data so we'll create an NSData Object with it NSData *myData = [[NSData alloc]initWithContentsOfURL:myURL];

    // now we'll parse our data using NSJSONSerialization if ([myData length]>0) { id myJSON = [NSJSONSerialization JSONObjectWithData:myData options:NSJSONReadingMutableContainers error:nil]; NSArray *jsonArray = (NSArray *)myJSON; for (int i=0 ; i<[jsonArray count] ; i++) { NSMutableString *urlString = [[NSMutableString alloc]initWithString:@"http://www.bikrionline.com/products/zmphotos/"]; NSString * name = [[[jsonArray objectAtIndex:i]objectForKey:@"prodname"]retain]; [namesArray addObject:name]; [idsArray addObject:[[jsonArray objectAtIndex:i]objectForKey:@"prodid"]]; [urlString appendString:[[jsonArray objectAtIndex:i]objectForKey:@"imageurl"]]; UIImage *imageObj = [self getImageFromUrl:urlString]; urlString = nil; [imagesArray addObject:imageObj]; } }

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"Cell"; 
    CustomCellView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) {
       NSArray *arrNib = [[NSBundle mainBundle] loadNibNamed:@"CustomCellView" owner:self options:nil]; 
       cell = [arrNib objectAtIndex:0]; 
    }
    cell.imgName.text = [namesArray objectAtIndex:indexPath.row];
    cell.custImageView.image=[imagesArray objectAtIndex:indexPath.row];

    return cell; 
}
Vladimir
  • 170,431
  • 36
  • 387
  • 313

2 Answers2

1

You can use some Lib like SDWebImage or Afnetworking. Libs support lazy load image and auto cache this image. All you need to do:

[cell.imageView setImageWithURL:[NSURL URLWithString:@"url of image"]
               placeholderImage:nil];
larva
  • 4,687
  • 1
  • 24
  • 44
-1

This is looking a similar question like lazy loading of an image: Check iOS lazy-loading of table images and Loading images on scrollview using lazy loading for your answer

Community
  • 1
  • 1
Samkit Jain
  • 2,523
  • 16
  • 33