How to create an "array of selectors" How to create an "array of selectors" ios ios

How to create an "array of selectors"


Could you store strings and use NSSelectorFromString?

From the docs

NSSelectorFromString

Returns the selector with a given name.

SEL NSSelectorFromString (   NSString *aSelectorName);


This creates an object out of selector:

[NSValue valueWithPointer:@selector(x)]


Why not just use a simple C array?

static const SEL selectors[] = {@selector(method1),                                ....                                @selector(method7)};...for (int i = 0; i < sizeof(selectors)/sizeof(selectors[0]); i++) {  [self performSelector:selectors[i]];  // ....}