Re: Abstracting a group of commonly named Selectors

Jeff Laing

This capability of Objective-C, to create classes on the fly, is one of the primo reasons why I can't understand people's fascination with Swift. Even C# can do this sort of thing, but people these days seem to be terrified of taking complete control.

Personally, I would be avoiding turning something into an NSString until the last minute. You could strcmp() the selector name against your fail pattern and just create your string from "selName+offset" rather than the more expensive substringFromIndex. Not quite sure why you need to change the case of the table but that's your grammar, I guess.

Nevertheless, don't waste time optimising till it's a known performance hit.

If this were being called millions of times, I would be building a static CFDictionary(), keyed by _cmd values I had previously encountered and storing their corresponding "snakeCased substrings" so that I only did that construction once. Or I would be asking myself "could stepDictForTableName: take a char* instead of an NSString*, etc. Again, CFDictionary is so much better than NSDictionary in that space. But that's me, I hate wasting cycles.

Good luck with it.

Join { to automatically receive all group messages.