我很难将对象添加到我的 2 个 NSMutableArrays。数据来自数据库,我知道我的解析是正确的,因为我在使用 NSLog 时得到了有效的输出。但是我不知道如何将 2 个不同的对象添加到我的 2 个不同的 NSMutableArrays 中。这是我的代码
-(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'
任何帮助表示赞赏。