Zhe*_*hen -1 memory-leaks objective-c core-foundation abaddressbook ios
在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];
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这些泄漏?
ABMultiValueRef phones = ABRecordCopyValue(ref, kABPersonPhoneProperty);
if (ABMultiValueGetCount(phones) != 0)
{
CFStringRef pNumber = ABMultiValueCopyValueAtIndex(phones,0);
phoneNumber = [NSString stringWithFormat:@"%@", (NSString *)pNumber];
NSString *contactFirstLast = [NSString stringWithFormat: @"%@ %@", firstName, lastName];
CFRelease(pNumber);
}
CFRelease(phones);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1785 次 |
| 最近记录: |