When I enable (uncomment) this line of code I get a SIGABRT crash – which is strange, to me, because I have never had this issue before.
cell.textLabel.text = [[annotations objectAtIndex:indexPath.row] title];
The error I get is:
2011-12-28 14:03:00.118 MapWithTableModalView-001[2006:11603] Localized name database is not present
2011-12-28 14:03:01.110 MapWithTableModalView-001[2006:11603] * Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘* -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array’
The project produces no errors or warnings.
The project is based on 2 UIViewControllers that slide on top of each other via a button – ModalViewContoller. When I press the button, the crash happens.
Just adding the code here – it is part of a tutorial, but I still want to get it:-) I know this does not look like an ordinary array, but the data is set like this in the project. Once I figure this out I want to set it in a Plist.
-(void)loadOurAnnotations
{
CLLocationCoordinate2D workingCoordinate;
#pragma mark - Apple Stores
workingCoordinate.latitude = 51.514298;
workingCoordinate.longitude = -73.973034;
iCodeBlogAnnotation *appleStore1 = [[iCodeBlogAnnotation alloc] initWithCoordinate:workingCoordinate];
[appleStore1 setTitle:@"Apple Store 5th Ave."];
[appleStore1 setSubtitle:@"Apple's Flagship Store"];
[appleStore1 setAnnotationType:iCodeBlogAnnotationTypeApple];
[viewController.mapView addAnnotation:appleStore1];
workingCoordinate.latitude = 51.514298;
workingCoordinate.longitude = -0.141949;
iCodeBlogAnnotation *appleStore2 = [[iCodeBlogAnnotation alloc] initWithCoordinate:workingCoordinate];
[appleStore2 setTitle:@"Apple Store St. Regent"];
[appleStore2 setSubtitle:@"London England"];
[appleStore2 setAnnotationType:iCodeBlogAnnotationTypeApple];
[viewController.mapView addAnnotation:appleStore2];
}
If you would like me to post any additional code, I would be happy to, but I am not sure where to look anymore and hence don’t really know which bit to post to be helpful.
-Jeff
Your annotations array is empty (has zero elements).
Looking at your
-loadOurAnnotationsmethod, you never actually seem to set theannotationsarray that you’re reading. Try updating that line to something like below and see if that helps: