• 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: Using @selector()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using @selector()


  • Subject: Re: Using @selector()
  • From: "Christian Giordano" <email@hidden>
  • Date: Sat, 9 Aug 2008 10:23:35 +0100

yep, it works with that :)
I presume it is an error in the book. Personally I thought that
passing the method not as string it would have recognized the scope
(target) automatically.

Thanks a lot, chr


On Sat, Aug 9, 2008 at 9:45 AM, Jean-Daniel Dupas
<email@hidden> wrote:
>
> Le 9 août 08 à 10:34, Christian Giordano a écrit :
>
>> Hi guys, I'm a newbie and I'm reading a book which shows the two
>> different option to link programmatically a control to an action:
>>
>> SEL mySelector;
>> mySelector = @selector(methodName:);
>> [myButton setAction:mySelector];
>>
>> OR
>>
>> SEL mySelector;
>> mySelector = NSSelectorFromString(@"methodName:");
>> [myButton setTarget:someObjectWithTheMethod];
>> [myButton setAction:mySelector];
>>
>> On my test, the first syntax doesn't seem to work. This is my
>> implementation.
>>
>> - (void)awakeFromNib
>> {
>>        NSLog(@"awakeFromNib");
>>       SEL mySelector;
>>        mySelector = @selector(sayIt:);
>>        [sayItButton setAction:mySelector];
>> }
>>
>> If I do the other syntax:
>>
>> - (void)awakeFromNib
>> {
>>        NSLog(@"awakeFromNib");
>>       SEL mySelector;
>>        mySelector = NSSelectorFromString(@"sayIt:");
>>        [sayItButton setTarget:self];
>>        [sayItButton setAction:mySelector];
>> }
>>
>> Works. The sayIt method is in the same class than the awakeFromNib of
>> course. Any ideas?
>>
>
> Why you do not set the target in the first method ?
>
>
>
_______________________________________________

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: Using @selector()
      • From: Negm-Awad Amin <email@hidden>
    • Re: Using @selector()
      • From: Uli Kusterer <email@hidden>
References: 
 >Using @selector() (From: "Christian Giordano" <email@hidden>)
 >Re: Using @selector() (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Problem with friend function and gcc 4.2 with objective-c++
  • Next by Date: Re: Using @selector()
  • Previous by thread: Re: Using @selector()
  • Next by thread: Re: Using @selector()
  • Index(es):
    • Date
    • Thread