c++/cli pass (managed) delegate to unmanaged code

Yes, you want Marshal::GetFunctionPointerForDelegate(). Your code snippet is missing the managed function you’d want to call, I just made one up. You will also have to declare the managed delegate type and create an instance of it before you can get a function pointer. This worked well: #include “stdafx.h” using namespace System; using namespace System::Runtime::InteropServices; … Read more

Delegates in swift?

Here’s a little help on delegates between two view controllers: Step 1: Make a protocol in the UIViewController that you will be removing/will be sending the data. protocol FooTwoViewControllerDelegate:class { func myVCDidFinish(_ controller: FooTwoViewController, text: String) } Step2: Declare the delegate in the sending class (i.e. UIViewcontroller) class FooTwoViewController: UIViewController { weak var delegate: FooTwoViewControllerDelegate? … Read more