Im有空格添加對象到我的2個NSMutableArrays。數據來自數據庫,我知道我的解析是正確的,因爲我使用NSLog時得到有效的輸出。但是我不知道如何將2個不同的對象添加到我的2個不同的NSMutableArrays中。這裏是我的代碼添加對象到NSMutableArray時遇到問題
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
feed = [allDataDictionary objectForKey:@"feed"];
arrayOfEntry = [feed objectForKey:@"entry"];
for (NSDictionary *dictionary in arrayOfEntry) {
NSDictionary *title = [dictionary objectForKey:@"title"];
NSString *labelTitle = [title objectForKey:@"label"];
[arrayLabel addObject:labelTitle];
NSDictionary *summary = [dictionary objectForKey:@"summary"];
NSString *labelSummary = [summary objectForKey:@"label"];
[arraySummary addObject:labelSummary]; //This line makes the application crash
}
}
出於某種原因,當我要添加labelSummary到arraySummary我得到這個錯誤:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
任何幫助表示讚賞。
你對錯誤信息有什麼想法? – 2013-03-05 18:55:40
我看不到'insertObject:atIndex:'的調用。 – trojanfoe 2013-03-05 18:57:27
@trojanfoe:'addObject:'通過調用。 – 2013-03-05 19:05:37