【发布时间】:2011-07-14 16:59:56
【问题描述】:
我正在尝试在 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"];
}
【问题讨论】:
-
什么
newNotekeyname out of high、low、condition or state,没有被设置? -
fields字典是否真的有一个string键或者是一个错字?
标签: objective-c ios4 core-data