Last part of string not getting inserted into coredata
I am trying to insert the last part of a string in Core Data store. I am getting the string using NSXMLParser
but the last part of the string does not get inserted.
f开发者_Python百科or (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"];
}
Your code excerpt is too short for us to determine what the problem is, but your mixing of [fields objectForKey:]
and [fields valueForKey:]
rings alarm bells.
精彩评论