0

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.

4

2 回答 2

2
 typedef enum {
      ktUnknown=0, ktSingleSided=1, ktDoubleSided=2, ktTripleSingleSided=3
    } TICKType;

myobj.objsval仅当是整数属性时,枚举才能与整数值进行比较

if (myobj.objsval == ktSingleSided) the this condition will be satisfied
于 2013-06-26T04:33:01.643 回答
1

在 OC 中使用这样的枚举

if (myobj.objsval == ktSingleSided){
}

你不需要在这里声明。

于 2013-06-26T04:02:00.767 回答