Re: How to use "SEL"
Re: How to use "SEL"
- Subject: Re: How to use "SEL"
- From: Tomas Zahradnicky <email@hidden>
- Date: Wed, 9 Oct 2002 08:12:57 +0200
I'm trying to write a general purpose loop method for one of my
classes that takes as one of its parameters the selector of another
method defined in the same class. Could someone fill in the blanks
in the following snippet?
// Is this the right way to get a selector for a hypothetical "doFoo" method?
SEL theMethodSelector = [self selector:@selector( doFoo: )];
// and once I have the "SEL", I'd like to use it as follows
- (id) newWidget:(SEL) inSelector
{
// to actually use the selector what do I do?
[self performSelector:inSelector];
}
Hello Ken,
the message you're looking for is performSelector. Send this
message to self to call a given SEL (doFoo:) in your case. The
performSelector:, performSelector:withObject: and
performSelector:withObject:withObject: are all defined in NSObject
itself.
-Tomas
--
# Tomas Zahradnicky, Jr
# The Czech Technical University
# Dept of Computer Science, FEE-CTU Prague
_______________________________________________
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.