iphone - how can i check NSNumber is null? -
nsdictionary *regiondict = (nsdictionary *) region; nsnumber *lat = [regiondict objectforkey:@"lat"]; //[latitude addobject:lat]; nsnumber *lng = [regiondict objectforkey:@"lng"]; //[longitude addobject:lng]; nslog(@"%@%@%@",lat,lng,titles); if(lat == [nsnumber numberwithfloat:0.00] && lng == [nsnumber numberwithfloat:0.00]) { nslog(@"%@%@%@",lat,lng,titles); } else { cllocationcoordinate2d coord; coord.latitude =lat.doublevalue; coord.longitude =lng.doublevalue; mapviewannotation *annotation =[[mapviewannotation alloc]initwithtitle:titles andcoordinate:coord]; [self.mapview addannotation:annotation]; }
if condition not satisfied because of nsnumber not check null value. way can check? tell me possible ways.. checking null.
you can check if object null doing
if ([myobject iskindofclass:[nsnull class]])
but if want check if float boxed in nsnumber
zero, can do
if (lng.floatvalue == 0. && lat.floatvalue == 0)
Comments
Post a Comment