我正在尝试在Core Data存储中插入字符串的最后一部分。我使用NSXMLParser
获取字符串,但字符串的最后一部分未插入。
for (NSMutableDictionary *fields in [delegate forecastConditions]) {
// NSLog(@"got %@", fields);
NSNumber*high=[fields objectForKey:@"high"];
NSLog(@"the high is %@",high);
NSManagedObjectContext *new=[self managedObjectContext];
NSManagedObject *newNote;
newNote=[NSEntityDescription insertNewObjectForEntityForName:@"Weather" inManagedObjectContext:new];
[newNote setValue:[fields valueForKey:@"high"] forKey:@"high"];
NSNumber *low=[fields objectForKey:@"low"];
NSLog(@"the low is %@",low);
[newNote setValue:[fields valueForKey:@"low"] forKey:@"low"];
NSString*icon=[fields objectForKey:@"icon"];
NSString *all=[icon lastPathComponent];
NSLog(@" the icon is %@",all);
[newNote setValue:[fields valueForKey:@"all"] forKey:@"condition"];
NSString *string=[fields objectForKey:@"condition"];
NSLog(@"the condition is %@",string);
[newNote setValue:[fields valueForKey:@"string"] forKey:@"state"];
}
答案 0 :(得分:2)
您的代码摘录太短,我们无法确定问题所在,但您[fields objectForKey:]
和[fields valueForKey:]
的混合会敲响警钟。