@IBAction func addLocation(_ sender: UIButton) {
//eklenen konumu ve verilerini kaydetme
if nameText.text == ""{
makeAlert(tıtleInput: "Error", messageInput: "İsim boş geçilemez!")
}
else if commentText.text == ""{
makeAlert(tıtleInput: "Error", messageInput: "Yorum boş geçilemez!")
}
else if choosenLatitude == nil && choosenLongitude == nil {
makeAlert(tıtleInput: "Error", messageInput: "Lütfen konumunuzu seçin")
}
else{
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let context = appDelegate.persistentContainer.viewContext
let newPlace = NSEntityDescription.insertNewObject(forEntityName: "Places", into: context)
newPlace.setValue(nameText.text, forKey:"title")
newPlace.setValue(commentText.text, forKey: "subtitle")
newPlace.setValue(self.choosenLongitude, forKey: "longitude")
newPlace.setValue(self.choosenLatitude, forKey: "latitude")
newPlace.setValue(UUID(), forKey: "id")
I want it to throw an error if chosenlatitude and chosenlongitude are empty, but I don't know how to do this in the double variable.
the error i got Comparing non-optional value of type 'Double' to 'nil' always returns false