SOffer[26229:c07] current Product: (
{
id = 20;
image = "img2.png";
name = "offer 2";
}
)
I have product which result the above when I print it through NSLog,, I need to print the these individually. Following code generate this
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
NSString *currentProductName;
currentProductName = [productKeys objectAtIndex:indexPath.row];
currentProduct = [products objectForKey:[productKeys objectAtIndex:indexPath.row]];
NSLog(@"current Product: %@",currentProduct);
//currentProductName = [currentProduct objectForKey:@"image"];
//currentProduct = [currentProduct ];
[[cell textLabel] setText:currentProductName];
return cell;
}
currentProduct is declared as NSArray but when i try to print with objectForKey it say No visible interface for NSArray declares the selector ObjectForKey
objectForKey, I believe works withNSDictionaryonly.NSArraydoes not have key value pairs. UnlesscurrentProductholds the JSON file, then you gonna have to first get out the Array Object of the first Product and assign it to aNSDictionary, where you can then use theobjectForKeyto get your image value.Something like this: