ios - Find Argument Class / Type From Selector Variable - Objective-C -
i'm working on class involves sending selector variable used later. selector required take 1 argument, bool value. executed so:
imp imp = [ob methodforselector:selector]; void (*func)(id, sel, bool) = (void *)imp; func(ob, selector, yes);
if tries set selector variable doesn't match bool, i'd return error. there way, when receiving selector can check whether or not argument bool, or in general, class or type of argument has been passed?
why?
i'm setting quasi notification center in 1 of classes can add observers , have more control on information distribution.
look @ method signature:
nsmethodsignature * sig = [ob methodsignatureforselector:selector]; nsassert(0 == strcmp(@encode(bool), [sig getargumenttypeatindex:2]), @"method must take bool sole argument.");
Comments
Post a Comment