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 is not satisfied because of NSNumber not check with null value. what is the way i can check? Tell me possible ways.. for checking null.
You can check if an object is null by doing
if ([myObject isKindOfClass:[NSNull class]])
But if you want to check if a float boxed in a NSNumber
is zero, you can do
if (lng.floatValue == 0. && lat.floatValue == 0)