3 ms·
FTA: the concept of “nothing” in Objective-C is kind of a mess, since there’s four different versions of it The article is about nil, not about that. And yes,
by Someone 5y ago
FTA: the concept of “nothing” in Objective-C is kind of a mess, since there’s four different versions of it
The article is about nil, not about that.
And yes, part of it is a kludge.
I think that’s only NSNull, and that, technically, isn’t a language issue, but a library one. As https://nshipster.com/nil/ https://nshipster.com/nil/ (which explains all of this) says:
NSNull is used throughout Foundation and other frameworks to skirt around the limitations of collections like NSArray and NSDictionary not being able to contain nil values. You can think of NSNull as effectively boxing the NULL or nil value so that it can be used in collections.
I think a better implementation would use a private singleton NSNull inside the container as a sentinel, so that users of the class could store nil values.
- dspillett 5y ago> the concept of “nothing” in Objective-C is kind of a mess, since there’s four different versions of it Sounds like Visual Basic of old. We used to refer to the four constants of the apocalypse: null, nothing, missing, and empty.