Esempio n. 1
0
 public void SaveToPhotosAlbum(Action <NSError> callback = null)
 {
     if (callback == null)
     {
         UIImageWriteToSavedPhotosAlbum(Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
     }
     else
     {
         var dispatcher = new UIImageDispatcher(callback);
         Callbacks.Subscribe(dispatcher, SelectorName, (IntPtr obj, IntPtr e, IntPtr ctx) =>
         {
             callback(e == IntPtr.Zero ? null : Runtime.GetNSObject <NSError>(e));
             dispatcher.Dispose();
         });
         UIImageWriteToSavedPhotosAlbum(Handle, dispatcher.Handle, ObjC.GetSelector(SelectorName), IntPtr.Zero);
     }
 }
Esempio n. 2
0
        private static Methods GetMethods(NSObject obj, string selector)
        {
            Dictionary <IntPtr, Methods> dictionary;

            if (!_callbacks.TryGetValue(obj.Handle, out dictionary))
            {
                _callbacks[obj.Handle] = dictionary = new Dictionary <IntPtr, Methods>();
            }

            IntPtr selectorHandle = ObjC.GetSelector(selector);

            Methods methods;

            if (!dictionary.TryGetValue(selectorHandle, out methods))
            {
                dictionary[selectorHandle] = methods = new Methods(obj);
            }

            return(methods);
        }
Esempio n. 3
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, "addObserver:selector:name:object:", handler.Handle, ObjC.GetSelector(SelectorName), name, fromObject == null ? IntPtr.Zero : fromObject.Handle);
            return(handler);
        }