Re: Setting action: with a variable
Re: Setting action: with a variable
- Subject: Re: Setting action: with a variable
- From: Mike Fischer <email@hidden>
- Date: Tue, 27 May 2008 19:42:44 +0200
Am 27.05.2008 um 18:19 schrieb Mark Manes <email@hidden>:
What I would like to do is set the action for NSButton
programmatically where the selector is a variable.
I can't seem to find an example.
[aButton addTarget:self action:variable ....]
NSButton does not respond to any message starting with
addTarget:action:, so this must be your own method? If so what does
its implementation look like and what do expect it to do?
If I define 'variable' to be NSString it is happy but at run time I
get an error stating that the target selector is Null. I can assure
you that variable exists and has a value of 'buttonAction:'.
As the error indicates it wants a "target selector". Selectors have
the type SEL. They are not strings. You could try creating a selector
from a string using NSSelectorFromString() or sel_registerName() or
you could predefine the selectors you need using SEL a = @selector
("xyz:"), b = @selector("abc:"); and so on. But I'm not sure what you
really want to achieve and whether one of these options would be a
good solution to your problem.
I of course have buttonAction defined as follows:
- (void) buttonActon:(id)sender
What am I doing wrong?
You don't seem to understand what selectors are. Maybe (re)read
<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/
Articles/chapter_8_section_3.html> ?
HTH
Mike
--
Mike Fischer Softwareentwicklung, EDV-Beratung
Schulung, Vertrieb
Note: I read this list in digest mode!
Send me a private copy for faster responses.
_______________________________________________
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