我有这个代码:
- (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];
静态分析仪说有潜在的泄漏。我知道我需要释放 phoneNumberProperty 但如何?我正在使用 ARC,所以 [phoneNumberProperty release] 不起作用。将其设置为零,它仍然会抱怨。
谢谢您的帮助