Re: Difference between SEL and const char* when sending a message?
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