My iOS application needs to store an MKPolyline
inside of an NSUserDefault
. I\'ve been doing a lot of research, and I now know that:
While you can implement NSCoding
yourself for MKPolyline
, and then construct an NSData
representation and store that in NSUserDefaults
, it might be better to represent the MKPolyline
using arrays and dictionaries, which NSUserDefaults
can directly handle.
Construct an array of dictionaries which encapsulate the x and y values for each point, and store that in NSUserDefaults
instead of the MKPolyline
.
When loading defaults, get the array, loop through the dictionaries reconstructing the points, and then re-create the MKPolyline
.