Reputation: 5510
I am abit stuck on how I use enum's in my project, I have set up the the enum object but I would like to know how to use it.
This is what I have done so far
//.h
typedef enum {
ktUnknown=0, ktSingleSided=1, ktDoubleSided=2, ktTripleSingleSided=3
} TICKType;
//..
TICKType Type;
//..
@property (assign) TICKType Type;
Now I would like to know how to check if an integer equals one of those enum types in an if statement.
this is kinda what im doing obviously not working
if (myobj.objsval == Type.ktSingleSided) {
}
but unfortunately this is not working. any help figuring this out would be greatly appreciated.
Upvotes: 0
Views: 5247
Reputation: 5268
typedef enum {
ktUnknown=0, ktSingleSided=1, ktDoubleSided=2, ktTripleSingleSided=3
} TICKType;
enum can be compared to integer value only if myobj.objsval
is a integer property
if (myobj.objsval == ktSingleSided) the this condition will be satisfied
Upvotes: 2
Reputation: 307
in OC use enum like this
if (myobj.objsval == ktSingleSided){
}
you don't need to type declared here.
Upvotes: 1