Mehdi Negahban
Mehdi Negahban

Reputation: 85

application crash on ios 11 when working with AddressBook framework?

I'm working on voip app. fetch contact work but when I want to make call, app crash.

[ABSAddressBook contacts]: message sent to deallocated instance 0x1c1478180 warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.

enter image description here

crash happen in this line.

NSArray *lContacts = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);

    - (void) checkContactListForJogvoiceList {
//    if (![BundleLocalData isLoadingJogvoiceContactList]) {
//        [BundleLocalData setLoadingJogvoiceContactList:true];

        int maxPhoneNumberSubmit = 200;
        NSArray *lContacts = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
        NSMutableDictionary *phoneNumberContactsDictionary = [[NSMutableDictionary alloc] init];
        NSMutableArray *allPhoneNumberList = [[NSMutableArray alloc] init];
        for (id lPerson in lContacts) {
            ABRecordRef person = (ABRecordRef)lPerson;
            NSArray *phoneList = [AppUtil getContactPhoneList:person];
            for (NSString* phoneNumber in phoneList) {
                NSMutableArray* contactList = phoneNumberContactsDictionary[phoneNumber];
                if (!contactList) {
                    contactList = [[NSMutableArray alloc] init];
                }
                [contactList addObject:(__bridge ABRecordRef)person];
                phoneNumberContactsDictionary[phoneNumber] = contactList;
            }
            [allPhoneNumberList addObjectsFromArray:phoneList];

            if (allPhoneNumberList.count >= maxPhoneNumberSubmit) {
                [self checkContactList:allPhoneNumberList phoneNumberContactsDictionary:phoneNumberContactsDictionary];
            }
        }

        if (allPhoneNumberList.count > 0) {
            [self checkContactList:allPhoneNumberList phoneNumberContactsDictionary:phoneNumberContactsDictionary];
        }


        //        ABAddressBookUnregisterExternalChangeCallback(addressBook, sync_address_book, self);

//        [BundleLocalData setLoadingJogvoiceContactList:false];
//    }

}

probably because AddressBook framework deprecate in ios9? am I right? I don’t want to use Contacts framework.

enter image description here

Upvotes: 0

Views: 480

Answers (1)

Shamim Hossain
Shamim Hossain

Reputation: 1760

According to Apple doc ABAddressBookCreateWithOptions using address book function ABAddressBookCreateWithOptions returns NULL if no permission granted from user.

On iOS 6.0 and later, if the caller does not have access to the Address Book database:

  • For apps linked against iOS 6.0 and later, this function returns NULL.
  • For apps linked against previous version of iOS, this function returns an empty read-only database.

You should follow this article How do I correctly use ABAddressBookCreateWithOptions method in iOS 6?

Upvotes: 1

Related Questions