0

I have a map that helps a friends find each other. The number of friends are too high and scattered around the map. I want to only load the friends from my api that pertain to the current view the user sees. If the user swipes, different set of users are displayed. Looking at the MKMapViewDelegate events, the only place suitable for what I want to do is:

optional func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool)

but according to documentation, I shouldn't be adding complex code to it:

Discussion This method is called whenever the currently displayed map region changes. During scrolling, this method may be called many times to report updates to the map position. Therefore, your implementation of this method should be as lightweight as possible to avoid affecting scrolling performance.

I've looked at the other events, no other events will give me what I want. Which other MKMapViewDelgate event do you think I should utilize!?

user1019042
  • 2,428
  • 9
  • 43
  • 85
  • 1
    I'm using this function, and i realize that this function will be called when your map end dragging. You can check it, very easy. – Tien Apr 20 '16 at 18:44
  • @Tien I'm already using it and its getting large. The documentation note is alarming against overloading its logic. I was wondering if I shouldn't use this, then which event should I use? – user1019042 Apr 20 '16 at 19:33

1 Answers1

0

Now I know quite a bit about it. The answer is simply: No, there isn't! Sometimes there is no escape from adding more logic to that event. I had to do some workarounds by laying out switches to prevent it from further processing or allowing through.

user1019042
  • 2,428
  • 9
  • 43
  • 85