Log in or register to post comments

Call Objective C method from VirtualButton_UpdateCallback

November 15, 2012 - 3:47am #1

Hi everyone,

I like to start a new ViewController from an virtual button but how can I call a Objective C method from this C++ method. The keywords self gives the following error:
Use of undeclared identifier 'self'
I like to call the Objective C method [self test];

How can this be done?

Thanks

Call Objective C method from VirtualButton_UpdateCallback

November 15, 2012 - 9:39am #2

Hi smek,

The problem here is that "self" has no meaning because the callback is declared in its own namespace and as such does not belong to an object i.e. there is no self.

    class VirtualButton_UpdateCallback : public QCAR::UpdateCallback {

        virtual void QCAR_onUpdate(QCAR::State& state);

    } qcarUpdate;

 

It sounds like maybe what you want to do is reference an object from within the callback and then call a method on it.

I am not sure you can pass this in as a parameter to the callback as I think the format here might be fixed i.e. the library probably depends on it.

...in which case you may need to declare this class/object somewhere, such that the callback function can call it within scope.  Hopefully you may be able to find a way of doing this elegantly.

HTH

N

 

Log in or register to post comments