我试图使用JSON框架和OBJ-C无法读取使用的OBJ-C
{
Sections = {
Now = "Wednesday 9 February 2011 02:40";
Section = (
{
Article = (
{
Exceprt = "text here";
ID = 49011;
Title = "text here";
Type = Politics;
audioCounter = 0;
commentsCounter = 0;
hasMore = false;
important = False;
likesCounter = 0;
photoCounter = 0;
time = "21:12";
timeStamp = "2/8/2011 9:14:16 PM";
timeStatus = True;
videoCounter = 0;
viewsCounter = 0;
},
{
Exceprt = "text here";
ID = 49010;
Title = "text here";
Type = Politics;
audioCounter = 0;
commentsCounter = 0;
hasMore = false;
important = True;
likesCounter = 0;
photoCounter = 0;
time = "20:45";
timeStamp = "2/8/2011 9:10:59 PM";
timeStatus = True;
videoCounter = 0;
viewsCounter = 0;
},
{
Exceprt = "text here";
ID = 49008;
Title = "text here";
Type = Politics;
audioCounter = 0;
commentsCounter = 0;
hasMore = false;
important = False;
likesCounter = 0;
photoCounter = 0;
time = "20:28";
timeStamp = "2/8/2011 9:09:44 PM";
timeStatus = True;
videoCounter = 0;
viewsCounter = 0;
}
);
ID = 22;
Name = "EN Live";
totalNews = 3416;
}
);
};
}
我的目的是让字典的文章的列表(列表阅读以下JSON对象JSON对象),以便我稍后可以轻松访问它们。我一直坚持这一点,我的代码给我一个关于调用NSArray不存在的方法的错误,这导致我怀疑我误解了json对象。我对此完全陌生,任何帮助都非常感谢。
这里是我的代码:
NSDictionary *results = [jsonString JSONValue];
NSDictionary *Articles = [[results objectForKey:@"Sections"] objectForKey:@"Section"];
NSArray *ListOfArticles = [Articles objectForKey:@"Article"];
for (NSDictionary *article in ListOfArticles)
{
NSString *title = [article objectForKey:@"Title"];
NSLog(title);
}
谢谢!
One note:Exceprt is misspelt。正确的拼写是摘录。 – 2011-02-09 01:11:23
好眼睛!不幸的是,我无法控制:) – Pepe 2011-02-09 01:15:09