How can I check the property attribute dynamically in Core Data / iPhone?
I ha开发者_开发技巧ve a line of code like this in a function:
....[record valueForKey:fieldName]....;
It (the part shown) works fine and gets the value I am searching for, from core data.
Is there a way I can test the type of this piece of data ? I mean its property attribute in the core data entity. In other words I want to test if it is String or Float or ....
You can get it from NSAttributeDescription that is stored in the NSEntityDescription
You can get the entity description by name from you managedobjectmodel.
This description contains attributes which are all of the NSAttributeDescription type. An AttributeDesciption contains an variable called attributeType.
See:
enter link description here
精彩评论