Forum Xamarin.iOS

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

iOS9 Contacts framework not working

Could be I'm missing something, but I can't seem to get anything working with the descriptions given by the contacts framework documentation.

To start with I get a System.Exception thrown when I try to instantiate a CNMutableConact, saying Could not create an native instance of the type 'Contacts.CNMutableContact': the native class hasn't been loaded. I have included the references in my class for both Contacts and ContacsUI.

The example code also throws errors on every new CNLabeledValue() which says it requires more than '1' argument.
Furthermore it won't allow anything like this:

contact.PhoneNumbers = new NSObject[] {cellPhone, workPhone};

As I get yet another error declaring I cannot convert a CNLabeledValue to an NSObject. I'm not sure where my problem lies and there's not a lot of documentation out there yet for ios9 problems.

Thanks!

Posts

  • ChrisShieldsChrisShields SEMember ✭✭

    I seem to be running into issues with NSObject all over the place with the Contacts Framework. I was just trying to access the contacts book exactly as described in the documentation with yet another NSObject error.

    var predicate = CNContact.GetPredicateForContacts("Kate");
    var fetchKey = new NSObject[] { CNContactKey.GivenName };
    var store = new CNContactStore ();
    NSError error;
    var contact = store.GetUnifiedContacts(predicate, fetchKey, out error);

    And I get

    "Error CS0311: The type Foundation.NSObject' cannot be used as type parameterT' in the generic type or method Contacts.CNContactStore.GetUnifiedContacts<T>(Foundation.NSPredicate, T[], out Foundation.NSError)'. There is no implicit reference conversion fromFoundation.NSObject' to `Foundation.INSSecureCoding' (CS0311)

    Am I missing a reference or build setting or what? I can't go forward with anything because of this issue :(

Sign In or Register to comment.