title: Call method with function as argument of Cocoa Touch Framework (swift) from Single View Application (objective-c)
body: <p>I created <code>Cocoa Touch Framework</code> in <code>swift</code> (called MyFramework). In MyFramework I have method which requires functions as arguments. In short hand <strong>MyFramework</strong> contains this code:</p>
  
  <pre><code>public class MyFramework : NSObject {
      public func MyMethod(successCallback : (String) -&gt; Void, errorCallback : (String, String) -&gt; Void) -&gt; Void {
          dispatch_async(dispatch_get_main_queue(), { () -&gt; Void in
              // successCallback("some value");
              // errorCallback("error reason", "error message");
          });
      }
  }
  </code></pre>
  
  <p>I can include <code>MyFramework</code> in <code>Single View Application</code> called <code>MyAppSwift</code> (in <code>swift</code>) and successfully call <strong>MyMethod</strong> of MyFramework in <code>ViewController.swift</code> by this code:</p>
  
  <pre><code>class ViewController: UIViewController {
      let myframework : MyFramework = MyFramework();
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
          myframework.MyMethod(self.onSuccess, errorCallback : self.onError);
      }
  
      private func onSuccess(value : String) {
          // ... 
      }
  
      private func onError(reason : String, error : String) {
          // ...
      }
  }
  </code></pre>
  
  <p>I can include <code>MyFramework</code> in <code>Single View Application</code> called <code>MyAppObjectiveC</code> (in objective-c) but I do not know how to call <code>MyMethod</code> of MyFramework in <code>ViewController.m</code> ...</p>
  
  <pre><code>// In ViewController.h
  
  #import &lt;UIKit/UIKit.h&gt;
  #import &lt;MyFramework/MyFramework.h&gt;
  @interface ViewController : UIViewController {
  
  }
  @property (strong, nonatomic) MyFramework * myframework;
  - (void) onSuccess : (NSString *) value;
  - (void) onError : (NSString *) reason : (NSString *) error;
  @end
  </code></pre>
  
  <p>.</p>
  
  <pre><code>// In ViewController.m
  
  #import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  - (void) viewDidLoad {
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
      self.myframework = [[MyFramework alloc] init];
      [self.myframework MyMethod : self onSuccess, self onError];
  }
  - (void) onSuccess : (NSString *) value {
      // ...
  }
  - (void) onError : (NSString *) reason : (NSString *) error {
      // ...
  }
  
  @end
  </code></pre>
  
  <p>This line <strong>[self.myframework MyMethod : self onSuccess, self onError];</strong> is not working. Xcode says expecting identifier ":" after onSuccess and then expects expresion. Im not sure what to insert. I read several answers on stackoverflow how to pass method as argument in objective-c but no success. For example I have tried selectors <strong>[self.myframework MyMethod : @selector(onSuccess:), @selector(onError::)];</strong> but Xcode says: "Sending 'SEL' to parameter of incompatible type 'void(^_Nonnull)(NSString * _Nonnull __strong)'</p>