Exemplo 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);
        }
Exemplo n.º 2
0
        public static UIUserNotificationSettings GetSettingsForTypes(UIUserNotificationType types)
        {
            //NOTE: right now we don't have support for categories, it required UIUserNotificationCategory, which is a somewhat advanced scenario I'd say
            IntPtr handle = ObjC.MessageSendIntPtr(_classHandle, Selector.GetHandle("settingsForTypes:categories:"), (uint)types, IntPtr.Zero);

            return(Runtime.GetNSObject <UIUserNotificationSettings>(handle));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public static UIImage FromFile(string filename)
        {
#if !XAMARIN
            filename = Path.Combine(UnityEngine.Application.streamingAssetsPath, filename);
#endif

            return(Runtime.GetNSObject <UIImage>(ObjC.MessageSendIntPtr(_classHandle, Selector.GetHandle("imageWithContentsOfFile:"), filename)));
        }
Exemplo n.º 6
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);
        }
Exemplo 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);
        }
Exemplo n.º 8
0
        public NSObject[] ObjectsForKeys(string[] keys)
        {
            IntPtr intPtr = ObjC.ToNSArray(keys);

            NSObject[] result = ObjC.FromNSArray <NSObject>(Runtime.GetNSObject <NSObject>(ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("objectsForKeys:notFoundMarker:"), intPtr, new NSObject().Handle)).Handle);
            ObjC.ReleaseNSArrayItems(intPtr);
            return(result);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public static NSData FromUrl(string url, NSDataReadingOptions mask, out NSError error)
        {
            IntPtr errorHandle;
            var    data = Runtime.GetNSObject <NSData>(ObjC.MessageSendIntPtr_NSUrl(_classHandle, Selector.GetHandle("dataWithContentsOfURL:options:error:"), url, (uint)mask, out errorHandle));

            error = errorHandle == IntPtr.Zero ? null : Runtime.GetNSObject <NSError>(errorHandle);
            return(data);
        }
Exemplo n.º 13
0
        public static NSData FromFile(string path)
        {
#if !XAMARIN
            path = Path.Combine(UnityEngine.Application.streamingAssetsPath, path);
#endif

            return(Runtime.GetNSObject <NSData>(ObjC.MessageSendIntPtr(_classHandle, Selector.GetHandle("dataWithContentsOfFile:"), path)));
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
 public object MarshalNativeToManaged(IntPtr pNativeData)
 {
     if (pNativeData == IntPtr.Zero)
     {
         return(null);
     }
     return(ObjC.FromNSUrl(pNativeData));
 }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        public static NSData FromUrl(string url, NSDataReadingOptions mask, out NSError error)
        {
            IntPtr arg;
            NSData nSObject = Runtime.GetNSObject <NSData>(ObjC.MessageSendIntPtr_NSUrl(_classHandle, Selector.GetHandle("dataWithContentsOfURL:options:error:"), url, (uint)mask, out arg));

            error = ((arg == IntPtr.Zero) ? null : Runtime.GetNSObject <NSError>(arg));
            return(nSObject);
        }
Exemplo n.º 19
0
        public static NSDictionary FromObjectsAndKeys(NSObject[] objs, string[] keys)
        {
            var objectsHandle = ObjC.ToNSArray(objs);
            var keysHandle    = ObjC.ToNSArray(keys);
            var dictionary    = Runtime.GetNSObject <NSDictionary>(ObjC.MessageSendIntPtr(_classHandle, Selector.GetHandle("dictionaryWithObjects:forKeys:"), objectsHandle, keysHandle));

            ObjC.ReleaseNSArrayItems(keysHandle);
            return(dictionary);
        }
Exemplo n.º 20
0
        public new static NSMutableDictionary FromObjectsAndKeys(NSObject[] objects, string[] keys)
        {
            IntPtr arg    = ObjC.ToNSArray(objects);
            IntPtr intPtr = ObjC.ToNSArray(keys);
            NSMutableDictionary nSObject = Runtime.GetNSObject <NSMutableDictionary>(ObjC.MessageSendIntPtr(_classHandle, Selector.GetHandle("dictionaryWithObjects:forKeys:"), arg, intPtr));

            ObjC.ReleaseNSArrayItems(intPtr);
            return(nSObject);
        }
Exemplo n.º 21
0
        public static string FromNSUrl(IntPtr handle)
        {
            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            return(FromNSString(ObjC.MessageSendIntPtr(handle, AbsoluteStringSelector.Handle)));
        }
Exemplo n.º 22
0
        public static string FromNSString(IntPtr handle)
        {
            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            return(Marshal.PtrToStringAuto(ObjC.MessageSendIntPtr(handle, Selector.UTF8StringHandle)));
        }
Exemplo n.º 23
0
        public NSObject[] ObjectsForKeys(string[] keys)
        {
            var keysHandle = ObjC.ToNSArray(keys);
            var arrayPtr   = Runtime.GetNSObject <NSObject>(ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("objectsForKeys:notFoundMarker:"), keysHandle, new NSObject().Handle));
            var array      = ObjC.FromNSArray <NSObject>(arrayPtr.Handle);

            ObjC.ReleaseNSArrayItems(keysHandle);
            return(array);
        }
Exemplo n.º 24
0
        public static double FromNSNumber(IntPtr handle)
        {
            if (handle == IntPtr.Zero)
            {
                return(default(double));
            }

            return(ObjC.MessageSendDouble(handle, DoubleValueSelector.Handle));
        }
Exemplo n.º 25
0
        public UIActivityViewController(UIImage image)
        {
            IntPtr arg = ObjC.ToNSArray(new IntPtr[1]
            {
                image.Handle
            });

            ObjC.MessageSendIntPtr(Handle, Selector.GetHandle("initWithActivityItems:applicationActivities:"), arg, IntPtr.Zero);
        }
Exemplo n.º 26
0
        public static NSData FromFile(string path, NSDataReadingOptions mask, out NSError error)
        {
            path = Path.Combine(Application.get_streamingAssetsPath(), path);
            IntPtr arg;
            NSData nSObject = Runtime.GetNSObject <NSData>(ObjC.MessageSendIntPtr(_classHandle, Selector.GetHandle("dataWithContentsOfFile:options:error:"), path, (uint)mask, out arg));

            error = ((arg == IntPtr.Zero) ? null : Runtime.GetNSObject <NSError>(arg));
            return(nSObject);
        }
Exemplo n.º 27
0
        public IntPtr MarshalManagedToNative(object managedObj)
        {
            string text = managedObj as string;

            if (text == null)
            {
                return(IntPtr.Zero);
            }
            return(ObjC.ToNSUrl(text));
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
0
        public static void ReleaseNSArrayItems(IntPtr handle)
        {
            uint   count = ObjC.MessageSendUInt(handle, CountSelector.Handle);
            IntPtr obj;

            for (uint num = 0; num < count; num += 1)
            {
                obj = ObjC.MessageSendIntPtr(handle, ObjectAtIndexSelector.Handle, num);
                MessageSend(obj, Selector.ReleaseHandle);
            }
        }
Exemplo n.º 30
0
        public static T[] FromNSSet <T>(IntPtr handle) where T : NSObject
        {
            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            IntPtr array = ObjC.MessageSendIntPtr(handle, AllObjectsSelector.Handle);

            return(FromNSArray <T>(array));
        }