public static void Subscribe(NSObject obj, string selector, IntPtrHandler callback) { Methods methods = GetMethods(obj, selector); methods.ActionIntPtr = (IntPtrHandler)Delegate.Combine(methods.ActionIntPtr, callback); if (!_delegates.ContainsKey(selector)) { IntPtrHandler3 intPtrHandler = OnCallback; if (!ObjC.AddMethod(obj.ClassHandle, Selector.GetHandle(selector), intPtrHandler, "v@:@")) { throw new InvalidOperationException("AddMethod failed for selector " + selector); } _delegates[selector] = intPtrHandler; } }
public static void Subscribe(NSObject obj, string selector, IntPtrHandler callback) { var methods = GetMethods(obj, selector); methods.ActionIntPtr += callback; if (!_delegates.ContainsKey(selector)) { IntPtrHandler3 del = OnCallback; if (!ObjC.AddMethod(obj.ClassHandle, Selector.GetHandle(selector), del, "v@:@")) { throw new InvalidOperationException("AddMethod failed for selector " + selector); } else { _delegates[selector] = del; } } }
public static void Subscribe(NSObject obj, string selector, IntPtrHandler callback) { var methods = GetMethods(obj, selector); methods.ActionIntPtr += callback; if (!_delegates.ContainsKey(selector)) { IntPtrHandler3 del = OnCallback; if (!ObjC.AddMethod(obj.ClassHandle, selector, del, "v@:@")) { throw new InvalidOperationException("AddMethod failed for selector " + selector); } else { _delegates[selector] = del; } } }
public static void Unsubscribe(NSObject obj, string selector, IntPtrHandler callback) { Methods methods = GetMethods(obj, selector); methods.ActionIntPtr = (IntPtrHandler)Delegate.Remove(methods.ActionIntPtr, callback); }
public static void Unsubscribe(NSObject obj, string selector, IntPtrHandler callback) { var methods = GetMethods(obj, selector); methods.ActionIntPtr -= callback; }