2

In my viewcontroller, I create a MKMapView object. I set the delegate to self, and in the ViewController, I implemented:

- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error 

This method gets called, but in the debugger, I see that error has the value 0x0

This happens on the device, and in the simulator.

I need the error code, as I want to give a message for the case where internet access is unavailable, while ignoring the cases like (from the API doc) "if a request for additional map tiles comes in while a previous request for tiles is still pending" (which doesn't seem like a failure to me)

Alan
  • 2,140
  • 1
  • 24
  • 30
  • so in the particular case it's failing, do you know why? (i.e. are you testing with the internet turned off?) do you always get a nil error code, or only sometimes? – David Maymudes Dec 07 '09 at 05:21
  • Three cases where mapViewDidFailLoadingMap gets called: 1) internet turned off 2) user checks that app can not use location 3) internet turned on, but then reapidly scroll (which I assume is the "request for additional map tiles..." All cases give the nil error. – Alan Dec 07 '09 at 21:01

1 Answers1

2

I just did some testing.

  1. Internet is off: [error description] = Error Domain=NSURLErrorDomain Code=-1009 UserInfo=0x46c6120 "no Internet connection"
  2. Scrolling around too quickly: error = nil (0x0)

I don't know if there are any other error conditions, but at least you can discriminate between an internet conneciton error (in which case I will display an alert) and the scrolling too quickly case, in which I'll just ignore it.

Simon Woodside
  • 7,175
  • 5
  • 50
  • 66