我在我的项目中使用了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任何建议都将不胜感激。
提前谢谢。
发布于 2012-01-06 14:10:17
ARC只管理Objective-C对象的内存,因此您的应用需要使用CFRelease释放ABRecordCopyValue返回的phoneProperty (方法中的Copy表示它已被保留)。
发布于 2012-02-03 15:46:10
无论是否使用ARC,你们都必须自己处理CFMemory。在离开之前添加以下代码:
if (phoneProperty){
CFRelease(phoneProperty);
}https://stackoverflow.com/questions/8753947
复制相似问题