Ejemplo n.º 1
0
        public void RemoveObjectForKey(string key)
        {
            IntPtr intPtr = ObjC.ToNSString(key);

            ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("removeObjectForKey:"), intPtr);
            ObjC.MessageSend(intPtr, Selector.ReleaseHandle);
        }
Ejemplo n.º 2
0
        public void SetObjectForKey(NSObject obj, string key)
        {
            IntPtr intPtr = ObjC.ToNSString(key);

            ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("setObject:forKey:"), obj.Handle, intPtr);
            ObjC.MessageSend(intPtr, Selector.ReleaseHandle);
        }
Ejemplo n.º 3
0
        public NSObject ObjectForKey(string key)
        {
            IntPtr handle = ObjC.ToNSString(key);
            var    value  = Runtime.GetNSObject <NSObject>(ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("objectForKey:"), handle));

            ObjC.MessageSend(handle, Selector.ReleaseHandle);
            return(value);
        }
Ejemplo n.º 4
0
        public UIActivityViewController(string text, UIImage image)
        {
            IntPtr textHandle = ObjC.ToNSString(text);
            IntPtr array      = ObjC.ToNSArray(new[] { textHandle, image.Handle });

            ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("initWithActivityItems:applicationActivities:"), array, IntPtr.Zero);
            ObjC.MessageSend(textHandle, Selector.ReleaseHandle);
        }
Ejemplo n.º 5
0
        public string StringFromNumber(double number)
        {
            IntPtr handle = ObjC.ToNSNumber(number);
            string text   = ObjC.MessageSendString(Handle, Selector.GetHandle("stringFromNumber:"), handle);

            ObjC.MessageSend(handle, Selector.ReleaseHandle);
            return(text);
        }
Ejemplo n.º 6
0
        public static string LocalizedStringFromNumber(double number, NSNumberFormatterStyle style)
        {
            IntPtr handle = ObjC.ToNSNumber(number);
            string text   = ObjC.MessageSendString(_classHandle, Selector.GetHandle("localizedStringFromNumber:numberStyle:"), handle, (int)style);

            ObjC.MessageSend(handle, Selector.ReleaseHandle);
            return(text);
        }
Ejemplo n.º 7
0
        public new static NSMutableDictionary FromObjectAndKey(NSObject obj, string key)
        {
            IntPtr intPtr = ObjC.ToNSString(key);
            NSMutableDictionary nSObject = Runtime.GetNSObject <NSMutableDictionary>(ObjC.MessageSendIntPtr(_classHandle, Selector.GetHandle("dictionaryWithObject:forKey:"), obj.Handle, intPtr));

            ObjC.MessageSend(intPtr, Selector.ReleaseHandle);
            return(nSObject);
        }
Ejemplo n.º 8
0
        public string StringFromNumber(double number)
        {
            IntPtr intPtr = ObjC.ToNSNumber(number);
            string result = ObjC.MessageSendString(Handle, Selector.GetHandle("stringFromNumber:"), intPtr);

            ObjC.MessageSend(intPtr, Selector.ReleaseHandle);
            return(result);
        }
Ejemplo n.º 9
0
        public NSObject ObjectForKey(string key)
        {
            IntPtr   intPtr   = ObjC.ToNSString(key);
            NSObject nSObject = Runtime.GetNSObject <NSObject>(ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("objectForKey:"), intPtr));

            ObjC.MessageSend(intPtr, Selector.ReleaseHandle);
            return(nSObject);
        }
Ejemplo n.º 10
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.º 11
0
        public static NSDictionary FromObjectAndKey(NSObject obj, string key)
        {
            IntPtr handle     = ObjC.ToNSString(key);
            var    dictionary = Runtime.GetNSObject <NSDictionary>(ObjC.MessageSendIntPtr(_classHandle, Selector.GetHandle("dictionaryWithObject:forKey:"), obj.Handle, handle));

            ObjC.MessageSend(handle, Selector.ReleaseHandle);
            return(dictionary);
        }
Ejemplo n.º 12
0
        public UIActivityViewController(string text)
        {
            IntPtr intPtr = ObjC.ToNSString(text);
            IntPtr arg    = ObjC.ToNSArray(new IntPtr[1]
            {
                intPtr
            });

            ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("initWithActivityItems:applicationActivities:"), arg, IntPtr.Zero);
            ObjC.MessageSend(intPtr, Selector.ReleaseHandle);
        }
Ejemplo n.º 13
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.º 14
0
 public virtual void Dispose()
 {
     GC.SuppressFinalize(this);
     if (Handle != IntPtr.Zero)
     {
         Runtime.UnregisterNSObject(Handle);
         Callbacks.UnsubscribeAll(this);
         if (_shouldRelease)
         {
             ObjC.MessageSend(Handle, Selector.ReleaseHandle);
         }
     }
 }
Ejemplo n.º 15
0
        public static IntPtr ToNSSet(string[] items)
        {
            IntPtr[] strings = new IntPtr[items.Length];
            for (int i = 0; i < items.Length; i++)
            {
                strings[i] = ToNSString(items[i]);
            }

            IntPtr array = ToNSArray(strings);
            IntPtr set   = ObjC.MessageSendIntPtr(GetClass("NSSet"), SetWithArraySelector.Handle, array);

            //Release everything
            for (int i = 0; i < strings.Length; i++)
            {
                ObjC.MessageSend(strings[i], Selector.ReleaseHandle);
            }

            return(set);
        }
Ejemplo n.º 16
0
 //TODO: need to add the callback instead of using IntPtr.Zero
 public void DismissViewController(bool animated = true)
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("dismissViewControllerAnimated:completion:"), animated, IntPtr.Zero);
 }
Ejemplo n.º 17
0
 //TODO: need to add the callback instead of using IntPtr.Zero
 public void PresentViewController(UIViewController controller, bool animated = true)
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("presentViewController:animated:completion:"), controller.Handle, animated, IntPtr.Zero);
 }
Ejemplo n.º 18
0
 public void LoadView()
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("loadView"));
 }
Ejemplo n.º 19
0
 public SKProductsRequest(params string[] productIds)
 {
     ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("initWithProductIdentifiers:"), ObjC.ToNSSet(productIds));
     ObjC.MessageSend(Handle, Selector.GetHandle("setDelegate:"), Handle);
 }
Ejemplo n.º 20
0
 public void Cancel()
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("cancel"));
 }
Ejemplo n.º 21
0
 public void SetStatusBarHidden(bool hidden, bool animated = true)
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("setStatusBarHidden:animated:"), hidden, animated);
 }
Ejemplo n.º 22
0
 public void CancelAllLocalNotifications()
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("cancelAllLocalNotifications"));
 }
Ejemplo n.º 23
0
 public void ScheduleLocalNotification(UILocalNotification notification)
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("scheduleLocalNotification:"), notification.Handle);
 }
Ejemplo n.º 24
0
 public void PresentLocationNotificationNow(UILocalNotification notification)
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("presentLocalNotificationNow:"), notification.Handle);
 }
Ejemplo n.º 25
0
 public void RegisterUserNotificationSettings(UIUserNotificationSettings notificationSettings)
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("registerUserNotificationSettings:"), notificationSettings.Handle);
 }
Ejemplo n.º 26
0
 public void UnregisterForRemoteNotifications()
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("unregisterForRemoteNotifications"));
 }
Ejemplo n.º 27
0
 public static void ResetSystemTimeZone()
 {
     ObjC.MessageSend(_classHandle, Selector.GetHandle("resetSystemTimeZone"));
 }
Ejemplo n.º 28
0
 public void CancelLocalNotification(UILocalNotification notification)
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("cancelLocalNotification:"), notification.Handle);
 }
Ejemplo n.º 29
0
 public void RegisterForRemoteNotificationTypes(UIRemoteNotificationType types)
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("registerForRemoteNotificationTypes:"), (int)types);
 }
Ejemplo n.º 30
0
 public void PlayInputClick()
 {
     ObjC.MessageSend(Handle, Selector.GetHandle("playInputClick"));
 }