0
我正在將註釋存儲並加載到基於coredata的地圖上。基於MKAnnotion刪除核心數據對象
我不知道如何去點擊註釋並刪除該針的coredata。
與在tableview中不同,沒有真正的indexPath從我抓取的對象數組中刪除。唯一可以考慮在屏幕上跟蹤我的註釋的方法就是給他們提供所有結果數組的標籤和線條,但我覺得必須有更好的方法。
我知道如何實現在引腳上點擊,但是一旦我選擇了引腳,我該如何將它與創建的coredata對象綁定在一起?
func loadPins(){
let pinRequest : NSFetchRequest<Pin> = Pin.fetchRequest()
do {
pins = try managedObjectContext.fetch(pinRequest)
} catch {
print("There was en error fetching pins")
}
for pin in pins {
let lat = pin.latitude
let lon = pin.longitude
let coordinate = CLLocationCoordinate2D(latitude: lat, longitude: lon)
createAnnotation(coordinate: coordinate)
}
}
func createAnnotation(coordinate : CLLocationCoordinate2D){
let annotation = MKPointAnnotation()
annotation.coordinate = coordinate
annotation.title = "henlo"
map.addAnnotation(annotation)
}
我甚至不知道對象ID的是一件事。這是完美的,謝謝! – user6820041