I am trying to store an enum value in coredata, though I understand the way doing it with normal coredata. My case is specific to AFIncrementalStore.
I am trying to do the following
- (NSDictionary *)attributesForRepresentation:(NSDictionary *)representation
ofEntity:(NSEntityDescription *)entity
fromResponse:(NSHTTPURLResponse *)response
{
......
if (representation[@"type"] != nil) {
[mutablePropertyValues setValue:[NSNumber numberWithInt:(MyEnumType)[Content typeFromString:representation[@"type"]]] forKey:@"contentType"];
}
.....
}
Though I am able to save this as an NSNumber, how can I retrieve the enum value from my entity. Since, AFIncrementalStore is taking care of storing the value to entity, I am not sure how to retrieve the enum value. Can anyone Please help. Thanks in advance.
EDIT: My problem is while retreiving I will have access to the entity which has the contentType as enum not as NSNumber For eg. I cant do [myentity.contentType intValue], since myentity.contentType is already a enum or integer value.