static IntPtr CreateWithCharacters(IntPtr handle, string str, bool autorelease = false)
        {
            unsafe
            {
                fixed(char *ptrFirstChar = str)
                {
        #if MONOMAC
                    handle = Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(handle, selInitWithCharactersLengthHandle, (IntPtr)ptrFirstChar, (IntPtr)str.Length);
        #else
                    handle = Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(handle, Selector.GetHandle(selInitWithCharactersLength), (IntPtr)ptrFirstChar, (IntPtr)str.Length);
        #endif

                    if (autorelease)
                    {
                        NSObject.DangerousAutorelease(handle);
                    }

                    return(handle);
                }
            }
        }
Exemple #2
0
        static IntPtr CreateWithCharacters(IntPtr handle, string str, int offset, int length, bool autorelease = false)
        {
            unsafe
            {
                fixed(char *ptrFirstChar = str)
                {
                    var ptrStart = (IntPtr)(ptrFirstChar + offset);

        #if MONOMAC
                    handle = Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(handle, selInitWithCharactersLengthHandle, ptrStart, (IntPtr)length);
        #else
                    handle = Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(handle, Selector.GetHandle(selInitWithCharactersLength), ptrStart, (IntPtr)length);
        #endif

                    if (autorelease)
                    {
                        NSObject.DangerousAutorelease(handle);
                    }

                    return(handle);
                }
            }
        }