Re: Error with proxy objects and to-many relationships with Core Data
Re: Error with proxy objects and to-many relationships with Core Data
- Subject: Re: Error with proxy objects and to-many relationships with Core Data
- From: "Sean Willson" <email@hidden>
- Date: Sun, 26 Feb 2006 22:42:25 -0600
As you can see from the sample code, I am in fact setting the to-one side of
the relationships in the setFooBar method call. That in turn should call the
to-many relationship setup, but that's where it's erroring out.
I sort of follow your train of thought but I guess what I don't understand
is that since I'm creating the object myself using:
inObject = (WASomeObject *)[NSEntityDescription
insertNewObjectForEntityForName:@"SomeObject"
inManagedObjectContext:context];
I'm not relying on the proxy object returned from say newObject or what not.
Since this is the object itself and even in turn with the code that mmalcolm
suggested:
[inObject setCourse:[[fooBarController selectedObjects] objectAtIndex:0]];
This should be dealing with all objects, and no proxies but in fact it
errors out with the same message.
Any other ideas? Thanks for the help, I appreciate it.
Sean
On 2/26/06, Greg Herlihy <email@hidden> wrote:
>
> The program is attempting to make the NSArrayController's own proxy object
> the contents of the to-many relationship. Data added to the object graph
> cannot be proxies for the data to be added but has to be the modeled data
> itself. Another way to look at the problem is if the proxies could replace
> the data they are supposed to be proxying, they would would no longer be
> proxies of data but would have become the data itself.
>
> The other problem this program is likely to run into is specifying a
> single
> object for a to-many relationship. When specifying the contents of a
> to-many
> relationship, the program should first place the object or objects into an
> NSSet or request an NSMutableSet of the relationship's objects to
> manipulate
> on its own.
>
> But here's a way to make to-many relationships easier to manage -
> especially
> when the program wants to add a single object to a relationship that
> already
> has existing members. Instead of dealing with the to-many relationship,
> the
> program can instead specify the content for the inverse, to-one
> relationship
> on the object to be added (and there should be an inverse relationship in
> most models). By setting up one-half of the relationship (the simple side
> of
> the relationship), the program is spared the more complicated, multiple
> object operation, and just lets Core Data deal with it.
>
> Greg
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden