内存泄漏abaddressbookcopyarrayofallp

内存泄漏abaddressbookcopyarrayofallp

本文介绍了潜在的内存泄漏abaddressbookcopyarrayofallpeople()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此功能是在保存更改(行)之后重新加载我的通讯簿的功能

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

self.addressbook=ABAddressbookCreateWithOptions()

self.contactAdd=ABAddressBookCopyArrayOfAllPeople(self.addressBook)

显示为潜在的内存泄漏点.

are showing as the potential memory leak points.

contactAdd的类型为CFAr r ayRef,地址簿为ABAddressBookRef

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);
    }

推荐答案

使用_addressbook而不是self.addressBook.

use _addressbook instead of self.addressBook.

这篇关于潜在的内存泄漏abaddressbookcopyarrayofallpeople()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 08:01