最后一部分字符串没有插入coredata

时间:2011-07-14 16:59:57

标签: objective-c ios4 core-data

我正在尝试在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"];

        }

1 个答案:

答案 0 :(得分:2)

您的代码摘录太短,我们无法确定问题所在,但您[fields objectForKey:][fields valueForKey:]的混合会敲响警钟。

相关问题