• 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
Interrogating selectors at runtime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Interrogating selectors at runtime


  • Subject: Interrogating selectors at runtime
  • From: Andrew White <email@hidden>
  • Date: Mon, 06 Feb 2006 10:58:21 +1100


Given a data entry of type SEL, is there an easy way to find out how many arguments it expects at runtime?


Obviously, I can go NSStringFromSelector (aSelector) and then count the number of ':' characters, but that's expensive and clunky. Is there a better way?


A related question: what happens if I call 'performSelector:withObject' on a selector that takes no arguments, or 'performSelector:withObject:withObject' on a selector that takes only one? Are the surplus arguments harmlessly discarded?


eg:

SEL aSelector = @selector (myMethod:)

[aClassInstance performSelector: aSelector
	withObject: anObject
	withObject: anotherObject
];

Will this harmlessly perform [aClassInstance myMethod: anObject] or will errors result?


Thanks

--
Andrew White

--------------------------------------------------------------------------
This email and any attachments may be confidential. They may contain legally
privileged information or copyright material. You should not read, copy,
use or disclose them without authorisation. If you are not an intended
recipient, please contact us at once by return email and then delete both
messages. We do not accept liability in connection with computer virus,
data corruption, delay, interruption, unauthorised access or unauthorised
amendment. This notice should not be removed.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Interrogating selectors at runtime
      • From: Greg Herlihy <email@hidden>
  • Prev by Date: Remove indicatorImage from table column
  • Next by Date: Re: ScreenSaverEngine loading wrong view!
  • Previous by thread: Re: Remove indicatorImage from table column
  • Next by thread: Re: Interrogating selectors at runtime
  • Index(es):
    • Date
    • Thread