0

hear is the response and please do explain in detail Thanks in advance

{
  "success": "true",
  "data": {
    "per_page": 25,
    "total_records": "12",
    "products": [
      {
        "product_id": "48",
        "price": "1699.0000",
        "image": "data/newimages/1.jpg",
        "status": "1",
        "description": "nill",
        "name": "Buy 2 Denim Jeans & 1 Round Tee & 1 Casual Shirt get one  Casual Watch free"
      },
      {
        "product_id": "47",
        "price": "2500.0000",
        "image": "data/newimages/2.jpg",
        "status": "1",
        "description": "nill",
        "name": "2 Branded denim Jeans & 2 Casual Shirt + 1 round neck tee and get a Watch , Card Holder free"
      },
      {
        "product_id": "43",
        "price": "1999.0000",
        "image": "data/newimages/12.jpg",
        "status": "1",
        "description": "nill",
        "name": "Complete Formal Combo By 2 cotton formal trousers & 2 Formal Shirts + 1 formal shoe & 2 formal Belts"
      },
      {
        "product_id": "40",
        "price": "1599.0000",
        "image": "data/newimages/8.jpg",
        "status": "1",
        "description": "nill",
        "name": "7 printed super hero & disney Round Neck Tees get 1 Sneaker Shoes free"
      },
      {
        "product_id": "39",
        "price": "2000.0000",
        "image": "data/newimages/18.jpg",
        "status": "1",
        "description": "nill"
        "name": "Its time to steel the looks with these 5 100% cotton formal Shirts"
      }
]
}
0

1 Answer 1

2

You can easily do this by downloading SDWebImage library, after downloading sdwebimage you need to first import it

#import "UIImageView+WebCache.h"

After import check my "cellForRowAtIndexPath" method of UITableView

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString *CellIdentifier = @"cell";
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell.ImageView sd_setImageWithURL:[NSURL URLWithString:@“URL String”] placeholderImage:[UIImage imageNamed:@“Place holder image name“]];
return cell;}

You can get the array using the below code

NSDictionary *dictionaryYouAlreadyHave;
NSArray *productArray = [[[dictionaryYouAlreadyHave objectForKey:@"data"] objectForKey:@"products"]];

And you can get image name using below code

NSDictionary *dict = [productArray objectAtIndex:0];
NSString *imgName = [dict objectForKey:@"image"];
Sign up to request clarification or add additional context in comments.

8 Comments

Please tell me how do i take the all images in to array i tried following but the app is crashing NSLog(@"imageurl====>: %@ ",[[[json objectForKey:@"data"]objectForKey:@"products"]objectForKey:@"image"]);
You are having Dictionary > Array > Dictionary,
You need to get array from the key products, let me show you the code
NSDictionary *dictionaryYouAlreadyHave; NSArray *productArray = [[[dictionaryYouAlreadyHave objectForKey:@"data"] objectForKey:@"products"]objectForKey:@"image"];
Thank you so much got it
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.