0

I have a problem about import contacts from contacts list. It is cause of crash app. Here is my code:

        GKAddressBook *addressBook = [[GKAddressBook alloc] init];
        ABAddressBookRequestAccessWithCompletion(addressBook.addressBookRef, ^(bool granted, CFErrorRef error) {

            dispatch_async(dispatch_get_main_queue(), ^{
                if (granted) {
                    UINavigationController *nav = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactsPickerNavigationController"];
                    PDContactsPicker *picker = nav.viewControllers.firstObject;
                    picker.addressBook = addressBook;
                    picker.didSelectContactBlock = ^(GKContact *contact) {
                        ViewControllerA *viewControllerA = [weakSelf.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerA"];

                        viewControllerA.contact = contact;
                        viewControllerA.completeBlock = ^(id result) {
                        weakSelf.segmentedControl.selectedSegmentIndex = 0;
                        weakSelf.selectedIcon = 0;
                        [weakSelf reloadTableView];
                        [weakSelf presentViewController:[[PortraitNavigationController alloc] initWithRootViewController:editVC] animated:YES completion:nil];
                    };
                    [self presentViewController:nav animated:YES completion:nil];
                }

            });
        });

Log not show. It jump to thread like screenshot. enter image description here

I run on iPhone 6s and iOS 10.1. Someone please help me to solve this problem. You will save a lot of ton time in my life. Thank.

Cuong Nguyen
  • 980
  • 2
  • 9
  • 29

2 Answers2

0

Thanks all for helps me to solve this problem. However, the bug was solved. I only need add key NSContactsUsageDescription into file .plist. It works well.

Cuong Nguyen
  • 980
  • 2
  • 9
  • 29
0

ADD THIS IN INFO PLIST

Privacy - Contacts Usage Description

AND

NSCalendarUsageDescription
Dishant Rajput
  • 1,329
  • 1
  • 10
  • 20