4 ms·
How about "interning" strings [1]? This is also useful for storing larger strings. [1] https://en.wikipedia.org/wiki/String_interning https://en.wikipedia.org/
by amelius 11y ago
How about "interning" strings [1]? This is also useful for storing larger strings.
[1] https://en.wikipedia.org/wiki/String_interning https://en.wikipedia.org/wiki/String_interning
- chc 11y agoConstant strings have always been interned. I don't think any others are, though I haven't looked into it in a while.
- mikeash 11y agoIt's not NSString, but it's interesting to note that Objective-C selectors are just interned strings. By interning them, they can be compared with a simple pointer comparison. Because they're just C strings, you can print a selector by casting it to char *. (But don't do this in production code, debugging only!)