I'm trying to implement a simple method, however, I'm still pretty new to objective-c.
I have this simple method that tries to convert from id to a specific value in an enumeration, if one matches.
This listing
typedef enum {
DXTypeUnknown = 0,
DXDatasource = 1,
DXGroup = 2
} DXPropertyType;
And this is the appropriate method:
-(DXPropertyType)typeFromObject:(id)_type {
int _t = [_type intValue];
switch (_t) {
case DXDatasource:
return [NSNumber numberWithInt:DXDatasource];
case DXGroup:
return [NSNumber numberWithInt:DXGroup];
default:
return [NSNumber numberWithInt:DXTypeUnknown];
}
}
, , - int, , , , , . , /, , ?
, , , , .
[EDIT]
, NSManagedObject, CoreData NSNumber, , , .