objective c - How to check if (id) object is null in ios? -


i have made function consume webservices , want check if (id) object null or not. doing here:

-(void)callservice:(nsstring*)request param:(nsstring*) parameters completion:(void (^)(nsarray *list, nserror *error))completionhandler {     [self.manager post:request parameters:parameters success:^(nsurlsessiondatatask *task, id responseobject) {          nslog(@"response object: %@", responseobject);          if (![responseobject iskindofclass:[nsnull class]]) {              [self methodusingjsonfromsuccessblock:responseobject];              if (completionhandler) {                 //nslog(@"%@", list);                 completionhandler(list,nil);             }         }         else {             nslog(@"nothing found");         }     }failure:^(nsurlsessiondatatask *task, nserror *error) {          //nslog(@"error: %@", [error description]);         if (completionhandler) {             completionhandler(nil,error);         }     }]; } 

but have found on break points when (id) null has nszerodata no nsnull passes condition. using afnetworking

heres details of response object:

thanks in advance helping me out.

your responseobject not nsnull, nsdata (which _nszerodata subclass of).

so want condition:

if ([responseobject iskindofclass:[nsdata class]] && ((nsdata *)responseobject).length > 0) {     // ... } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -