這裏是我正在做這行創建NSManagedObject,就像一個魅力:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:kParentChildSKUSUrl,@"8"]];
NSArray *array = [[NSArray alloc] initWithContentsOfURL:url];
int j = 0;
int saveThreshold = 500;
for (NSDictionary* dict in array) {
j+=1;
ParentChildSKU *entity = (ParentChildSKU*) [NSEntityDescription insertNewObjectForEntityForName:@"ParentChildSKU" inManagedObjectContext:managedObjectContext];
[entity setValuesForKeysWithDictionary:dict];
if (j%saveThreshold==0) {
NSLog(@"Saving after 500 items");
NSError *error;
if (![managedObjectContext save:&error]) {
// Handle the error.
}
}
}
看到這個問題也是,這就是我開始了: Plist Array to NSDictionary