Here is the code:

NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; NSLog(@"%@", dictionary); NSArray *values = [dictionary allValues]; NSString *string = [NSString stringWithFormat:@"%@", [values valueForKey:@"src_xbig"]]; 

Here is what is displayed in the console:

 ( 1, { aid = "-6"; created = 1475346651; height = 1600; "owner_id" = 387268685; pid = 435535181; "post_id" = 1; src = "http://cs836734.vk.me/v836734685/2d92/92R22lgR4kk.jpg"; "src_big" = "http://cs836734.vk.me/v836734685/2d93/QSJ4LmBslYQ.jpg"; "src_small" = "http://cs836734.vk.me/v836734685/2d91/N36BgXu2xkw.jpg"; "src_xbig" = "http://cs836734.vk.me/v836734685/2d94/558Lo99OeIY.jpg"; "src_xxbig" = "http://cs836734.vk.me/v836734685/2d95/dGVo-f5-Jes.jpg"; "src_xxxbig" = "http://cs836734.vk.me/v836734685/2d96/KjRB_7NFoE8.jpg"; text = ""; width = 1200; } ) 
  • in my opinion it is not a dictionary - Max Mikheyenko
  • I also do not understand what it is) - Orest Mykha
  • This comes after I want to get the url photo user from vk - Orest Mykha
  • Well, either write the answer or delete - Max Mikheyenko
  • I wrote what and where I replaced) Maybe it will also help someone - Orest Mykha

2 answers 2

JSON comes to you not in the form of a dictionary of meanings, but in the form of an array.

Therefore the following code will be correct.

 NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; NSString *string1 = [NSString stringWithFormat:@"%@", [[array lastObject] valueForKey:@"src_xbig"]]; 

But I would not advise writing out only one link to the image, it is better to create a class module for this answer and "map" the answer to it. Since different image sizes come for better display on different devices

    Decided thus:

     NSString *string1 = [NSString stringWithFormat:@"%@", [[[values objectAtIndex:0] objectAtIndex:1] valueForKey:@"src_xbig"]];