From b2ee1b879ef1b2eab56e313031d836e50b5eadd8 Mon Sep 17 00:00:00 2001 From: Ivan Trufanov Date: Sat, 2 Nov 2013 22:18:01 +0400 Subject: [PATCH 1/2] Checking granting of access in main thread (Important for good work) --- .../Controllers/TKPeoplePickerController.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/TKContactPicker/Controllers/TKPeoplePickerController.m b/TKContactPicker/Controllers/TKPeoplePickerController.m index cb6424b..7abb021 100755 --- a/TKContactPicker/Controllers/TKPeoplePickerController.m +++ b/TKContactPicker/Controllers/TKPeoplePickerController.m @@ -64,11 +64,13 @@ - (id)initPeoplePicker switch (ABAddressBookGetAuthorizationStatus()) { case kABAuthorizationStatusNotDetermined: { ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) { - if (granted) { - [self presentContactsMultiPickerController]; - } else { - [self presentNoContactViewController]; - } + dispatch_sync(dispatch_get_main_queue(), ^(){ + if (granted) { + [self presentContactsMultiPickerController]; + } else { + [self presentNoContactViewController]; + } + }); }); } break; case kABAuthorizationStatusAuthorized: { From 01758b014be13b4adda62e1ed08dad8396546e9e Mon Sep 17 00:00:00 2001 From: Ivan Trufanov Date: Sat, 2 Nov 2013 22:19:22 +0400 Subject: [PATCH 2/2] Added new method for creating Address Book (Old deprecated) --- TKContactPicker/Controllers/TKPeoplePickerController.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/TKContactPicker/Controllers/TKPeoplePickerController.m b/TKContactPicker/Controllers/TKPeoplePickerController.m index 7abb021..3d49df1 100755 --- a/TKContactPicker/Controllers/TKPeoplePickerController.m +++ b/TKContactPicker/Controllers/TKPeoplePickerController.m @@ -44,7 +44,11 @@ - (void)presentNoContactViewController - (void)presentContactsMultiPickerController { - _addressBook = ABAddressBookCreate(); + if (IOS_VERSION_LESS_THAN(@"6.0")) { + _addressBook = ABAddressBookCreate(); + } else { + _addressBook = ABAddressBookCreateWithOptions(NULL, NULL); + } TKContactsMultiPickerController *contactMultiController = [[TKContactsMultiPickerController alloc] initWithGroup:nil]; contactMultiController.delegate = self;