5 ms·
I don't know Objective-C/Cocoa, but is it when you know the size at compile time? If yes, you can use an array.
by afdbcreid 4y ago
I don't know Objective-C/Cocoa, but is it when you know the size at compile time? If yes, you can use an array.
- astrange 4y ago“At compile time” is too strict; that’s a constant string. And an array isn’t a string, it’s an array. (A string is only a byte array because everything is a byte array.)
- ratmice 4y agoNo it is when you know the size during runtime, or at time of construction. there is a 3rd class for constant strings known at compile time but it is mostly hidden behind @"" compiler syntax.
- astrange 4y agoNS(Mutable)Strings aren’t “classes” but “class clusters”. Making them classes would be an inappropriate mix of interface and implementation. Of course, despite it being a bad idea, almost all other data structure library does do it that way. Constant strings have the same memory layout as other strings more-or-less but have different layouts for ASCII and Unicode, and in memory immutable strings have different backing classes for tagged pointer storage and for UNIX paths.