Hopefully I can make it clear what I'm attempting to accomplish, so here goes. I'm using Core Data to store my data. And many of my view controllers I have a tutorial that will pop up to explain how to use my app. I've created an entity called "tutorials" where each attribute is a boolean storing if the tutorial for that view controller will be shown.
When the app is run for the first time it creates an entry in the tutorials entity and then sets all the attributes in it to true. Currently I'm setting each attribute by using something like this tutorials.attributeName = true
, but since I know all of the attributes will be true, I was hoping to use something similar to this question.
Core Data - Iterating through the attributes of a NSManagedObject
I tried using this from the answer that shows Swift 3.0, but it turns out I can't use item.valueForKey(key) = true
since item.valueForKey(key)
is read only. Since I already have tutorial set as my tutorial entity, my code is much more simple. But I need to know how to set the attribute value when using the key.
for key in tutorials.entity.attributesByName.keys {
//Code to set attribute key to true
}
Any help to get me that last mile would be much appreciated. Thank you