public static void Subscribe(NSObject obj, string selector, EventHandler <ButtonEventArgs> callback) { var methods = GetMethods(obj, selector); methods.EventHandlerInt += callback; if (!_delegates.ContainsKey(selector)) { Action <IntPtr, IntPtr, IntPtr, int> del = OnCallbackInt; if (!ObjC.AddMethod(obj.ClassHandle, selector, del, "v@:@l")) { 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; } } }