Bronze Challenge - Assertion error


#1

I attempted to implement the Bronze Challenge this way:

// Only get updates if location changed more than 50 meters [locationManager allowDeferredLocationUpdatesUntilTraveled:50 timeout:CLTimeIntervalMax];
The target builds with no errors; however, when I run the target, I get this exception:

Any thoughts? Thanks.


#2

You should check the Apple Documentation for which method you should call.

Go there and search for: CLLocationManager - then look at it’s properties - one of them is: distanceFilter. Having a read of that - we should be able to implement the code needed.

Change your implementation to:

Run your app in the simulator and when you simulate another country it will update.
What I did to make sure it’s working was first set the distance filter to like 500000 meters and then simulated moving between two countries that were closer than that together - I got no update (As expected)
I then changed it back to 50 meters and did the above, again - updates were coming in now (As expected)


#3

Thank you, Tander. I did read the API doc and eventually implemented the solution using the setDistanceFilter property.

I still wonder why the assertion exception was thrown in the former case.


#4

[quote=“wagill”]Thank you, Tander. I did read the API doc and eventually implemented the solution using the setDistanceFilter property.

I still wonder why the assertion exception was thrown in the former case.[/quote]

Not sure why that happened. Hopefully someone can explain to us new comers. :smiley: