0

I am using MKMapView in my project with XCode9. My app gets crashed when control comes to line @IBOutlet weak var mapView: MKMapView!. I have tried it programatically but facing the same issue. Its working on iOS 11 simulators but when I am running this on iPhone 5(iOS 10.3.3) it gets crashed. When I delete outlet of mapView then it works fine on device also.

Terminating app due to uncaught exception 'NSRangeException', reason: 
'*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty 
array'
*** First throw call stack:
(0x1cf93b3d 0x1c21b067 0x1cea398b 0x23b1c091 0x23b1b909 0x23b1b0a5 
0x23b1c5b3 0x23b1c5e7 0x23b7afab 0x23b7d2eb 0xf9e453 0xf9ef4f 
0x23b7d279 0x27e65653 0x27e6623f 0x227d06ef 0x227d03a5 0x226960d3 
0x227d06ef 0x227d0647 0x227d03a5 0x22695633 0x22513adf 0x222f2abb 
0x221c5b9b 0x221c5ad9 0x22b14599 0x2292cb33 0x2292c961 0x2292cbd9 
0x221c5d31 0x22279b59 0x22279a4d 0x22278f11 0x222789ad 0x2227858d 
0x2227850d 0x221c3483 0x1fe1bcb7 0x1fe0fd77 0x1fe0fc05 0x1fd9e839 
0x1fdbcfdb 0x1fdbdb2f 0x1cf4f803 0x1cf4da55 0x1cea11cf 0x1cea0fd1 
0x2222ee2d 0x22229a53 0x4bfb0 0x1c68e4eb)
libc++abi.dylib: terminating with uncaught exception of type 
NSException

This is what I am getting on console. Thanks for your suggestion.

class StampViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {

@IBOutlet weak var markLightButton: UIButton!
@IBOutlet weak var markDarkButton: UIButton!
@IBOutlet weak var placesButton: UIButton!
@IBOutlet weak var mapView: MKMapView!

let locationManager = CLLocationManager()

override func viewDidLoad() {
    super.viewDidLoad()
    //    self.locationManager.requestAlwaysAuthorization()
    //    self.locationManager.requestWhenInUseAuthorization()
    //    if CLLocationManager.locationServicesEnabled() {
    //        locationManager.delegate = self
    //        locationManager.desiredAccuracy = 
            kCLLocationAccuracyNearestTenMeters
    //        locationManager.startUpdatingLocation()
    //    }
    //    mapView.delegate = self
}
Pritam Salunkhe
  • 87
  • 1
  • 11

0 Answers0