I have a String
property as part of a custom object. When I try to access the String
on the custom object (when it's Null), the program crashes.
I can tell that the string is of type NSNull
by printing out the custom object.
Every time I try
if theString == nil
if theString == NSNull()
if theString.isEmpty
the program crashes with [NSNull length]: unrecognized selector sent to instance
What I don't understand is where it's trying to call length
. I would imagine it only calls length
on the isEmpty
function, but it crashes on the other two conditionals as well.
I'm thinking it could be because the custom object is created in objective-c with an NSString
, but this also crashes when I try to convert the String
to an NSString
, so I'm not sure how to go about it.
Thanks!