如何将toclocal转换为NSObject?

时间:2017-02-10 16:56:50

标签: ios delphi

在delphi中,我有这个程序:

procedure addObserver(observer: NSObject; ...)

观察者必须实现键值观察方法observeValue(),所以我试着这样做:

  IKVODelegate = interface(IObjectiveC)
    ['{B8C6720A-79B7-4FD6-B9E3-77594E905B3C}']
    procedure observeValueForKeyPath(keyPath: NSString; ofObject: Pointer; change: NSDictionary; context: Pointer); cdecl;
  end;

  TKVODelegate = class(TOCLocal, IKVODelegate)
  private
  public
    procedure observeValueForKeyPath(keyPath: NSString; ofObject: Pointer; change: NSDictionary; context: Pointer); cdecl;
  end;

然而,问题是TKVODelegate不是NSObject后代,因此我无法执行以下操作:

addObserver(MyKVODelegate) 

这是因为addObserver正在等待NSobject。我怎么能做到这一点?

0 个答案:

没有答案