What is the set of valid characters for an Objective-C class?
Of course the basic naming conventions of letters, numbers and underscore all work, but I'm looking for a special character to avoid naming conflicts.
The $ symbol seems to work, but I could not find any documentation. The language reference does not mention it.
Any other? Any "official" document I can refer to?
Historically, Objective-C compiler has been based on GNU C compiler, which allowed dollar signs in identifiers as an extension. As far as I know, this is the only exception to the rule of naming identifiers with sequences of letters, digits, and underscores that do not start in a digit.
Since Apple switched to a different toolchain for their compilers, it appears that the dollar sign is kept for backward compatibility. I would avoid using it in my new code, especially since Apple is not advertising it as a feature.
At compile time, the set of characters is whatever the C/C++ compiler accepts as an identifier.
At runtime, anything UTF-8 goes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With