• 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: Array controllers in code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array controllers in code?


  • Subject: Re: Array controllers in code?
  • From: email@hidden (Laurent Demaret)
  • Date: Thu, 22 Jul 2010 11:55:19 +0200
  • Organization: None

Amy Gibbs <email@hidden> wrote:

> how do
> I reference the Arrays/Array controllers in the code?

>. I've
> added a 'calculate' button, so now I just need to take the 2
> properties from the selected product, do the maths, and set the cost
> property with the result.

Why don't use use bindings of the button ?
If you don't mind buttons then they offers bindings to whatever method
you wish and you can give any number you need of arguments to the method
as long as you can bind to them in your interface.
Your methode does not need to be an IBAction (can be void).

declare and implement something like
- (void)doMathWithCost:(NSNumber)*cost purchase:(NSNumber*)purchase{
        self.cost = cost/purchase;
}
in your XIB open the inspector on bindings you'll find there is "Action
Invocation" with Target and Argument
For the target you bind to the object that will bring to your method
(FileOwner ?) and for keyPath the name of the method with colons
doMathWithCost:purchase:
For the arguments you bind to your arrayController keyPath
selection.cost for the first argument, selection.purchase

That way you don't have to reference your arrayController in code.
_______________________________________________

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

References: 
 >Array controllers in code? (From: Amy Gibbs <email@hidden>)

  • Prev by Date: Re: loading French strings being in English language
  • Next by Date: Re: Array controllers in code?
  • Previous by thread: Array controllers in code?
  • Next by thread: Re: Array controllers in code?
  • Index(es):
    • Date
    • Thread