0

I wonder if anyone can shed light on this strange issue...

I created an attribute called "updated" in an entity called "Users" in swift 2 core data. I set the attribute to type Boolean as it was supposed to be a flag to indicate if the record had been updated or not.

I had all sorts of problems getting Booleans to work with core data (but that's another story!), so I changed the type to Int16 with the idea of simply setting it's value to 1 or 0, but the attribute still acted as though it were a Boolean and did not work as expected.

Next I tried deleting the attribute, deleting the app on the simulator, running the app, adding the attribute back (as an Int16), deleting the app and running it again, but still it acts like a Boolean.

So I added a new attribute called "modified" and set it's type to Int16 which worked fine for my purposes.

So it would appear that Xcode is caching the attribute name & properties which feels like a bug to me. Has anyone else come across this behaviour? or is there something that I am missing? some vital step I need to complete if I want to change an attributes type?

Thanks

Paul
  • 103
  • 6
  • 1
    Don't call an Core Data attribute "updated" or "deleted". Depending on how you retrieve it, you might get the value of your "updated" attribute, or the value of the [`updated` property](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/#//apple_ref/occ/instp/NSManagedObject/updated) of NSManagedObject. – Martin R Jan 16 '16 at 10:32
  • Damn is that all it is! I searched & searched for ages until I gave up & posted the question. It's not well documented in the Apple docs. Ideally Xcode should at least warn you at compile time if you're using a reserved word! Thanks Martin R – Paul Jan 16 '16 at 13:32

0 Answers0