Subscribe() public static method

public static Subscribe ( NSObject obj, string selector, EventHandler callback ) : void
obj NSObject
selector string
callback EventHandler
return void
Ejemplo n.º 1
0
        public NSObject AddObserver(string name, Action <NSNotification> action, NSObject fromObject = null)
        {
            var handler = new Observer(action);

            Callbacks.Subscribe(handler, SelectorName, n => action(Runtime.GetNSObject <NSNotification>(n)));
            ObjC.MessageSend(Handle, Selector.GetHandle("addObserver:selector:name:object:"), handler.Handle, Selector.GetHandle(SelectorName), name, fromObject == null ? IntPtr.Zero : fromObject.Handle);
            return(handler);
        }
Ejemplo n.º 2
0
        public NSObject AddObserver(string name, Action <NSNotification> action, NSObject fromObject = null)
        {
            Observer observer = new Observer(action);

            Callbacks.Subscribe(observer, "__onNotification:", delegate(IntPtr n)
            {
                action(Runtime.GetNSObject <NSNotification>(n));
            });
            ObjC.MessageSend(Handle, Selector.GetHandle("addObserver:selector:name:object:"), observer.Handle, Selector.GetHandle("__onNotification:"), name, fromObject?.Handle ?? IntPtr.Zero);
            return(observer);
        }
Ejemplo n.º 3
0
 public void SaveToPhotosAlbum(Action <NSError> callback = null)
 {
     if (callback == null)
     {
         UIImageWriteToSavedPhotosAlbum(Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
     }
     else
     {
         UIImageDispatcher dispatcher = new UIImageDispatcher(callback);
         Callbacks.Subscribe(dispatcher, "__onSaveToPhotoAlbum:", delegate(IntPtr obj, IntPtr e, IntPtr ctx)
         {
             callback((e == IntPtr.Zero) ? null : Runtime.GetNSObject <NSError>(e));
             dispatcher.Dispose();
         });
         UIImageWriteToSavedPhotosAlbum(Handle, dispatcher.Handle, ObjC.GetSelector("__onSaveToPhotoAlbum:"), IntPtr.Zero);
     }
 }