Use of unresolved identifier 'enumerate' after Swift Migration
ios
Solution
Try using the `enumerated()` method instead:
for (index, value) in customAnnotationArray.enumerated()
Hopefully this is what you're looking for...
Problem
I have an array, called customAnnotationsArray, in which I am appending a class (Annotations) to. This class, Annotations, is a subclass of MKAnnotation and NSObject. In my previous Swift version, the code `for (index, value) in enumerate(customAnnotationArray)` worked wonderfully to extract the pin's index. Now, it is saying that there is "Use of unresolved identifier 'enumerate'. Ive researched a ton and cannot find any resources. How do I fix this? ``` //Annotations array (gets populated with annotations on data load) var customAnnotationArray = [Annotations]() //When tapping the MKAnnotationView. func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) { let theAnnotation = view.annotation //ERROR BELOW IN enumerate "Use of unresolved identifier 'enumerate' for (index, value) in enumerate(customAnnotationArray) { if value === theAnnotation { //print("The annotation's array index is \(index)") //Im passing these variables in prepareForSegue to VC markerIndex = index addressSelected = addressArray[index] } } let vc = storyboard.instantiateViewController(withIdentifier: "updateRecordVC") self.navigationController!.pushViewController(vc, animated: true) } //Annotations class if that helps. class Annotations: NSObject, MKAnnotation { let title: String? let locationName: String let coordinate: CLLocationCoordinate2D let pinColor: MKPinAnnotationColor init(title: String, coordinate: CLLocationCoordinate2D, locationName: String, pinColor:MKPinAnnotationColor) { self.title = title self.coordinate = coordinate self.locationName = locationName self.pinColor = pinColor super.init() } var subtitle: String? { return locationName } func currentPinColor(_ currentUser: Double) -> MKPinAnnotationColor? { switch currentUser { case 0: return .green case 1: return .purple default: return .green } } } ```