Created
September 18, 2013 06:32
-
-
Save mbalex99/6605292 to your computer and use it in GitHub Desktop.
JSON AFNetworking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"link"]]; | |
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request | |
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { | |
NSDictionary *jsonDict = (NSDictionary *) JSON; | |
NSArray *products = [jsonDict objectForKey:@"products"]; | |
[products enumerateObjectsUsingBlock:^(id obj,NSUInteger idx, BOOL *stop){ | |
NSString *productIconUrl = [obj objectForKey:@"icon_url"]; | |
}]; | |
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, | |
NSError *error, id JSON) { | |
NSLog(@"Request Failure Because %@",[error userInfo]); | |
} | |
]; | |
[operation start]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"products": [ | |
{ | |
"product_id": "1170", | |
"name": "zzzz®", | |
"sort_order": 0, | |
"brand": "zzzas", | |
"product_category_id": "1090", | |
"location_ids": [ | |
"1078" | |
], | |
"icon_url": "http://zzzzz.com/media/2502/zzzz.png", | |
"icon_date": "Wed, 07 Nov 2012 14:03:47 GMT", | |
"thumbnail_url": "http://zzzz.com/media/2591/zzdfs.png", | |
"thumbnail_date": "Wed, 07 Nov 2012 14:04:02 GMT" | |
}, | |
{ | |
"product_id": "1126", | |
"name": "ddddd®", | |
"sort_order": 1, | |
"brand": "dddsas", | |
"product_category_id": "1110", | |
"location_ids": [ | |
"1095" | |
], | |
"icon_url": "http://zzzzz.com/media/2507/ddddd.png", | |
"icon_date": "Wed, 07 Nov 2012 14:03:48 GMT", | |
"thumbnail_url": "http://zzzzz.com/media/2596/sssds.png", | |
"thumbnail_date": "Wed, 07 Nov 2012 14:04:05 GMT" | |
} | |
]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment