應用代碼如下:
用來過濾和篩選
- (long)personRecord:(ABRecordRef)paramPerson{
if(paramPerson == nil){
NSLog(@"The given Person is Null");
}
ABMutableMultiValueRef emails = ABRecordCopyValue(paramPerson, kABPersonEmailProperty);
if(emails == nil){
return 0;
}
NSLog(@"%ld",ABMultiValueGetCount(emails));
// return (ABMultiValueGetCount(emails));
return (ABMultiValueGetCount(emails));
}
但是當解析的時候出現:
怎麼解決這個Leak?
你是從ABRecordRef中獲得了一份復制的object.釋放一下
修改為如下方法:
- (long)personRecord:(ABRecordRef)paramPerson
{
if(paramPerson == nil)
{
NSLog(@"The given Person is Null");
}
ABMutableMultiValueRef emails = ABRecordCopyValue(paramPerson, kABPersonEmailProperty);
if(emails == nil)
{
return 0;
}
NSLog(@"%ld",ABMultiValueGetCount(emails));
// return (ABMultiValueGetCount(emails));
long count = ABMultiValueGetCount(emails);
CFRelease(emails);
return count;
}