I know how to create a SEL
at compile time using @selector(MyMethodName:)
but what I want to do is create a selector dynamically from an NSString
. Is this even possible?
What I can do:
SEL selector = @selector(doWork:);
[myobj respondsToSelector:selector];
What I want to do: (pseudo code, this obviously doesn't work)
SEL selector = selectorFromString(@"doWork");
[myobj respondsToSelector:selector];
I've been searching the Apple API docs, but haven't found a way that doesn't rely on the compile-time @selector(myTarget:)
syntax.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…