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

Re: about @selector


  • Subject: Re: about @selector
  • From: Ondra Cada <email@hidden>
  • Date: Sat, 11 May 2002 00:48:26 +0200

On Friday, May 10, 2002, at 12:08 , nicolas berloquin wrote:

there is something I understood with aaron's book, and that's quite different from c++: you can call
methods dynamically. That is, you could have the user enter a string, say "mymethod:", then get this
string, and call the function by creating a selector with the string @selector(mystring) (or something close
to that).

Well, close:

[obj performSelector:NSSelectorFromString(theString) ...];

The @selector is a compiler directive, ie. a compile-time (actually link-time) constant. Therefore, it can't be used over dynamic string.

That's very efficient and cool when you want to have dynamic plugins etc etc, something more difficult
to do in c++...

Actually it is plain impossible in C++. You can rig up tricks to go close,
but the more flexibility you get, the less C++ the result is. As soon as you get the full ObjC-like flexibility, you have just implemented an ObjC runtime in C++ ;)))
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
2K Development: email@hidden http://www.2kdevelopment.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >Re: about @selector (From: nicolas berloquin <email@hidden>)

  • Prev by Date: Re: Datagram Socket Reading?
  • Next by Date: [OT] ?
  • Previous by thread: Re: about @selector
  • Next by thread: CocoaDevCentral Sheets Tutorial
  • Index(es):
    • Date
    • Thread