Re: wasting space?
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