Example #1
0
        public void CreateTest()
        {
            var handle = CFArray.Create(TestArray);

            using var a = Runtime.GetINativeObject <CFArray> (handle, true);
            VerifyArray(a);
            Assert.AreEqual((nint)1, CFGetRetainCount(handle), "RC");
        }
Example #2
0
        public void ArrayFromHandleTest_bool_false()
        {
            var handle = CFArray.Create(TestArray);
            var a      = CFArray.ArrayFromHandle <NSString> (handle, false);

            VerifyArray(a);
            Assert.AreEqual((nint)1, CFGetRetainCount(handle), "RC");
            CFRelease(handle);
        }
Example #3
0
        public void ArrayFromHandleFuncTest()
        {
            var handle = CFArray.Create(TestArray);
            var a      = CFArray.ArrayFromHandleFunc <string> (handle, (v) => CFString.FromHandle(v));

            VerifyArray(a);
            Assert.AreEqual((nint)1, CFGetRetainCount(handle), "RC");
            CFRelease(handle);
        }
        // 'Value must be a CFArray of CFNumberRefs' - System/Library/Frameworks/CoreText.framework/Headers/CTStringAttributes.h
        public void SetWritingDirection(params CTWritingDirection[] writingDirections)
        {
            var ptrs = new IntPtr [writingDirections.Length];

            for (int i = 0; i < writingDirections.Length; ++i)
            {
                ptrs[i] = (new NSNumber((int)writingDirections[i])).Handle;
            }

            var array = CFArray.Create(ptrs);

            CFMutableDictionary.SetValue(Dictionary.Handle, CTStringAttributeKey.WritingDirection.Handle, array);
        }
        // 'Value must be a CFArray of CFNumberRefs' - System/Library/Frameworks/CoreText.framework/Headers/CTStringAttributes.h
        public void SetWritingDirection(params CTWritingDirection[] writingDirections)
        {
            var ptrs    = new NativeHandle [writingDirections.Length];
            var numbers = new NSNumber [writingDirections.Length];

            for (int i = 0; i < writingDirections.Length; ++i)
            {
                numbers [i] = new NSNumber((int)writingDirections [i]);
                ptrs [i]    = numbers [i].Handle;
            }

            var array = CFArray.Create(ptrs);

            CFMutableDictionary.SetValue(Dictionary.Handle, CTStringAttributeKey.WritingDirection.Handle, array);
            GC.KeepAlive(numbers);              // make sure the numbers aren't freed until we're done with them
        }
Example #6
0
        public static NSData GetVCards(params ABPerson[] people)
        {
            if (people == null)
            {
                throw new ArgumentNullException("people");
            }

            var ptrs = new IntPtr [people.Length];

            for (int i = 0; i < people.Length; ++i)
            {
                ptrs[i] = people[i].Handle;
            }

            var ptr = ABPersonCreateVCardRepresentationWithPeople(CFArray.Create(ptrs));

            return(new NSData(ptr, true));
        }
Example #7
0
        public void Create()
        {
            var native = CFArray.Create(array);

            CFString.ReleaseNative(native);              // that's a `CFObject.CFRelease` with a null-check
        }