I have an Objective C selector which returns integers. I have a C++ instance method which expects an enum. How can I link them? I’m in an Objective C++ (.mm) class while I’m doing this.
I want to call this:
TKClass::foo(MyEnum enumVal) { ... }
With the return value of this:
- (int) intValue { ... }
Like this:
myCPPInstance->foo([myObjCInstance intValue]);
I’ve tried casting (foo((MyEnum) [myObjCInstance integerValue])) but it doesn’t work. I definitely don’t want my Objective C object to know anything about the enum; intValue needs to stay as an integer. Similarly, I don’t really want to have the C++ method worry about integer inputs when it should be accepting enums.
I’m not much of a C++ programmer, so sorry if this is easy.
Thanks
EDIT: The enum is defined like this:
enum MyEnum {
Apples = 0,
Bananas = 1,
Chocolate = 2
};
It was a namespace issue. The cast should have been: