• 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: [NSObject setValue:forUndefinedKey:] no longer requires explicit KVC notifications?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSObject setValue:forUndefinedKey:] no longer requires explicit KVC notifications?


  • Subject: Re: [NSObject setValue:forUndefinedKey:] no longer requires explicit KVC notifications?
  • From: Gabriele de Simone <email@hidden>
  • Date: Sat, 8 Aug 2009 19:24:32 -0400

On Aug 8, 2009, at 2:37 PM, Keary Suska wrote:

It used to be that if you overrode -[NSObject
setValue:forUndefinedKey:] your own subclass was responsible for
calling -[NSObject will/didChangeValueForKey: so that bindings and
observers would work as expected.

That was fine, since it allowed one to provide different
implementations depending on the key, and to generate (or not) KVC
notifications. It seems that a recent update to Mac OS X (perhaps
10.5.8?) has changed this behavior. It seems that as long as you
override setValue:forUndefinedKey:, KVC-compliant notifications are
automatically generated for the given key.

Can anyone confirm this? This is an "interesting" change to the
Cocoa framework that probably interferes with any class that
overrides [NSObject setValue:forUndefinedKey:].


Calling will/didChange should never have been necessary, and in fact,
the setter sequence should be automatically wrapped with the calls, as
long as automatic notification is on. AFAIK, this has always been the
case and hasn't changed recently. There may be more side effects than
before, but I don't recall.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

The KVC infrastructure did not always generate value-changed notifications for setValue:forUndefinedKey: overrides. Doubting my own sanity (always a good approach, IMO) I searched for, and found some evidence of this in an old discussion:


http://www.cocoabuilder.com/archive/message/cocoa/2006/10/12/172593

When did you start using setValue:forUndefinedKey: in your own code? It's quite possible that Apple changed this behavior a while back (with the 10.5 runtime?) and I wasn't paying enough attention. I doubt too many developers are overriding setValue:forUndefinedKey:, but this change means their code would need some cleaning up.

Thanks,
Gabe

_______________________________________________

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: [NSObject setValue:forUndefinedKey:] no longer requires explicit KVC notifications?
      • From: Ken Thomases <email@hidden>
  • Prev by Date: ***SOLVED*** Re: NSArrayController Managing / Sorting NSManagedObjects
  • Next by Date: [iPhone 3.0] UIImage startAnimating -- how to tell when it's finished?
  • Previous by thread: Re: NSData Questions
  • Next by thread: Re: [NSObject setValue:forUndefinedKey:] no longer requires explicit KVC notifications?
  • Index(es):
    • Date
    • Thread