Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 798 Bytes

README.md

File metadata and controls

26 lines (18 loc) · 798 Bytes

Patika_ListApp

CoreData -> delete all item in entity

@IBAction func didRemoveBarButtonItemTapped(_ sender: Any) {
        presentAlert(title: "Uyarı!",
                     message: "Listedeki bütün öğeleri silmek istediğinize emin misiniz?",
                     defaultButtonTitle: "Evet",
                     cancelButtonTitle: "Vazgeç") { _ in
            
            let appDelegate = UIApplication.shared.delegate as? AppDelegate
            
            let managedObjectContext = appDelegate?.persistentContainer.viewContext
            
            for item in self.data {
                managedObjectContext?.delete(item)
            }
            
            try? managedObjectContext?.save()
            
            self.fetch()
        }
        
    }