i have a problem with that exception, actually, when i click on the calloutAccessoryControlTapped button of the pin i got this exception, i try to track the error by the NSLog in the console and i found the only pin which caused this exception have the value <null>, i explain by some code :
for (int i=0; i<[array count]; i++) {
NSDictionary *stationEnCours=[array objectAtIndex:i];
location2D = (CLLocationCoordinate2D){ .latitude = lat, .longitude = lng };
MyLocation *annotation=[[[MyLocation alloc]initWithName:ensStation distanceVersLaStation:distance coordinate:location2D]autorelease];
//here we set the properties before we get call to addAnnotation annotation.stationAdress=[stationEnCours objectForKey:@"ssiphone_adresse"];
NSLog(@"%@",annotation.stationAdress);
[mapView addAnnotation:annotation];
}
i have 4 stations, in the console i got this :
2011-05-11 22:27:11.768 TopStation[2370:207] A 51 - Aire de la Champouse
2011-05-11 22:27:11.769 TopStation[2370:207] <null>
2011-05-11 22:27:11.769 TopStation[2370:207] 467 Avenue Henri Mauriat
2011-05-11 22:27:11.769 TopStation[2370:207] Route de Berre - Jas de Bouffan
the second one is which cause problem later when i try to click on its calloutAccessoryControlTapped so i checked my database and its adress is a string and it’s not null.
i am little confused, why that exception although all is retrieved as String ?? i have also tried to do the same work but on the server side and all is ok, it’s not displaying me NULL, only in the iPhone side and for this station.
If this help, the adress of the station which make problem is :
1 Boulevard du Maréchal Juin
At some point in your code, you are either calling
isEqualToString:on an object that you think is an NSString but is really NSNull, or (more likely) you are passing an NSNull to a method/property of a class somewhere that expects a NSString. For example, you might be setting a UILabel’stextproperty with the value ofannotation.stationAdress.You should generally only use NSNull where you cannot use
nil, e.g. in an NSArray, NSDictionary, or the like. After extracting the possibly-NSNull value from the collection, you should include a statement like this to convert it back to nil: