【发布时间】:2016-02-09 20:03:16
【问题描述】:
我有_userLocations:[CLLocation] 集合存储用户geoDatas,我想循环抛出_userLocations 集合并提取时间戳、纬度和经度属性并插入到名为savedLocations:[Location]=[] 的模型集合中。当我尝试使用for 循环进行循环时,我有这个错误_userLocations
'类型'[Location]'的值没有成员'timestamp''
有人可以帮我吗?
我的模特
class Location {
@NSManaged var latitude: NSNumber?
@NSManaged var longitude: NSNumber?
@NSManaged var timestamp: NSDate?
}
for location in _userLocations {
savedLocations.timestamp = location.timestamp
savedLocations.latitude = location.coordinate.latitude
savedLocations.longitude = location.coordinate.longitude
}
【问题讨论】:
-
你的
savedLocations不是[Location]吗?您需要创建一个新的Location对象并插入到savedLocations -
是的,它是位置数组
-
你能告诉我如何因为我是 swift 新手