Is it possible to create an NSCharacterSet constant?
Attempting to do so with the methods for creating an NSCharacterSet
naturally fails to compile with "initializer element is not constant"
I would ideally like to be able to do this.
Is it best just to declare a global constant string, then
initialize an NSCharacterSet during app initialization? It
certainly seems that is the only real option.
Am I missing something?
If I am correct in what I am seeing, would there not be a valid use
case for this as an extension of NSCharacterSet?
You can't create any non-scalar constant (except nil) using a static
However, what you want to do is super-easy, and yes, it's a case for
an extension to NSCharacterSet. Just add a class method as a category:
Wow, you all responded wonderfully and super fast!
I had accidentally sent it to the list hours ago from the wrong email,
so it was naturally rejected, then I just now sent this.
Thanks to everyone, when I get a block of time I'll dive into each
approach and see how they all feel.
Anyway, I digress...
Category, yeah, that's totally one way I thought about, but I was
thinking more of an enhancement request in Radar. I figured the nature
of it inheriting from NSObject implies there are some kind of
optimizations under the hood (otherwise we'd just use NSString and
Seems like a useful one considering the
characterSetWithCharactersInString: method. Even if it were some sort
of singleton class. Particularly useful in input validation routines
(things like highly structured serial numbers and other identifiers,
If there is consensus from multiple people on an enhancement request
and the functionality and justification for it, I'll be happy to file
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden