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