I have class Distance and typedef enum Unit,
@interface Distance:NSObject{
double m_miles;
}
@property double m_miles;
-(Distance *) initWithDistance: (double) value andUnit:(Unit) unit;
@implementation Distance
-(Distance *)initWithDistance: (double) value andUnit:(Unit) unit{
self = [super init];
if (self){
switch (unit) {
case Unit.miles: m_miles = value;
break;
case Unit.km: m_miles = value/1.609344;
break;
}
}
Where do I declare my enum Unit? How to access
typedef enum{
miles;
km;
}Unit
In the other class I should be able to call Distance.Unit.km
or miles:
Distance *a = [[Distance alloc] initWithDistance: 10.2 andUnit: Distance.Unit.km];