Re: Copying records from to-many relationship in Core Data
Re: Copying records from to-many relationship in Core Data
- Subject: Re: Copying records from to-many relationship in Core Data
- From: Sean Kline <email@hidden>
- Date: Mon, 7 Sep 2009 12:31:24 -0400
In case anyone is interested (or understood my post ;-)), Rib Rix is helping
me through this one. The issue is that Apple states:
You are typically discouraged from performing fetches within an
implementation of awakeFromInsert. Although it is allowed, execution of the
fetch request can trigger the sending of internal Core Data notifications
which may have unwanted side-effects. For example, on Mac OS X, an instance
of NSArrayController may end up inserting a new object into its content
array twice.
One solution (from Rob) is to push the fetch request to the next iteration
of the run loop (via -performSelector:withObject:afterDelay:)
This fetches properly, does not create two records and (though I have not
tried it yet) I believe will allow me to "copy" the to-many
NSManagedObjects.
Regards,
- S
On Sat, Aug 29, 2009 at 4:50 PM, Sean Kline <email@hidden> wrote:
> Folks,
> I have a Core Data application with two entities (relevant to this
> question) with a to-many relationship between them. When I create a new
> record in Entity 1, I would like to copy the to-many records from Entity 2
> from that last record created into the new record. I tried to execute a
> fetch into an array, but whenever I do this the table that is bound to
> Entity 1 displays two records. There may be something bizarre that I have
> done causing this behavior, but does anyone have any general advice or
> examples to help me achieve what I am trying to do?
>
> Thanks,
>
> - S
>
_______________________________________________
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