Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HELP: with UIButton actions (new to objective c and iphone dev)



On 07.04.2008, at 14:10, Matthew Pearson wrote:
The problem:
How do I pass arguments ( ie the button number 0-9, or in future pi (3.142) ) to a method using the addTarget: action: syntax

You don't. The single argument of an action is always the sender (sending object, eg the NSButton).


Don't know how it works on the iPhone (I guess the same), but on Cocoa you would distinguish the pressed buttons using a tag (NSControl - setTag:/-tag).

  [button setTag:0];
  [button setTag:1];
  [button setTag:2];

- (void)digitButtonPressed:(id)_sender {
  NSLog(@"the user pressed: %i", [(BSControl *)_sender tag]);
}

Target/Action:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_5.html

Helge
--
Helge Hess
http://www.helgehess.eu/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/objc-language/email@hidden

This email sent to email@hidden
References: 
 >HELP: with UIButton actions (new to objective c and iphone dev) (From: Matthew Pearson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.