• 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
Core Data: custom model object accessors vs. KVC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data: custom model object accessors vs. KVC


  • Subject: Core Data: custom model object accessors vs. KVC
  • From: Ryan Homer <email@hidden>
  • Date: Thu, 25 Jan 2007 16:48:33 -0500

According to Core Data Programming Guide -> Using Managed Objects -> Accessing and Modifying Properties:
"To access or modify properties of a managed object, by default you use key-value coding, "...
Ex: NSString *firstName = [newEmployee valueForKey:@"firstName"];


However, when creating a custom managed object according to the Low- Level Core Data Tutorial -> Implementing the Managed Object Subclass - > Implementing the Accessor Methods:
"When you implement custom accessors for a managed object class, you must ensure you invoke the appropriate access and change notification methods."
Ex:
- (NSDate *)date
{
[self willAccessValueForKey:@"date"];
id date = [self primitiveValueForKey:@"date"];
[self didAccessValueForKey:@"date"];


    return date;
}

So, my questions are:

(1) Is it ok to use valueForKey: in the custom class instead of primitiveValueForKey: and therefore not use willAccessValueForKey: and didAccessValueForKey:

(2) What exactly is the difference between them? According to the docs,

primitiveValueForKey:
Returns from the receiver’s private internal storage the value for the specified property.


valueForKey:
Returns the value for the property specified by key.

but I'm still not clear on the difference. If a fetch is returning data from the persistent store into an array, why should I be using primitiveValueForKey and digging into the private internal storage?



Thanks in advance for your replies.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: custom model object accessors vs. KVC
      • From: Jim Correia <email@hidden>
  • Prev by Date: Re: Completely broken XCode
  • Next by Date: Re: Core Data: custom model object accessors vs. KVC
  • Previous by thread: Re: KVO, design and documentaion
  • Next by thread: Re: Core Data: custom model object accessors vs. KVC
  • Index(es):
    • Date
    • Thread