-1
我正在分析在Xcode解決潛在的內存泄漏
//Getting memeory leak warning here "Potential leak of an object allocated and stored into 'phones'
ABMultiValueRef phones = ABRecordCopyValue(ref, kABPersonPhoneProperty);
//Getting potential leak error for line below
if (ABMultiValueGetCount(ABRecordCopyValue(ref, kABPersonPhoneProperty))!=0)
{
//Getting potential leak error for line below
CFStringRef pNumber = ABMultiValueCopyValueAtIndex(phones,0);
phoneNumber = [NSString stringWithFormat:@"%@", (NSString *)pNumber];
NSString *contactFirstLast = [NSString stringWithFormat: @"%@ %@", firstName, lastName];
}
工具,我怎樣才能解決這些泄漏後得到以下memeory泄漏?
謝謝!但是,如果(ABMultiValueGetCount(ABRecordCopyValue(ref,kABPersonPhoneProperty))!= 0)泄漏怎麼辦?'? – Zhen
就像我說的。沒有必要爲了計算它們而創建新的值。使用'phones'中已有的一個 - 和該代碼片段末尾的'CFRelease(phones)'。 –