Re: Core Data: many-to-many relationships not being saved
Re: Core Data: many-to-many relationships not being saved
- Subject: Re: Core Data: many-to-many relationships not being saved
- From: David Catmull <email@hidden>
- Date: Sat, 17 Jul 2010 09:43:36 -0700
I finally found the answer to this problem. It comes from the way I was setting the relationship. I was calling:
[[expense valueForKey:@"tags"] addObject:tag];
..which apparently is too direct. What I need is something more like:
[[expense mutableSetValueForKey:@"tags"] addObject:tag];
I discovered the answer as I was preparing to post my question on Stack Overflow. It was yet another case of trying to anticipate all the obvious "did you try this" responses, and finding the answer myself in the process.
On Jul 10, 2010, at 9:03 AM, David Catmull wrote:
> In my finance app, I have Expense and Tag entities with many-to-many relationships to each other. But changing those relationships doesn't mark the document as dirty, and the changes don't get saved. It doesn't seem to matter if the relationships are optional or not, and they're not transient. This is the first time I've had trouble with object relationships. What could be causing it?
>
> The project is on GitHub if you want to try it out:
> http://github.com/Uncommon/Budget-Machine
>
> --
> David Catmull
> email@hidden
> http://www.uncommonplace.com/
>
--
David Catmull
email@hidden
http://www.uncommonplace.com/
_______________________________________________
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