我在访问用户的地址簿时遇到问题。我的代码是
ABMultiValueRef email = ABRecordCopyValue(aSource, kABPersonEmailProperty);
NSString* email_lbl;
for(CFIndex i = 0; i < ABMultiValueGetCount(email); i++) {
email_lbl = (NSString*)ABMultiValueCopyLabelAtIndex(email, i);
if([email_lbl isEqualToString:(NSString *)kABHomeLabel])
{
home_email = [(NSString*)ABMultiValueCopyValueAtIndex(email, i)retain];
}
if([email_lbl isEqualToString:(NSString *)kABWorkLabel])
{
work_email = [(NSString*)ABMultiValueCopyValueAtIndex(email, i)retain];
}
if([email_lbl isEqualToString:(NSString *)kABOtherLabel])
{
basic_email = [(NSString*)ABMultiValueCopyValueAtIndex(email, i)retain];
}
}
当我记录home_email,work_email,basic_email时收到Exc_bad_access信号。
答案 0 :(得分:0)
我找到了解决这个问题的方法。我声明了home_email,work_email,basic_email但没有初始化它们,当我在日志中打印它们时,它们没有被初始化。 这解决了我的问题。