How can I call an Objective C instance method from a c++ class? In TestApp.cpp I would like to call updateUI in TestDelegate.mm
TestDelegate.h
#include "cinder/app/CinderView.h" #include "TestApp.h" #import <Cocoa/Cocoa.h> @interface TestDelegate : NSObject <NSApplicationDelegate> { IBOutlet CinderView *cinderView; IBOutlet NSWindow *window; TestApp *mApp; } @property (assign) IBOutlet NSWindow *window; - (IBAction)subdivisionSliderChanged:(id)sender; - (void)updateUI; @end TestDelegate.mm
#include "cinder/Cinder.h" #import "TestDelegate.h" @implementation TestDelegate @synthesize window; - (void)dealloc { [super dealloc]; } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { mApp = new TestApp; mApp->prepareLaunch(); mApp->setupCinderView( cinderView, cinder::app::RendererGl::create() ); mApp->launch(); } - (void)updateUI { //Set new values... } @end TestApp.h
#pragma once #include "cinder/app/AppCocoaView.h" class TestApp : public cinder::app::AppCocoaView { public: void setup(); void draw(); }; TestApp.cpp
#include "TestApp.h" #include "cinder/gl/gl.h" using namespace ci; using namespace ci::app; void TestApp::setup() { //Set values //Call updateUI method in TestDelegate.mm } void TestApp::draw() { }