2011-07-14 30 views
0

我试图在Core数据存储中插入字符串的最后一部分。我正在使用NSXMLParser获取字符串,但字符串的最后部分未被插入。字符串的最后部分没有插入到coredata

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

什么'newNote'键名出高,低,条件或状态,没有被设置? – TechZen

+0

'fields'字典实际上是否有'字符串'键或是一个错字? – TechZen

回答

2

你的代码片段太短,我们确定是什么问题,但你的[fields objectForKey:][fields valueForKey:]环警钟混合。

相关问题