I have a json array and I am using the following to retrieve data:
- (void) retrieveData
{
NSURL * url = [NSURL URLWithString:getDataURL];
NSData * data = [NSData dataWithContentsOfURL:url];
jsonArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//set up cities array
dronesArray = [[NSMutableArray alloc] init];
//Loop json array
for (int i = 0; i < jsonArray.count; i++)
{
//Create city/drone object
NSString * dID = [[jsonArray objectAtIndex:i] objectForKey:@"id"];
NSString * dName = [[jsonArray objectAtIndex:i] objectForKey:@"droneName"];
NSString * dPic = [[jsonArray objectAtIndex:i] objectForKey:@"dronePic"];
[dronesArray addObject:[[City alloc]initWithDroneName:dName andDronePic:dPic]];
}
}
The above displays the cells fine:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
City * droneObject;
droneObject = [dronesArray objectAtIndex:indexPath.row];
cell.textLabel.text = droneObject.droneName;
//Accessory
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
But it only displays the Name, there is no image. The images are stored in URL format e.g. http://www.domain.com/image.jpg in the sql database. How can I import the images to make it look like this format:
Ok So I added the following code to cellforrowatindexpath and it doesn't do anything:
[[cell imageView] setImage: [UIImage imageNamed:droneObject.dronePic]];