• 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: Calculations in a tableview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calculations in a tableview


  • Subject: Re: Calculations in a tableview
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 28 Jul 2011 20:15:14 -0700

On Jul 28, 2011, at 20:00, Andre Masse wrote:

> Is this can be done using bindings or should I stop fighting the framework and and use a datasource?

It can be done with bindings***. All you've done is clarified that "totalPrice" isn't a derived property after all. So, you make a regular property (with getter and setter), and initialize the instance variable that backs it to the default value (items * price).

Or, you can initialize the instance variable to a "not set" value (like 0 or NSNotFound, or something), but then you won't be able to just @synthesize the property -- you'll have to write code to return either the default or the explicit value, depending on the contents of the instance variable. (Or, you can have a BOOL instance variable that says whether the default has been overridden, but in that case you'll have to add code to the setter instead.)

And, incidentally, what you are trying to do is in no way "fighting" the framework. You're doing exactly what you're supposed to be doing. :)




*** Again, focus your thinking on *properties*. Ask yourself what properties your data model needs to support the user interaction, and it should become immediately clear what to do. Bindings are a way of hooking up (in this case) your UI to your data model's properties. They don't replace the data model design part of the process.


_______________________________________________

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: Calculations in a tableview
      • From: Andre Masse <email@hidden>
References: 
 >Calculations in a tableview (From: Andre Masse <email@hidden>)
 >Re: Calculations in a tableview (From: Quincey Morris <email@hidden>)
 >Re: Calculations in a tableview (From: Andre Masse <email@hidden>)

  • Prev by Date: Re: Calculations in a tableview
  • Next by Date: didReceivePTPEvent is not triggered with Canon T2i
  • Previous by thread: Re: Calculations in a tableview
  • Next by thread: Re: Calculations in a tableview
  • Index(es):
    • Date
    • Thread