Frage

I have this code:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker 
      shouldContinueAfterSelectingPerson:(ABRecordRef)personRecord
                                property:(ABPropertyID)property
                              identifier:(ABMultiValueIdentifier)identifier
{
    //TODO: release phoneNumberProperty when done
    ABMultiValueRef phoneNumberProperty = ABRecordCopyValue(personRecord, kABPersonPhoneProperty);
    int selectedPhNum = ABMultiValueGetIndexForIdentifier(phoneNumberProperty, identifier);//Turns identifier into index
    NSString *txtNum = (NSString *)CFBridgingRelease(ABMultiValueCopyValueAtIndex(phoneNumberProperty, selectedPhNum));
    //NSLog(@"Selected ph num = %@", txtNum);
    [[self toTextField] setText:txtNum];
    phoneNumberProperty = nil;
    [self dismissViewControllerAnimated:YES completion:NULL];

Static analyzer is saying there is a potential leak. I know I need to release the phoneNumberProperty but how? I am using ARC so [phoneNumberProperty release] is not going to work. Setting it to nil and it still complain.

Thanks for the help

War es hilfreich?

Lösung

Use CFRelease function to release your ABMultiValueRef variable:

...
if (phoneNumberProperty)
    CFRelease(phoneNumberProperty);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top