Re: Abstracting a group of commonly named Selectors


Sandor Szatmari
 

Jeff,

On Jul 22, 2020, at 17:44, Jeff Laing <jefflaing@...> wrote:



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.

Couldn’t agree more…

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.

There is no need to optimize for performance here…  higher level Obj-c interfaces are preferable.

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.

Yes, lots of efficiencies can be made.  Unfortunately, it’s just not a necessity for us.

Thanks,
Sandor

Good luck with it.

Join cocoa@apple-dev.groups.io to automatically receive all group messages.