• 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
performSelector: question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

performSelector: question


  • Subject: performSelector: question
  • From: Bruce Truax <email@hidden>
  • Date: Tue, 27 Jul 2004 11:34:48 -0400

I am writing a parser for test input strings. Each string starts with a
keyword and is followed by 0 or more text or numeric arguments. I thought a
nice way to handle the processing of each string would be to create methods
with the same names as each keyword. I would then extract the keyword from
the string and call the method with that name passing the rest of the string
as an argument. The NSObject documentation describes the performSelector:
withObject method which would appear to do the job. The documentation
describes two ways to call this method:


id myClone = [anObject performSelector:@selector(copy)];

id myClone = [anObject performSelector:sel_getUid("copy")];

It would appear that the second method would work if I extracted the keyword
as follows:

id myClone = [anObject performSelector:sel_getUid([keywordString cString])
withObject:[restOfString]];

Is this the proper way to call a method using a string name?

Bruce
_______________________________________________
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.


  • Follow-Ups:
    • Re: performSelector: question
      • From: Marco Scheurer <email@hidden>
    • Re: performSelector: question
      • From: "John C. Warner" <email@hidden>
    • Re: performSelector: question
      • From: Stéphane Sudre <email@hidden>
  • Prev by Date: Re: Simplifying this code?
  • Next by Date: Re: performSelector: question
  • Previous by thread: Re: Dealloc is never being called and application crashes
  • Next by thread: Re: performSelector: question
  • Index(es):
    • Date
    • Thread