问题:
NSManagedObjectContext* mainContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
[context setPersistentStoreCoordinator:coordinator];
NSManagedObjectContext* childContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
[childContext setParentContext:mainContext];
Amount* amount = [[Amount alloc] initWithEntity:[NSEntityDescription entityForName:@"Amount" inManagedObjectContext:context] insertIntoManagedObjectContext:nil];
amount.xyz = @"String";
[childContext insertObject:amount];
/*
(lldb) po [childContext insertedObjects]
{(
<Amount: 0x7fc3635b90f0> (entity: Amount; id: 0x7fc3635b7a00 <x-coredata:///Amount/t3176AD5B-914D-469D-AFCE-21D5D679E3652> ; data: {
xyz = String;
})
)}
*/
NSError* error = nil;
[childContext save:&error];
childContext
MO被推送到mainContext,但是为什么xyz是nil并且它不是&#34; String&#34;?我很苦恼!
/*
(lldb) po [mainContext insertedObjects]
{(
<Amount: 0x7fc3634701e0> (entity: Amount; id: 0x7fc3635b7a00 <x-coredata:///Amount/t3176AD5B-914D-469D-AFCE-21D5D679E3652> ; data: {
xyz = nil;
})
)}
*/