2012-01-06 64 views
0

我在我的項目中使用ARC,並在以下內容中發現潛在的內存泄漏(請參閱註釋行)。不知道如何處理它。people使用ARC的Picker內存泄漏

-(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 

任何意見,將不勝感激。

在此先感謝。

回答

3

ARC只管理內存Objective-C對象,通過ABRecordCopyValue所以phoneProperty返回(該方法中的Copy表明它一直保留)需要使用CFRelease您的應用程序發佈。

2

無論是否使用ARC,您都必須自己處理CFMemory。 離開前添加以下代碼:

if (phoneProperty){ 
CFRelease(phoneProperty); 
}