I'm using CoreData as a persistent store for my app data but would like to access elements in my data model by index rather than iterating through the whole collection every time.
For example if I have data of the form:
- "George"
- "Bill"
- "George"
- "Barack"
- "Donald"
I'd like to be able to update the elements without searching the collection each time.
If the data was in an array this would be easy ie:
Presidents[5] = "Hilary"
There doesn't seem to be an easy way to do this in CoreData other than
for president in Presidents{
if(president.id == 5){
president.name = "Hilary"
}
}
Which for large data sets will get hugely expensive. Am I missing something?