0
  ABMultiValueRef phoneNumbers = ABRecordCopyValue((__bridge  ABRecordRef)([arrTemp1 objectAtIndex:i]),
                                                                 kABPersonPhoneProperty);
                if (ABMultiValueGetCount(phoneNumbers) > 0) {
                    phone = (__bridge_transfer NSString*)
                    ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
                } else
                {
                    phone = @"[None]";
                }

在这行代码之后,我得到“对象泄漏:分配并存储到'phoneNumber'中的对象在此执行路径的后面没有被引用,并且保留计数为+1”。我看到了几个类似的帖子,但没有得到我的问题的确切解决方案。由于这个泄漏,我的应用程序崩溃了。所以有人知道这个请帮助我

4

2 回答 2

1

试试这个代码。

ABMultiValueRef phoneNumbers = ABRecordCopyValue((__bridge  ABRecordRef)([arrTemp1 objectAtIndex:i]),kABPersonPhoneProperty);

if (ABMultiValueGetCount(phoneNumbers) > 0) {
      phone = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
} else {
      phone = @"[None]";
}

CFRelease(phoneNumbers);
于 2013-11-11T07:10:27.507 回答
0

As these objects are CoreFoundation Objects , you should use CFRelease to release the memory being occupied. You must use CFRelease(phoneNumbers); . Checkout the following Link to release the memory occupied by ABMultiValueRef objects.

于 2013-11-11T07:54:41.623 回答