Search code examples
iosobjective-cmemory-leakscontactsabaddressbook

MachMessagePort error when requesting access to address book


I am trying to load a few contacts from the address book.

I create the address book in viewDidLoad and check for authorisation

if (!_addressBook) {
      CFErrorRef error=NULL;
      _addressBook=ABAddressBookCreateWithOptions(NULL, &error);
    }

I then release it in dealloc

if (_addressBook) {
        CFRelease(_addressBook);
        _addressBook = NULL;
    }

But I still get the following error.

Error, could not create MachMessagePort for database doctor (com.apple.ABDatabaseDoctor)

Is it due to a problem in memory allocation, permissions, or something else entirely?


Solution

  • I know this is almost six months late, but I recall that I eventually fixed the problem simply by resetting the location & privacy settings in Settings > General > Reset, turning off Contacts access in the application settings and then turning it back on. When it launched, it requested for authorisation again, after which it worked. So that might be a quick fix for anyone else facing the same issue.

    If anyone can enlighten me on why this worked, that would be great.