Skip to content

Commit

Permalink
[Contacts] Fix wrong delegate signature on CNContactStoreEnumerateCon…
Browse files Browse the repository at this point in the history
…tactsHandler

xamarin#19

From PR 19:

The signature on  `CNContactStoreEnumerateContactsHandler` should
include a `ref`on the `bool stop` parameter in order to have the
ability to early exit the enumeration.

Ref: http://stackoverflow.com/questions/36992982/early-exit-a-cncontactstoreenumeratecontactshandler-enumeration
  • Loading branch information
dalexsoto committed May 3, 2016
1 parent 24e1e29 commit 4fadd21
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/contacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,10 @@ public interface CNLabelContactRelationKey {
}

public delegate void CNContactStoreRequestAccessHandler (bool granted, NSError error);
#if !XAMCORE_4_0
public delegate void CNContactStoreEnumerateContactsHandler (CNContact contact, bool stop);
#endif
public delegate void CNContactStoreListContactsHandler (CNContact contact, ref bool stop);

[iOS (9,0), Mac (10,11, onlyOn64: true)]
[BaseType (typeof (NSObject))]
Expand All @@ -441,9 +444,16 @@ public interface CNContactStore {
[Protected] // we cannot use ICNKeyDescriptor as Apple (and others) can adopt it from categories
NSObject GetUnifiedMeContact (NSArray keys, out NSError error);

#if !XAMCORE_4_0
[Obsolete ("Use the overload that takes CNContactStoreListContactsHandler instead")]
[Export ("enumerateContactsWithFetchRequest:error:usingBlock:")]
bool EnumerateContacts (CNContactFetchRequest fetchRequest, out NSError error, CNContactStoreEnumerateContactsHandler handler);

[Sealed] // We will introduce breaking changes anyways if XAMCORE_4_0 happens
#endif
[Export ("enumerateContactsWithFetchRequest:error:usingBlock:")]
bool EnumerateContacts (CNContactFetchRequest fetchRequest, out NSError error, CNContactStoreListContactsHandler handler);

[Export ("groupsMatchingPredicate:error:")]
CNGroup [] GetGroups ([NullAllowed] NSPredicate predicate, out NSError error);

Expand Down

0 comments on commit 4fadd21

Please sign in to comment.