• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data: During Migration, should use Primitive Accessors only?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data: During Migration, should use Primitive Accessors only?


  • Subject: Re: Core Data: During Migration, should use Primitive Accessors only?
  • From: Adam Swift <email@hidden>
  • Date: Thu, 18 Nov 2010 11:49:10 -0800

On Nov 18, 2010, at 6:17 AM, Jerry Krinock wrote:

>
> On 2010 Nov 16, at 16:51, Quincey Morris wrote:
>
>> 2. If you have a *custom* NSManagedObject subclass (i.e. whose subclass name is known to the Core Data entity), you can of course override the Core-Data-supplied accessor methods by writing your own. Adam was saying that there isn't supposed to be any legal way to use such custom subclasses during migration.
>
> Thanks, Quincey.  My claims are that such usage should not happen, and indeed you don't want it to happen, but if you're not careful, it will happen…
>
> 1.  If you invoke -(set)foo of -(setValue:)forKey: during a migration, and you have overridden accessors with custom accessors, Core Data will find the custom accessors and use them.
>
This is absolutely untrue - CoreData is not going to use instances of your custom subclass during migration - your subclasses implementation of foo/setFoo: are not going to be wired up on NSManagedObject.

> 2.  This will cause undesirable results.
>
> 3.  To prevent Core Data from using the custom accessors during migration, use the "…Primitive…" accessors instead.

This isn't necessary - but if you choose to call the primitives you need to first call willAccessValueForKey: and then after didAccessValueForKey:.  See the managed object accessor methods documentation I referred to:

	If you want to implement your own attribute or to-one relationship accessor methods, you use the primitive accessor methods to get and set values from and to the managed object's private internal store. You must invoke the relevant access and change notification methods

	http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html#//apple_ref/doc/uid/TP40002154-SW9


>
> _______________________________________________
>
> 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

References: 
 >Core Data: During Migration, should use Primitive Accessors only? (From: Jerry Krinock <email@hidden>)
 >Re: Core Data: During Migration, should use Primitive Accessors only? (From: Adam Swift <email@hidden>)
 >Re: Core Data: During Migration, should use Primitive Accessors only? (From: Jerry Krinock <email@hidden>)
 >Re: Core Data: During Migration, should use Primitive Accessors only? (From: Adam Swift <email@hidden>)
 >Re: Core Data: During Migration, should use Primitive Accessors only? (From: Jerry Krinock <email@hidden>)
 >Re: Core Data: During Migration, should use Primitive Accessors only? (From: Quincey Morris <email@hidden>)
 >Re: Core Data: During Migration, should use Primitive Accessors only? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: NSTimer firedate randomly changes
  • Next by Date: Re: Core Data: During Migration, should use Primitive Accessors only?
  • Previous by thread: Re: Core Data: During Migration, should use Primitive Accessors only?
  • Next by thread: Re: Core Data: During Migration, should use Primitive Accessors only?
  • Index(es):
    • Date
    • Thread