Core Data NSSQLiteStoreType problem
Core Data NSSQLiteStoreType problem
- Subject: Core Data NSSQLiteStoreType problem
- From: email@hidden
- Date: Sun, 11 Nov 2007 16:18:36 +0900
Hi, all.
I am developing a (non-document based) Core Data app and am facing
a problem with saving data in NSSQLiteStoreType.
The app has a subclass of NSManagedObject and can add to-many
relationship
through a custom accessor.
@interface AClass : NSManagedObject
{
}
- (void) addRelation: (NSManagedObject *) aManagedObject;
@end
- (void) addRelation: (NSManagedObject *) aManagedObject
{
NSSet * changedObjects = [[NSSet alloc] initWithObjects:
&aManagedObject count:1];
[self willChangeValueForKey: @"relation"
withSetMutation: NSKeyValueUnionSetMutation
usingObjects: changedObjects];
[[self primitiveValueForKey: @"relation"] addObject: aManagedObject];
[self didChangeValueForKey: @"relation"
withSetMutation: NSKeyValueUnionSetMutation
usingObjects: changedObjects];
[changedObjects release];
}
The custom to-many accessor is the same code introduced in Listing 4
of Managed Object Accessor Methods in Core Data Programming Guide.
In my code, I add managed objects with this accessor and the objects
are added and the to-many relation are established correctly.
But once I save the data and close the app then restart it again,
the objects themselves remain there but the relations of some objects
disappear. (Not all, but some. The relation is not transient.)
I was using NSSQLiteStoreType and when I changed it to NSXMLStoreType
or NSBinaryStoreType, there was no problem and all the relations
remained
after the app was closed and restarted. All the other codes were the
same.
Just the behavior of NSSQLiteStoreType was different.
I wonder why and when the relations once established disappear, only
when
I use NSSQLiteStoreType. Does the type need some extra code the other
types
don't need?
I am using Xcode 3.0 on Leopard.
Thank you.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden