Iphone 仅在显示注释时滚动地图时使应用程序崩溃
当我滚动地图并显示一个或多个注释时,我的应用程序崩溃。没有显示注释,地图工作正常 现在我不明白这里有什么问题。请帮帮我 下面是我用来显示所有注释的代码Iphone 仅在显示注释时滚动地图时使应用程序崩溃,iphone,objective-c,mapkit,Iphone,Objective C,Mapkit,当我滚动地图并显示一个或多个注释时,我的应用程序崩溃。没有显示注释,地图工作正常 现在我不明白这里有什么问题。请帮帮我 下面是我用来显示所有注释的代码 -(void)displayAllAnnotation { NSLog(@"%d",[reminderTitle count]); for (int i=0 ; i<[reminderTitle count]; i++) { double templati=[[reminderLatitude
-(void)displayAllAnnotation
{
NSLog(@"%d",[reminderTitle count]);
for (int i=0 ; i<[reminderTitle count]; i++)
{
double templati=[[reminderLatitude objectAtIndex:i]doubleValue];
double templongi=[[reminderLongitude objectAtIndex:i]doubleValue];
CLLocationCoordinate2D coord;
coord.latitude=(CLLocationDegrees)templati;
coord.longitude=(CLLocationDegrees)templongi;
DDAnnotation *ann = [[[DDAnnotation alloc] initWithCoordinate:coord addressDictionary:nil] autorelease];
ann.title = [reminderTitle objectAtIndex:i];
[self.mapView addAnnotation:ann];
[ann release];
}
}
-(无效)显示说明
{
NSLog(@“%d”,[提醒次数];
对于(int i=0;i您释放了两次ann对象,因此您的应用程序正在崩溃。
删除自动释放。只需这样写:
DDAnnotation *ann = [[DDAnnotation alloc] initWithCoordinate:coord addressDictionary:nil];
当滚动4到5次出现错误时,放置断点并查看应用程序崩溃的位置,并向我们显示崩溃日志。由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[\uu NSCFString坐标]:未识别的选择器发送到实例0x78456c0'