[英]JSON how to call an object in a different list
我目前有一個看起來像這樣的JSON API:
{
"posts": [
{
"id": 277,
"title": "test title",
"content": "test content",
"attachments": [
{
"url": "http:\/\/www.example.com\/bar-icon-help@2x.png"
}
}
}
我正在嘗試使用“附件”下的“ URL”。 請看看我在做什么錯:
-(void)dataRequestCompletedWithJsonObject.(id)jsonObject
{
NSDictionary *recipeDictionary = (NSDictionary*)jsonObject;
NSArray* recipeArray = (NSArray*)[recipeDictionary objectForKey:@"posts"];
self.recipes = [[NSMutableArray alloc] init];
for (NSDictionary* dic in recipeArray) {
Recipe *recipe = [[Recipe alloc] init];
recipe.name = [dic objectForKey:@"title"];
recipe.thumbNail = [[dic objectForKey:@"attachements"]objectForKey:@"url"];
recipe.twitterShareCount = [[dic objectForKey:@"id"] intValue];
[recipes addObject:recipe];
}
主要試圖弄清楚我應該用什么代替這行:
recipe.thumbNail = [[dic objectForKey:@"attachements"]objectForKey:@"url"];
感謝任何幫助!
您在附件對象中有一組字典。
[[[dic objectForKey:@"attachements"] objectAtIndex:0] objectForKey:@"url"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.