How else can you escape the leak of this Core Foundation object?

The following leaks:

CFStringRef labelName = ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(aMultiRef, indexPath.row));
    cell.textLabel.text = (NSString *)labelName;
    CFRelease(labelName);

I wonder if there is a way to rewrite it so that it doesn’t leak without a break and assignment ABMultiValueCopyLabelAtIndex(aMultiRef, indexPath.row)to CFStringRef, which then I need to manually CFRelease2 lines later? Of course, it’s not very important to do just that ... I’m just curious.

Edit: Does it work CFAutoRelease? see my comment below

+3
source share
2 answers

- Copy/Get , API Copy . ABMultiValueCopyLabelAtIndex , , , .

+2

Objective-C ( ). . . [(id) labelName autorelease] ( CFStringRef NSString). CoreFoundation, , Apple , .

0

Source: https://habr.com/ru/post/1736392/


All Articles