Re: Abstracting a group of commonly named Selectors

Alex Zavatone

Well, I’m guessing here, but can’t you construct the method and use a perform selector, get the result and return it?

It seems like you are making methods, performing them, then need to perform methods within that, right? Can’t you simplify that? Or somehow define what becomes parsed in the method?

It seems like this can be simplified.

On Jul 20, 2020, at 2:47 PM, Sandor Szatmari <> wrote:


Thanks for the idea. I not sure how that helps me get the return value back to the original caller. Am I missing your point?

Here’s more details, in pseudo code

// Controller class
SEL aSel

aSel = lookUpSel (i.e. parseXYZ)
NSInvocation *n = // make invocation with aSel
[n setTarget: ModelClass]
[n invoke]
Status s = success // I’m an optimist
[n getReturnValue:&s]

while more_sels

… Meanwhile…

// ModelClass
// do the same thing for each parse method
return [self parse:XYZ]

// do the same thing for each parse method
return [self parse:RST]


I want to change model class to do this
// remove parse SELs i.e. remove parse[A-Z]{3} methods

// replace with something like
NSString *sel = NSStringFromSelector(aSel)

if ( sel has prefix ‘parse’ )
NSString *selCmd = [sel subStringFromIndex:5] // remove prefix ‘parse’. e.g. ‘RST’ remains
Status s = [self parse:selCmd]

// how do I return ‘s’ to the original caller??? The Controller

[super doesNotRespondToSelector:aSel]


On Jul 20, 2020, at 13:27, Alex Zavatone via <> wrote:

Would it be possible to put them in an array or dictionary as NSStrings and use performSelector on one of them if it is present within the array or dict?

On Jul 20, 2020, at 12:11 PM, Sandor Szatmari <> wrote:

I have a certain group of selectors that all follow a strict naming convention,


All have one line that does the same thing and return a scalar (enum) as a result.
Each method would do something XYZ or RST and return their status

There are about 200 of these… it’s quite annoying to maintain and look at this boiler plate interface. It should not be necessary, I hope.

I would like to abstract them using something like:
By some other means, which I cannot conceive of…

The issue I don’t understand is, how would I return the scalar to the original caller once one of the methods has received the program flow. Neither of these methods return anything.

Is what I want to do possible?
If so, what should I be looking at?


Join to automatically receive all group messages.