I've searched a bit around the web and found a few ideas on how to do what I want, but I would still like to know what you think I should do.
Here is the context :
I'm developing an app for iOS 5. I use MapKit to display a map, and I add around 5000 annotations to it - yup, that seems a lot, but don't worry, I use a clustering library :). In order not to load them every time the user opens the map, I create them in my appDelegate (I create an array of annotations, and call [_mapView addAnnotations:[appDelegate.annotationsToAdd allObjects]];
when I open the map). It takes about roughly 10 seconds to create the annotationsToAdd
array, so I think this solution is working pretty well (you have to wait for those 10 seconds before being authorized to open the map, but you only wait once, at the launch of the app). In each of those annotations, I have a "link" to an object, which contains an array of values (15 floats). For now, when I create the annotation, the subtitle
method returns one of those values.
In my map's ViewController, I have 2 segmented controls. The first one has 3 segments, the second one has 5, which gives 15 combinations - yup again, that's the same number of values the array of the object in my annotation has :).
So you may have seen my problem coming, I would like to update the subtitle of every annotation on my map (even the ones in the clusters, as the cluster gives an average value based on the pins it holds). What I would also want is to update the annotationView's color/image based on the value of the annotation's subtitle.
I may be wrong, but based on my research, I understand that you have to remove all the annotations, and recreate them all in order to do that. you understand that this is not an option in my case. I can't make the user wait 10 seconds every time he changes the value of one of the controls.
I saw an article on KVO: could that be a working solution ?
I don't know much about NSNotification, but should I use them ?
I would really appreciate your help, and I would even more appreciate a detailed answer, showing me the steps to follow in my apparently uncommon situation.
Thanks in advance.