を使用してJSONオブジェクトを読み込むトラブル私は次のようなJSONオブジェクトを読み取るしようとしているの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-フレームワークとOBJ-Cを使用して私の意図は、辞書の記事(リストのリストを持つことです)後で簡単にアクセスできるようになりました。私はこれにしばらく立ち往生していて、私のコードは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);
}
ありがとう!
注:Exceprtはミスペルトです。正しいスペルは抜粋です。 –
いいね!残念ながら私はそれ以上のコントロールはありません:) – Pepe