I'm struggling to find a tutorial whereby I can update a core data entity. For example, if I have a field and an add button, I know how to add it to an entity. This field can add names: john, jack, jill but if I add john again I want to ensure that the duplicate is not entered.
Here is my add code.
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let entity = NSEntityDescription.entity(forEntityName: "UserAccountTbl", in: context)!
let person = NSManagedObject(entity: entity, insertInto: context)
person.setValue(NameSurname, forKeyPath: "nameSurname")
try context.save()