Save MKPolyline as NSData in NSUserDefaults

坚强是说给别人听的谎言 提交于 2019-12-02 00:05:53
paulmelnikow

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!