I am writing a simple iOS app that shows historic soccer scores. At present, I am trying to stop duplicate "match info" objects appearing in the table view of historic results (my code pulls match info objects based on the date of the game matching today's date going back X number of years. A bit like Timehop).
This works fine, however there is no check to see if a match info object already exists in the context. A duplicate will be created if the user re-visits the Settings menu to choose other teams' results to see and DOES NOT deselect a previously chosen team.
What is the easiest way to avoid creating the duplicate altogether if my managed object context already contains an object with the new object's data?
I am using the basic code to instantiate the Match Info objects:
let newManagedObject = NSEntityDescription.insertNewObjectForEntityForName(entity.name!, inManagedObjectContext: context)
Thanks!