Well, it may be a little long, but it worked for me, and I really hope it helps you. This is from an application that is used to exchange various traffic status reports between drivers.
I also had this problem, I tried to download annotations from the server, and then delete them and reload the annotation array to the card every time the user sends the annotation to the server himself / clicks the "Update" button / every 1.5 minutes so that he always had the current set.
So I thought that this might have something to do with the time interval that is required to download new annotations from the server or with the array itself, later I realized that it could also be related to how all the code was organized and that, perhaps some things just get in the way / others time.
What I did basically moves the [self.map addAnnotations:AN ARRAY OF ANNOTATIONS] to the main thread and the whole loading process back, I also used a temporary array instead of "self.map.annotations" to remove the current annotations, it worked OK, so I just left it like that :), although I am not a world-class expert (even close), and I'm sure that others can have a more professional and effective solution, example code:
Please comment on my answer, as I will also be very happy to learn about a less complicated way to resolve this issue.
I think that most of these problems would be resolved if there was a way to โwait for completionโ when using background threads, because now it happens that the code continues to work before the whole loading process - the process of creating annotation-loading for creating a map is actually completed.
source share