示例#1
0
        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;
            }
        }
示例#2
0
        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;
                }
            }
        }
示例#3
0
        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;
                }
            }
        }
示例#4
0
        public static void Unsubscribe(NSObject obj, string selector, IntPtrHandler callback)
        {
            Methods methods = GetMethods(obj, selector);

            methods.ActionIntPtr = (IntPtrHandler)Delegate.Remove(methods.ActionIntPtr, callback);
        }
示例#5
0
 public static void Unsubscribe(NSObject obj, string selector, IntPtrHandler callback)
 {
     var methods = GetMethods(obj, selector);
     methods.ActionIntPtr -= callback;
 }
示例#6
0
        public static void Unsubscribe(NSObject obj, string selector, IntPtrHandler callback)
        {
            var methods = GetMethods(obj, selector);

            methods.ActionIntPtr -= callback;
        }