iphone - How to check null value of object in decision statement for Objective C -
i getting object value server null value when nslog
object.i want identify in if-else
decision statement. how can check because nil have reference unknown object not means null
.and can't compare 0 too.
how can identify value null
, have crash on point.i have tried @try - @catch
block gone in vain.
any suggestion problem.
as others have pointed out, there many kinds of "null" under cocoa/objective c. 1 further thing note [object iskindofclass:[nsnull class]]
pointlessly complex since [nsnull null]
documented singleton can check pointer equality. see topics cocoa: using null
so use :-
if (title == (id)[nsnull null] || title.length == 0 ) title = @"something";
note how can use fact if title nil, title.length return 0/nil/false, ie 0 in case, not have special case it. people new objective c have trouble getting used to, coming form other languages messages/method calls nil crash.
if want in detail difference between nil, nil , null, can check article what difference between nil, nil , null.
Comments
Post a Comment