/// <summary> /// Returns a Boolean value that indicates whether the enumeration of /// all contacts matching a contact fetch request executed successfully. /// </summary> /// <returns><c>true</c>, if contacts with fetch request was enumerated, <c>false</c> otherwise.</returns> /// <param name="fetchRequest">Fetch request.</param> /// <param name="error">Error.</param> /// <param name="block">Block.</param> public bool EnumerateContactsWithFetchRequest(CNContactFetchRequest fetchRequest, out NSError error, EnumerateContactsWithFetchRequestBlock block) { Util.NullArgumentTest(fetchRequest); Util.NullArgumentTest(block); IntPtr errorPtr = new IntPtr(); bool success = C.CNContactStore_enumerateContactsWithFetchRequest( SelfPtr(), fetchRequest.ToPointer(), ref errorPtr, InternalEnumerateContactsBlock, PInvokeCallbackUtil.ToIntPtr((CNContact contact) => { bool shouldStop; block(contact, out shouldStop); return(shouldStop); })); error = null; if (PInvokeUtil.IsNotNull(errorPtr)) { error = new NSError(errorPtr); CFFunctions.CFRelease(errorPtr); // balance out ref count of a pointer returned directly from native side. } return(success); }
/// <summary> /// Fetches a unified contact for the specified contact identifier. /// </summary> /// <returns>The contact with identifier.</returns> /// <param name="identifier">Identifier.</param> /// <param name="keys">Keys.</param> /// <param name="error">Error.</param> public CNContact UnifiedContactWithIdentifier(NSString identifier, NSArray <NSString> keys, out NSError error) { Util.NullArgumentTest(identifier); Util.NullArgumentTest(keys); IntPtr errorPtr = new IntPtr(); var contactPtr = C.CNContactStore_unifiedContactWithIdentifier( SelfPtr(), identifier.ToPointer(), keys.ToPointer(), ref errorPtr); error = null; if (PInvokeUtil.IsNotNull(errorPtr)) { error = new NSError(errorPtr); CFFunctions.CFRelease(errorPtr); } CNContact contact = null; if (PInvokeUtil.IsNotNull(contactPtr)) { contact = new CNContact(contactPtr); CFFunctions.CFRelease(contactPtr); } return(contact); }
/// <summary> /// Fetches all unified contacts matching the specified predicate. /// </summary> /// <returns>The contacts matching predicate.</returns> /// <param name="predicate">Predicate.</param> /// <param name="keys">Keys.</param> /// <param name="error">Error.</param> public NSArray <CNContact> UnifiedContactsMatchingPredicate(NSPredicate predicate, NSArray <NSString> keys, out NSError error) { Util.NullArgumentTest(predicate); Util.NullArgumentTest(keys); IntPtr errorPtr = new IntPtr(); var contactsPtr = C.CNContactStore_unifiedContactsMatchingPredicate( SelfPtr(), predicate.ToPointer(), keys.ToPointer(), ref errorPtr); error = null; if (PInvokeUtil.IsNotNull(errorPtr)) { error = new NSError(errorPtr); CFFunctions.CFRelease(errorPtr); } NSArray <CNContact> contacts = null; if (PInvokeUtil.IsNotNull(contactsPtr)) { contacts = new NSArray <CNContact>(contactsPtr); CFFunctions.CFRelease(contactsPtr); } return(contacts); }
internal GKInviteEventListenerForwarder() : this(C.GKInviteEventListener_new( InternalDidAcceptInviteCallback, InternalDidRequestMatchWithRecipientsCallback)) { // We're using a pointer returned by a native constructor: call CFRelease to balance native ref count CFFunctions.CFRelease(this.ToPointer()); }
/// <summary> /// Returns the object located at the specified index. /// </summary> /// <returns>The at index.</returns> /// <param name="index">Index.</param> /// <param name="constructor">Constructor.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public T ObjectAtIndex(uint index, Func <IntPtr, T> constructor) { IntPtr ptr = C.NSArray_objectAtIndex(SelfPtr(), index); T obj = constructor(ptr); CFFunctions.CFRelease(ptr); // release pointer returned by native method to balance ref count return(obj); }
/// <summary> /// Creates and returns an NSMutableArray object with enough allocated memory /// to initially hold a given number of objects. /// </summary> /// <returns>The with capacity.</returns> /// <param name="numItems">Number items.</param> public static NSMutableArray <T> ArrayWithCapacity(uint numItems) { var ptr = C.NSMutableArray_arrayWithCapacity(numItems); var mutArray = new NSMutableArray <T>(ptr); CFFunctions.CFRelease(ptr); return(mutArray); }
internal UIImagePickerControllerDelegateForwarder() : this(C.UIImagePickerControllerDelegateForwarder_new( InternalUIDidFinishPickingMediaWithInfoCallback, InternalUIDidCancelCallback)) { // We're using a pointer returned by a native constructor: call CFRelease to balance native ref count CFFunctions.CFRelease(this.ToPointer()); }
internal GKTurnBasedMatchmakerViewControllerDelegateForwarder() : this(C.GKTurnBasedMatchmakerViewControllerDelegate_new( InternalWasCancelledCallback, InternalDidFailWithErrorCallback, null /* didFindMatch is obsolete so we'll ignore it */)) { // We're using a pointer returned by a native constructor: call CFRelease to balance native ref count CFFunctions.CFRelease(this.ToPointer()); }
internal UIAdaptivePresentationControllerDelegateForwarder() : this(C.UIAdaptivePresentationControllerDelegate_new( InternalPresentationControllerDidAttemptToDismissCallback, InternalPresentationControllerShouldDismissCallback, InternalPresentationControllerDidDismissCallback, InternalPresentationControllerWillDismissCallback)) { // We're using a pointer returned by a native constructor: call CFRelease to balance native ref count CFFunctions.CFRelease(this.ToPointer()); }
internal GKTurnBasedEventListenerForwarder() : this(C.GKTurnBasedEventListener_new( InternalDidRequestMatchWithOtherPlayersCallback, InternalMatchEndedCallback, InternalReceivedTurnEventForMatchCallback, InternalWantsToQuitMatchCallback)) { // We're using a pointer returned by a native constructor: call CFRelease to balance native ref count CFFunctions.CFRelease(this.ToPointer()); }
internal CNContactPickerDelegateForwarder() : this(C.CNContactPickerDelegateForwarder_new( InternalContactPickerDidCancelCallback, InternalContactPickerDidSelectContactCallback, InternalContactPickerDidSelectContactPropertyCallback, InternalContactPickerDidSelectContactsCallback, InternalContactPickerDidSelectContactPropertiesCallback)) { // We're using a pointer returned by a native constructor: call CFRelease to balance native ref count CFFunctions.CFRelease(this.ToPointer()); }
internal GKMatchmakerViewControllerDelegateForwarder() : this(C.GKMatchmakerViewControllerDelegate_new( InternalMatchmakerViewControllerDidFindMatchCallback, InternalMatchmakerViewControllerDidFindHostedPlayersCallback, InternalMatchmakerViewControllerWasCancelledCallback, InternalMatchmakerViewControllerDidFailWithErrorCallback, InternalMatchmakerViewControllerHostedPlayerDidAcceptCallback)) { // We're using a pointer returned by a native constructor: call CFRelease to balance native ref count CFFunctions.CFRelease(this.ToPointer()); }
internal GKMatchDelegateForwarder() : this(C.GKMatchDelegate_new( InternalMatchDidReceiveDataForRecipientCallback, InternalMatchDidReceiveDataCallback, InternalPlayerDidChangeConnectionStateCallback, InternalMatchDidFailWithErrorCallback, InternalShouldReinviteDisconnectedPlayerCallback)) { // We're using a pointer returned by a native constructor: call CFRelease to balance native ref count CFFunctions.CFRelease(this.ToPointer()); }
/// <summary> /// Returns the required key descriptor for the specified formatting style of the contact. /// </summary> /// <returns>The for required keys for style.</returns> /// <param name="style">Style.</param> public static CNKeyDescriptor DescriptorForRequiredKeysForStyle(CNContactFormatterStyle style) { InternalCNKeyDescriptor keyDesc = null; var ptr = C.CNContactFormatter_descriptorForRequiredKeysForStyle(style); if (PInvokeUtil.IsNotNull(ptr)) { keyDesc = new InternalCNKeyDescriptor(ptr); CFFunctions.CFRelease(ptr); } return(keyDesc); }
/// <summary> /// Returns a new instance that’s a mutable copy of the receiver. /// </summary> /// <returns>The copy.</returns> public CNMutableContact MutableCopy() { CNMutableContact mutCopy = null; var ptr = C.CNContact_mutableCopy(SelfPtr()); if (PInvokeUtil.IsNotNull(ptr)) { mutCopy = new CNMutableContact(ptr); CFFunctions.CFRelease(ptr); } return(mutCopy); }
/// <summary> /// Creates and returns a predicate that always evaluates to a given Boolean value. /// </summary> /// <returns>The with value.</returns> /// <param name="value">If set to <c>true</c> value.</param> public static NSPredicate PredicateWithValue(bool value) { NSPredicate predicate = null; var ptr = C.NSPredicate_predicateWithValue(value); if (PInvokeUtil.IsNotNull(ptr)) { predicate = new NSPredicate(ptr); CFFunctions.CFRelease(ptr); } return(predicate); }
internal GKLocalPlayerListenerForwarder(GKInviteEventListenerForwarder inviteEventListenerForwarder, GKTurnBasedEventListenerForwarder turnBasedEventListenerForwarder) : this(C.GKLocalPlayerListener_new( inviteEventListenerForwarder != null ? inviteEventListenerForwarder.ToPointer() : IntPtr.Zero, turnBasedEventListenerForwarder != null ? turnBasedEventListenerForwarder.ToPointer() : IntPtr.Zero)) { // We're using a pointer returned by a native constructor: call CFRelease to balance native ref count CFFunctions.CFRelease(this.ToPointer()); // Store the sub-forwarders. this.mInviteEventListenerForwarder = inviteEventListenerForwarder; this.mTurnBasedEventListenerForwarder = turnBasedEventListenerForwarder; }
/// <summary> /// Get the contact property value. /// </summary> /// <param name="constructor">Constructor to create object of type <see cref="T"/>.</param> public T GetValue(Func <IntPtr, T> constructor) { if (mValue == null) { var ptr = C.CNLabeledValue_value(SelfPtr()); if (PInvokeUtil.IsNotNull(ptr)) { mValue = constructor(ptr); CFFunctions.CFRelease(ptr); } } return(mValue); }
/// <summary> /// Creates a NSString object from a pointer and release that pointer if required. /// </summary> /// <returns>The pointer.</returns> /// <param name="ptr">Ptr.</param> /// <param name="releasePointer">If set to <c>true</c> release pointer.</param> internal static NSString FromPointer(IntPtr ptr, bool releasePointer) { if (PInvokeUtil.IsNull(ptr)) { return(null); } var str = new NSString(ptr); if (releasePointer) { CFFunctions.CFRelease(ptr); } return(str); }
/// <summary> /// Creates a NSURL object from a pointer and release that pointer if required. /// </summary> /// <returns>The NSURL object.</returns> /// <param name="pointer">Pointer.</param> /// <param name="releasePointer">If set to <c>true</c> release pointer.</param> internal static NSURL FromPointer(IntPtr pointer, bool releasePointer) { if (PInvokeUtil.IsNotNull(pointer)) { var newURL = new NSURL(pointer); if (releasePointer) { CFFunctions.CFRelease(pointer); } return(newURL); } else { return(null); } }
/// <summary> /// Creates a NSArray object from a pointer and release the pointer if required. /// </summary> /// <returns>The NSArray object.</returns> /// <param name="pointer">Pointer.</param> /// <param name="releasePointer">If set to <c>true</c> release pointer.</param> internal static NSArray <T> FromPointer(IntPtr pointer, bool releasePointer) { if (PInvokeUtil.IsNotNull(pointer)) { var obj = new NSArray <T>(pointer); if (releasePointer) { CFFunctions.CFRelease(pointer); } return(obj); } else { return(null); } }
/// <summary> /// Executes a save request and returns success or failure. /// </summary> /// <returns><c>true</c>, if save request was executed, <c>false</c> otherwise.</returns> /// <param name="saveRequest">Save request.</param> /// <param name="error">Error.</param> public bool ExecuteSaveRequest(CNSaveRequest saveRequest, out NSError error) { Util.NullArgumentTest(saveRequest); IntPtr errorPtr = new IntPtr(); bool success = C.CNContactStore_executeSaveRequest(SelfPtr(), saveRequest.ToPointer(), ref errorPtr); error = null; if (PInvokeUtil.IsNotNull(errorPtr)) { error = new NSError(errorPtr); CFFunctions.CFRelease(errorPtr); // balance out ref count of a pointer returned directly from native side. } return(success); }
/// <summary> /// Returns the delimiter to use between name components. /// </summary> /// <returns>The for contact.</returns> /// <param name="contact">Contact.</param> public static NSString DelimiterForContact(CNContact contact) { if (contact == null) { return(null); } NSString str = null; var ptr = C.CNContactFormatter_delimiterForContact(contact.ToPointer()); if (PInvokeUtil.IsNotNull(ptr)) { str = new NSString(ptr); CFFunctions.CFRelease(ptr); } return(str); }
/// <summary> /// Returns the contact name, formatted with the specified formatter. /// </summary> /// <returns>The from contact.</returns> /// <param name="contact">Contact.</param> /// <param name="style">Style.</param> public static NSString StringFromContact(CNContact contact, CNContactFormatterStyle style) { if (contact == null) { return(null); } NSString str = null; var ptr = C.CNContactFormatter_stringFromContact(contact.ToPointer(), style); if (PInvokeUtil.IsNotNull(ptr)) { str = new NSString(ptr); CFFunctions.CFRelease(ptr); } return(str); }
/// <summary> /// Creates and returns a new predicate formed by creating a new string with a given format and parsing the result. /// </summary> /// <returns>The with format.</returns> /// <param name="predicateFormat">Predicate format.</param> public static NSPredicate PredicateWithFormat(NSString predicateFormat) { if (predicateFormat == null) { return(null); } NSPredicate predicate = null; var ptr = C.NSPredicate_predicateWithFormat(predicateFormat.ToPointer()); if (PInvokeUtil.IsNotNull(ptr)) { predicate = new NSPredicate(ptr); CFFunctions.CFRelease(ptr); } return(predicate); }
/// <summary> /// Returns a string containing the localized contact property name. /// </summary> /// <returns>The localized string.</returns> /// <param name="key">A string containing the contact property key.</param> public NSString LocalizedStringForKey(NSString key) { if (key == null) { return(null); } NSString localizedStr = null; var ptr = C.CNContact_localizedStringForKey(key.ToPointer()); if (PInvokeUtil.IsNotNull(ptr)) { localizedStr = new NSString(ptr); CFFunctions.CFRelease(ptr); } return(localizedStr); }
/// <summary> /// Returns the localized name for the property associated with the specified key. /// </summary> /// <returns>The string for key.</returns> /// <param name="key">Key.</param> public static NSString LocalizedStringForKey(NSString key) { if (key == null) { return(null); } var ptr = C.CNPostalAddress_localizedStringForKey(key.ToPointer()); NSString localizedStr = null; if (PInvokeUtil.IsNotNull(ptr)) { localizedStr = new NSString(ptr); CFFunctions.CFRelease(ptr); } return(localizedStr); }
/// <summary> /// Returns a new labeled value identifier object with the specified label and value. /// </summary> /// <returns>The value with label.</returns> /// <param name="label">Label.</param> /// <param name="value">Value.</param> public static CNLabeledValue <T> LabeledValueWithLabel(NSString label, T value) { if (value == null) { return(null); } var ptr = C.CNLabeledValue_labeledValueWithLabel(label == null ? IntPtr.Zero : label.ToPointer(), value.ToPointer()); CNLabeledValue <T> instance = null; if (PInvokeUtil.IsNotNull(ptr)) { instance = new CNLabeledValue <T>(ptr); CFFunctions.CFRelease(ptr); } return(instance); }
/// <summary> /// The designated initializer for a fetch request that uses the specified keys. /// </summary> /// <returns>The with keys to fetch.</returns> /// <param name="keysToFetch">Keys to fetch.</param> public static CNContactFetchRequest InitWithKeysToFetch(NSArray <NSString> keysToFetch) { if (keysToFetch == null) { return(null); } // This will automatically call alloc on native side before calling the init method. var ptr = C.CNContactFetchRequest_initWithKeysToFetch(keysToFetch.ToPointer()); CNContactFetchRequest request = null; if (PInvokeUtil.IsNotNull(ptr)) { request = new CNContactFetchRequest(ptr); CFFunctions.CFRelease(ptr); } return(request); }
/// <summary> /// Returns a new phone number object initialized with the specified phone number string. /// </summary> /// <returns>The phone number</returns> /// <param name="value">A string value with which to initialize phone number object.</param> public static CNPhoneNumber PhoneNumberWithStringValue(string value) { if (string.IsNullOrEmpty(value)) { return(null); } var ptr = C.CNPhoneNumber_phoneNumberWithStringValue(value); if (PInvokeUtil.IsNotNull(ptr)) { var cnPhoneNumber = new CNPhoneNumber(ptr); CFFunctions.CFRelease(ptr); // release pointer returned by the native method. return(cnPhoneNumber); } else { return(null); } }