iosxcodeaddressbookui

Potential Memory leak abaddressbookcopyarrayofallpeople( )


This is function to reload my address book after saving changes, the line

self.addressbook=ABAddressbookCreateWithOptions()

and

self.contactAdd=ABAddressBookCopyArrayOfAllPeople(self.addressBook)

are showing as the potential memory leak points.

contactAdd is of type CFArrayRef and address book is ABAddressBookRef

  -(void)reloadAddressBook
    {
    //   if(self.addressBook)
    //       CFRelease(self.addressBook);
       self.addressBook = ABAddressBookCreateWithOptions(NULL,NULL);
        if(ABAddressBookHasUnsavedChanges(self.addressBook))
        {

            ABAddressBookSave(self.addressBook,NULL);
        }
    //    if(self.contactAdd)
    //        CFRelease(self.contactAdd);

        self.contactAdd=ABAddressBookCopyArrayOfAllPeople(self.addressBook);
    }

Solution

  • use _addressbook instead of self.addressBook.