Reputation: 4406
what is the maximum length of a class name in objective-c
? I could not find any hints in the xcode doc-sets and google was no help either.
I am currently writing some runtime helpers, and it would be nice to know if my char-buffers for the type-encoding are big enough.
Upvotes: 4
Views: 1744
Reputation: 400
Since Objective C is not a standardized programming language this question can't really be answered. But it rather depends on what your compiler supports. I guess the major Objective C compilers (Clang/LLVM, GCC) support all lengths of class names. To find out you would have to have a look at their sources. But since they are both written in C++ they will probably utilize std:string and be therefore length independent.
I gave it a try and tried to compile a project with a 100.000 character class name using clang/llvm in Xcode, which worked perfectly fine.
So your buffers are likely not to be big enough.
Upvotes: 3
Reputation: 19030
I don't believe there is a hard limit to the class name size, why would there be?
With Obj-C being run on top of C, it would follow their standards. Identifiers in C do not have a maximum length, as identified in the question "Max identifier length"
It is very unlikely for you to come across a class name greater than 100 characters, but you could always have bigger buffers to be safer.
Upvotes: 2