iphone - [NSNull getCharacters:]:

2019-09-03 07:19发布

问题:

I got the above in an error message.

[NSNull getCharacters:]:

I cannot find it in the documentation. Can someone explain to me what it means?

Many thanks.

Edit: This is a different one than the question than the one linked to which is about the use of NSNull getCharacters. This one just asks what it means.

回答1:

Straight from Apple documentation: "The NSNull class defines a singleton object used to represent null values in collection objects (which don’t allow nil values)."

From here on, it's pure speculation, as you've shown no code and no error message. If you push an object into a collection without checking it is not null, you'll be pushing NSNull. Then, if you have some kind of error or debugging, NSNull will call a private API getCharacters (which I'm guessing is private as there's no documentation). I suspect it is the equivalent of Java's toString() and is called when an error message is outputted.



标签: ios nsnull