Re: Copying Managed Objects from App to Doc MOContext
Re: Copying Managed Objects from App to Doc MOContext
- Subject: Re: Copying Managed Objects from App to Doc MOContext
- From: "Kyle Sluder" <email@hidden>
- Date: Sat, 20 Dec 2008 23:21:04 -0500
On Sat, Dec 20, 2008 at 9:29 PM, Jerry Krinock <email@hidden> wrote:
> Both. The app-wide MOC has its PSC set to the app-wide PSC, which in turn
> has a persistent store in the Application Support folder.
OK, good, glad I understood you there.
> By UUID, I believe you mean [[[self objectID] URIRepresentation]
> absoluteString].
Yes.
> I'd considered that, but since it's possible that the source potato in the
> central store might go away, indeed I want a copy. I was thinking that, for
> portability and robustness, in most cases one would not want a document to
> reference an object in an app's Application Support.
This is a situation you will need to handle anyway when you're dealing
with multiple MOCs, since they don't notify each other of changes. If
you are cloning your prototypical potatoes simply because you're
afraid of them disappearing in your app's PSC, then I recommend you
look into Fetched Properties:
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html#//apple_ref/doc/uid/TP40001857-SW7
.
Again, you need to determine if your app's semantics really do require
you to clone your prototypes. In most apps, for example, if you
create a new document based on a template and then change the template
the document doesn't get changed. If that's the behavior your app
needs, then keep doing what you're doing. Otherwise, look into
modeling a cross-store relationship. You could perhaps store a
"referencedByCount" attribute in your global objects, and ensure that
objects don't get deleted unless this attribute is zero.
--Kyle Sluder
>
> Thank you, Kyle -- I'm starting to see a clearer picture what I'm doing now.
>
> _______________________________________________
>
> 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
>
_______________________________________________
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