From 9c32b8c3c80de07c5255a33e89f654e12509fbf5 Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Tue, 3 May 2016 10:05:40 -0500 Subject: [PATCH] [Contacts] Fix wrong delegate signature on CNContactStoreEnumerateContactsHandler From PR https://github.com/xamarin/xamarin-macios/pull/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 --- src/contacts.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/contacts.cs b/src/contacts.cs index c90136d80d11..4e086955661d 100644 --- a/src/contacts.cs +++ b/src/contacts.cs @@ -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))] @@ -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);