IOS Apprentice Chapter 34 Solutions for Exercise?

Here is what i have got it seems to work, has anyone got better? I have tried more complicated solutions for the NSUpdatedObjectsKey, but simply removing annotations then adding them worked the same, is this because it uses a hash with the MKAnnotation properties of the object which don’t change in this app; allowing you to reference the old locations with the new updated version?

image

@matthewvee Thank you for sharing your solution - much appreciated! :]

@matthewvee. My solution is nearly identical (we even chose the same names :slight_smile: ), the only real difference is that I extended the updateLocations method instead of adding directly to the property logic. I’m not sure that this is “better” or not.

image

I was also wondering how to handle the updated locations and was surprised that removeAnnotations removed the correct pin when passed the updated location object. It makes sense that this would work considering Location is a class and is passed by reference, but removeAnnotations has no idea that this is the case and only knows how to handle objects that implement the MKAnnotation. Since MKAnnotation can be implemented by structs or classes, I don’t think my explanation is correct…

@clarkesm Thank you for sharing your solution - much appreciated!

This topic was automatically closed after 166 days. New replies are no longer allowed.