• 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: Getting access to the name of a button?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting access to the name of a button?


  • Subject: Re: Getting access to the name of a button?
  • From: apparao <email@hidden>
  • Date: Fri, 14 Sep 2007 16:09:51 +0530

NSButton uses NSButtonCell to implement its user interface.

- (NSString *)stringValue  -- Returns the button value as a string

To get Button A, you have to use - (NSString *)title method.


On 14-Sep-07, at 3:58 PM, Frank Bettger wrote:

I've created a very simple application with just one button called "Button
A" and I connected it to the action "myLog:" inside the AppController (I
created the AppController by sub classing NSObject and I added the action
myLog: using the IB. I then instantiated AppController and Control- dragged
from the button to the AppController instance).
The AppController has just one method that looks like this.


- (IBAction)myLog:(id)sender
{
    //NSLog(@"myLog activated");
    NSString *myString=[sender stringValue];
    NSLog(@"%@", myString);
}

When I run it and click repeatably on the button "Button A" this is what I
get in the log window


[Session started at 2007-09-14 12:19:23 +0200.]
2007-09-14 12:19:29.660 Logger[482] 1
2007-09-14 12:19:30.676 Logger[482] 0
2007-09-14 12:19:31.708 Logger[482] 1
2007-09-14 12:19:32.291 Logger[482] 0

I was hoping that [sender stringValue] would return the name of the button,
that is "Button A", but it gives alternating 1s and 0s. What's the
explanation?


Thanks Frank
_______________________________________________

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:
40effigent.net


This email sent to email@hidden


_______________________________________________

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: 
 >Getting access to the name of a button? (From: "Frank Bettger" <email@hidden>)

  • Prev by Date: Getting access to the name of a button?
  • Next by Date: Singletons and Threads
  • Previous by thread: Getting access to the name of a button?
  • Next by thread: Singletons and Threads
  • Index(es):
    • Date
    • Thread