将 cllocation 值数组存储在 userdefaults iphone sdk 中
您好,我有一个 cllocation 值数组,我需要将该数组存储在 userdefaults 中...我该怎么做...?
您好,我将对象添加到数组中: [AM_locationMP.favArray addObject:[AM_locationMP.locationData objectAtIndex:AM_locationMP.indexno]];
其中位置数据是位置地标值的数组。
其中 maplocationVO 类用于地标 地图位置VO *当前地图位置;
[AM_delegate.locationData addObject: currentMapLocation];
hi i have an array of cllocation values, i need to store that array in userdefaults...how do i do it...?
hi these where i add object to my array:
[AM_locationMP.favArray addObject:[AM_locationMP.locationData objectAtIndex:AM_locationMP.indexno]];
where location data is array of location placemark values .
where maplocationVO class is for placemark
MapLocationVO *currentMapLocation;
[AM_delegate.locationData addObject: currentMapLocation];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当人们显然不知道答案,或者不知道可以在 NSUserDefaults 中存储什么和不能存储什么时,为什么他们还要在这里发帖?
您需要使用 NSKeyedArchiver 将 CLLocation 数据转换为 NSData。然后使用 NSKeyedUnarchiver 将 NSData 转回 CLLocation 数据。
下一个要解决的问题是,当您归档 CLLocation 对象并将它们存储在 UserDefaults 中时,无法正确取消归档。唯一的解决方案可能是将它们保存到文件中。
Why do people post on here when they clearly don't know the answer, or understand what you can and cannot store in NSUserDefaults?
You need to use NSKeyedArchiver to turn the CLLocation data into NSData. Then use NSKeyedUnarchiver to turn the NSData back into CLLocation data.
The next problem to solve is when you archive CLLocation objects and store them in UserDefaults, the don't unarchive properly. The only solution may be to save them to file instead.
这应该足以写它:
this should be enough to write it:
使用它
来设置数组
和获取数组
use this
for setting array
and for getting array