I've done the Raywenderlich tutorial about JSON in iOS but I got difficulties to adapt it to my own JSON file. Here is my JSON:
{
"Albumvideo":[
{
"titre": "Publicité",
"photo":"blabla.jpg"
},
{
"titre": "Events",
"photo":"blabla.jpg"
}
]
}
Here is my Code:
- (void) viewDidLoad
{
[super viewDidLoad];
dispatch_async (kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL:lienAlbumsVideo];
[self performSelectorOnMainThread:@selector(fetchedData:)withObject:data waitUntilDone:YES];
});
}
- (void)fetchedData:(NSData *)responseData {
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSArray* albumsvideo = [json objectForKey:@"titre"];
NSLog(@"Album: %@", albumsvideo);
}
Log returns null
.