ABRecordCopyValue()SIGSEGV

Tim*_*cht 1 iphone calendar addressbook abrecord

我目前正在从地址簿中提取所有联系人,并希望保存我遇到特定联系人的最后日期.因此,我在同一时间获取日历如下:

for (EKEvent* event in events) {
            for (EKParticipant* attende in [event attendees]) {
                ABRecordRef record = [attende ABRecordWithAddressBook:addressBook];
                if([contact.name isEqualToString:[NSString stringWithFormat:@"%@ %@", (__bridge NSString *)ABRecordCopyValue(record, kABPersonFirstNameProperty), (__bridge NSString *)ABRecordCopyValue(record, kABPersonLastNameProperty)]]){
                        contact.lastMet = [NSString stringWithFormat:@"%@",[formatter stringFromDate:event.endDate]];
                    }

            }

        }
Run Code Online (Sandbox Code Playgroud)

遗憾的是,代码在信号SIGSEGV的"if"-statement行崩溃,崩溃日志表明ABRecordCopyValue()发生故障...有任何建议如何解决这个问题?

Abd*_*man 5

因为你没有发布完整的代码我自己无法调试问题.但我认为答案是由ikuragames在评论中给出的.崩溃的最可能原因是,执行代码时可能是记录为空.调试代码并检查记录和kABPersonFirstNameProperty的值.如果我是对的那么您必须为记录分配一些初始值或根据需要更改您的代码.如果它没有解决您的问题,请发布调试信息,并进行一些深入的描述.

:)

感谢你..