• 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: Difference between SEL and const char* when sending a message?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difference between SEL and const char* when sending a message?


  • Subject: Re: Difference between SEL and const char* when sending a message?
  • From: Mark Ritchie <email@hidden>
  • Date: Wed, 08 Apr 2009 03:17:40 -0400

On 7-Apr-09, at 11:34 PM, Daqi Pei wrote:
[myObj performSelector: (SEL)"someMethod"];

Oh, don't do that! ;-)

If you know the selector at compile time, you should use @selector() for compile time checking.
Otherwise you should use the sel_getName() function to do the lookup at runtime.


"You can not simply cast a C string to SEL." is from:
http://developer.apple.com/documentation/Cocoa/Reference/ObjCRuntimeRef/ObjCRuntimeRef.pdf

Note that while it's be convenient to cast SEL to char *, especially when debugging in gdb, there's no guarantee it will be that way in the future.

Regards,
Mark
__
Mark Ritchie
Cocoa and WebObjects Developer
Diamond Lake Consulting Inc.
Toronto, Ontario, Canada



_______________________________________________

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: Difference between SEL and const char* when sending a message?
      • From: Sherm Pendley <email@hidden>
References: 
 >Difference between SEL and const char* when sending a message? (From: Daqi Pei <email@hidden>)

  • Prev by Date: Re: Fully transparent window opaque to mouse?
  • Next by Date: Re: Difference between SEL and const char* when sending a message?
  • Previous by thread: Re: Difference between SEL and const char* when sending a message?
  • Next by thread: Re: Difference between SEL and const char* when sending a message?
  • Index(es):
    • Date
    • Thread