我在项目中使用ARC,并在以下情况下被警告潜在的内存泄漏(请参阅注释行)。不确定如何处理。
-( BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
ABMultiValueRef phoneProperty = ABRecordCopyValue(person,property);
// Call to function 'ABRecordCopyValue' returns a Core Foundation object with a +1 retain count
int idx = ABMultiValueGetIndexForIdentifier (phoneProperty, identifier);
emailToValue= (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(phoneProperty,idx);
// Object Leaked: object allocated and stored into 'phoneProperty' is not referenced later in this execution path and has a retain count of +1
任何意见,将不胜感激。
提前致谢。
最佳答案
ARC仅管理Objective-C对象的内存,因此应用程序需要使用phoneProperty
释放ABRecordCopyValue
返回的Copy
(方法中的CFRelease
表示已保留)。
关于ios - 使用ARC的peoplePicker内存泄漏,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8753947/