• 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: Jerry Krinock <email@hidden>
  • Date: Tue, 16 Nov 2010 15:55:20 -0800

On 2010 Nov 16, Adam Swift wrote:

> What you seem to be describing shouldn't be possible (unless you've added property accessors to NSManagedObject via a category)

I definitely have not done that.  I subclass NSManagedObject.

Let's step back a little here:

> You should be able to use the standard KVC accessors during migration, NSManagedObjects will respond to the foo/setFoo: laccessors for properties defined in your managed object model.

Well, -foo and -setFoo: won't even compile unless I change the type of the sourceInstance: parameter of the method to be a MyManagedObject* like this:

- (BOOL)createDestinationInstancesForSourceInstance:(MyManagedObject*)foo
                                      entityMapping:(NSEntityMapping*)inMapping
                                            manager:(NSMigrationManager*)inManager
                                              error:(NSError**)error_p

or else do some equivalent typecasting in the implementation.

> - the accessors defined on your subclass are not going to be called during migration because the instances being migrated are not instances of your class.


Makes sense, but I distinctly remember debugging this and seeing in the call stack that KVO was calling my custom accessors.
  I'll have a closer look the next time that I run into this problem.  Making a demo project of a Core Data migration is quite tedious.

By the way, my custom accessors are also called if I used -valueForKey: and -setValue:forKey:.  This is per documentation [1]:

"The access pattern key-value coding uses for managed objects is largely the same as that used for subclasses of NSObject—seevalueForKey:"

and drilling down, [2]:

Default Search Pattern for valueForKey:
When the default implementation of valueForKey: is invoked on a receiver, the following search pattern is used:
• Searches the class of the receiver for an accessor method whose name matches the pattern -get<Key>, -<key>, or -is<Key>, in that order.


[1] http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html#//apple_ref/doc/uid/TP40002154-SW9
[2] http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/SearchImplementation.html#//apple_ref/doc/uid/20000955

_______________________________________________

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

  • Follow-Ups:
    • Re: Core Data: During Migration, should use Primitive Accessors only?
      • From: Quincey Morris <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>)

  • Prev by Date: Re: Core Data: During Migration, should use Primitive Accessors only?
  • 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