Hello:
I want to be able to check if a specific Core Data record was fetched previously by comparing the Record ID with the one being currently fetched. I want to some how to mark each fetched record so I can know whether or not it has been called before.
I don't want to save every fetched record to a data store then compare new fetches with what is there because it would call for a lot of processing resources.
Is there an easier way?
Thanks.
OK, if you can fetch all questions (but what about when you have 1000 or 10 000 ?), you can do as you propose.
As for creating the dict, you need first to select what should be the unique key. RecordID string seems well appropriate.
var alreadyAnswered = [String: Bool]()
It is probably wiser to keep track of answered questions, not of all fetched.
-> In the code where question is presented to user:
let questionID = recordID // or String(recordID) depending what recordID is
alreadyAnswered[questionID] = true
Then, before presenting a new question:
- you have to fetch or you read from the fetched values
let questionID = recordID // or String(recordID) depending what recordID is
if !alreadyAnswered[questionID] {
// show the question
alreadyAnswered[questionID] = true
}