• 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: wasting space?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wasting space?


  • Subject: Re: wasting space?
  • From: Erik Buck <email@hidden>
  • Date: Mon, 6 Oct 2008 13:22:40 -0700 (PDT)

I am no fan of KVO or bindings, but I disagree with Mike Ash on his analysis.
 
If you are even tempted to override - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context, you have missed the whole point of KVO IMHO.
 
Let the built in framework code parse the key paths.  You should forget that key paths even exist.
 
When someone calls float currentElevation = [someObject valueForKeyPath:@"document.currentTerrain.selectedObject.elevation"],  that is conceptually identical to the following:
 
currentElevation = [[[[someObject document] currentTerrain] selectedObject] elevation];
 
In fact, the framework will call -document, -currentTerrain, -selectedObject, and -elevation for you if you let it.  Just make sure someObject has a -document method, and your document object has a currentTerrain method, and your terrain object has a -selectedObject method and selected objects have an -elevation method, and you are good to go!
 
If you ever find yourself writing switch statements based on the return value of a method you are doing something very wrong.  If you have nested if statements comparing strings, you are doing something wrong.
 
 
_______________________________________________

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: wasting space?
      • From: "Shawn Erickson" <email@hidden>
    • Re: wasting space?
      • From: "Michael Ash" <email@hidden>
    • Re: wasting space?
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: Cocoa Programming for Mac OsX Third Edition eBook search
  • Next by Date: Re: wasting space?
  • Previous by thread: Re: wasting space?
  • Next by thread: Re: wasting space?
  • Index(es):
    • Date
    • Thread