I have a map view with annotations, and a callout is displayed in these annotations. When the button for detailed markup disclosure is pressed, it switches to a new view.
My MKAnnotations is a custom class that implements <MKAnnotation>
. Let me call this class MyClass. They are stored in NSMutableArray. During the viewdidload of this view, I add each MyClass object to this array to the map view annotations. Using the debugger, I see that after all this addition is complete, the order of [annotations [self.MapView] is the same as the order of NSMutableArray.
Now I set another breakpoint in mapView: viewForAnnotation: and check the order 1) of my NSMutableArray and 2) [self.MapView annotations]. The array is, of course, in the same order. However, the annotation order was scrambled.
This was a big problem for me because I needed to use the specific instance of MyClass that the user selected in the next view. AKA, I wanted to look at the annotation, find its index, and then use it to get the same index in the array.
Now I realized that I can just save the annotation directly (coming from the Android background, it was very cool for me). However, I still conceptually do not understand why the order became hacked. Can anybody help me? Code below:
- (void)viewDidLoad { if([fromString isEqualToString:@"FromList"]) self.navigationItem.hidesBackButton = TRUE; else { self.navigationItem.rightBarButtonItem = nil; } self.array = [MySingleton getArray];
source share