If your data store is SQLite, I believe the problem is the subclass FooSub.

Since FooSub is a subclass of Foo, CoreData combines both Foo and FooSub into a 
single table whose columns include all properties from Foo AND FooSub.

Consequently, when you create a new instance of Foo, columns from FooSub may 
contain invalid data. 

You can easily verify this by opening your SQLite database store with SQLite 
Database Browser, found at:

http://sqlitebrowser.sourceforge.net

For a solution, rework your schema to subclass FooSub directly from 
NSManagedObject.


On Sep 29, 2010, at 9:28 AM, Gideon King wrote:

> Hi, I have a bidirectional one to one relationship between two entities like 
> this:
> 
> Foo <-> Bar, and Foo has a subclass FooSub. All entities are concrete. 
> 
> Sometimes when I set the inverse relationship it's like this aBar.toFoo = 
> aFoo, and this works fine, but when it's linking back to the subclass, 
> aBar.toFoo = aFooSub, it fails with a validation error: toFoo is not valid, 
> dangling reference to an invalid object = null.
> 
> I would have thought it would be OK for the relationship to point to an 
> instance of FooSub shouldn't it? After all, it is a subclass of Foo. Or do 
> things work differently for subclasses in Core Data? If so, how should I work 
> around this problem?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to