【发布时间】:2020-10-09 04:17:08
【问题描述】:
我目前有核心数据,我想传递存在于持久存储中的选定引脚的坐标。所以我过滤了获取的对象并与视图注释坐标匹配。位置是我的实体的一个实例。我的代码如下:
var location: Location!
var latitude: Double = 0.0
var longitude: Double = 0.0
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
performSegue(withIdentifier: "toPhotos", sender: self)
let savedPins = fetchResultController.fetchedObjects!
location = savedPins.filter({$0.latitude == view.annotation?.coordinate.latitude && $0.longitude == view.annotation?.coordinate.longitude}).first
self.longitude = location.longitude
self.latitude = location.latitude
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let vc = segue.destination as? photoAlbumViewController {
vc.dataController = dataController
vc.longitude = longitude
vc.latitude = latitude
}
当它转场时,它不会在第一次尝试时发送坐标,直到我第二次转回相册视图控制器,然后我才收到第一个坐标。
【问题讨论】:
标签: ios swift iphone core-data