• 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: rules for custom managed object setter implementations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data: rules for custom managed object setter implementations


  • Subject: Core Data: rules for custom managed object setter implementations
  • From: "Sean McBride" <email@hidden>
  • Date: Fri, 20 Nov 2009 11:32:10 -0500
  • Organization: Rogue Research Inc.

Hi all,

If I implement a custom setter for an NSManagedObject attribute, what
can/can't I do?

For example, can I do nothing if the old and new values are the same?

- (void)setSalary:(NSNumber*)newsalary
{
    get current salary
    compare with newsalary
    if different
        [self willChangeValueForKey:@"salary"];
        [self setPrimitiveValue:newsalary forKey:@"salary"];
        [self didChangeValueForKey:@"salary"];
}

Or is it required to _always_ call willChange/setPrimitive/didChange?

Most of the time I use CD's dynamically generated accessors, but
occasionally I implement custom ones.  I couldn't find a general
discussion of what can and can't be done safely in much methods.

Thanks,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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: rules for custom managed object setter implementations
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: tableView:setObjectValue:forTableColumn:row: not called when button pressed
  • Next by Date: Re: How to avoid the movie distortion ?
  • Previous by thread: Re: extracting the mantissa for a NSDecimal
  • Next by thread: Re: Core Data: rules for custom managed object setter implementations
  • Index(es):
    • Date
    • Thread