Reputation: 4452
In Core Data I have an entity called item
which has the the attribute score
.
Currently score
has the type int16_t
.
score
s value is updated from different places within the project, by parsing it via [[UITextField text] integerValue]
, while keeping an open eye for overflow.
score
s datatype is very likely to change in the future.
I want to minimise future risk associated with that change.
The only way I can think of is by the preprocessor macro #define itemScore_t int16_t
.
Is there a better way, such as determining the datatype directly from Core Data?
Upvotes: 1
Views: 123
Reputation: 119031
Using NSEntityDescription
you can navigate to the particular attribute and get the NSAttributeDescription
, from there you can get the attributeType
(which gives NSInteger16AttributeType
/ NSInteger32AttributeType
/ NSInteger64AttributeType
).
Upvotes: 3