我使用JSON解析了itunes rss提要,但遇到了問題。下面的代碼正確運行一個movieName輸出,但我仍然沒有得到movieSummary輸出,請幫助我。如何解析JSON並擁有2個最終數據陣列
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
feed = [allDataDictionary objectForKey:@"feed"];
arrayOfEntry = [feed objectForKey:@"entry"];
for (NSDictionary *dictionTitle in arrayOfEntry) {
NSDictionary *title = [dictionTitle objectForKey:@"title"];
NSString *labelTitle = [title objectForKey:@"label"];
[arrayLable addObject:labelTitle];
NSDictionary *summary = [dictionTitle objectForKey:@"summary"];
NSString *labelSummary = [summary objectForKey:@"label"];
[arraySummary addObject:labelSummary];
}
movieName.text = [arrayLable objectAtIndex:0];
movieSummary.text = [arraySummary objectAtIndex:0]; //This is not displaying
}
這裏是我解析鏈接:http://itunes.apple.com/us/rss/topmovies/limit=300/json
任何幫助,將不勝感激。
也許一個愚蠢的問題,但你初始化'arraySummary'? – rickerbh 2013-02-27 04:14:02
只要我這樣做,應用程序崩潰。這是我在做什麼初始化2數組arrayLable = [[NSMutableArray alloc] init]; [arrayLable removeAllObjects]; arraySummary = [[NSMutableArray alloc] init]; [arraySummary removeAllObjects];雖然已經有了arrayLable初始化的應用程序,只要我初始化arraySummary它崩潰。 – RockPaperScissors 2013-02-27 06:31:33
你如何定義/聲明arraySummary? – rickerbh 2013-02-27 06:34:14