わかりました、これは Objective-C での JSON への私の最初のアプローチです (そして、私は最後のものにもまったく慣れていません)。私はObjective-Cでそれらを使用するために私のjsonに保存された情報を取得しますが、それを読み込もうとすると、NSLog(@"%@",allData);
上からの応答でnullが返されます。誰が私が間違っているのか教えてもらえますか? あなたの時間とあなたの忍耐に前もって感謝します. ああ、必要に応じて、ここに json があります:
http://jsonviewer.stack.hu/#http://conqui.it/ricette.json
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"recipes" ofType:@"json"];
NSError *error = nil;
NSMutableData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error];
NSLog(@"%@",JSONData);
NSArray *allData = [NSJSONSerialization JSONObjectWithData:JSONData options:0 error:nil];
NSLog(@"%@",allData);
for (NSDictionary *diction in allData) {
NSString *recipe = [diction objectForKey:@"recipe"];
[array addObject:recipe];
}
NSLog(@"%@",array);