2

ABRecordRef のソースを見つける必要があります。これは、以下のメソッドが電話帳と icloud から連絡先の配列を返し、その結果、同じ人 (姓名) の連絡先が 2 つあるが、ABRecordID recordId=ABRecordGetRecordID(record) が異なるためです。 );?

ABAddressBookRef addressBook;
if ([self isABAddressBookCreateWithOptionsAvailable]) {
    CFErrorRef error = nil;
    addressBook = ABAddressBookCreateWithOptions(NULL,&error);

    ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {

        dispatch_async(dispatch_get_main_queue(), ^{

            if (error) {

            } else if (!granted) {

            } else {
                CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
                CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);

                for (int i = 0; i < nPeople; i++) {
                    // Get the next address book record.
                    ABRecordRef record = CFArrayGetValueAtIndex(allPeople, i);

                    ABRecordID recordId=ABRecordGetRecordID(record);

                    NSString* firstName = (__bridge_transfer NSString*)ABRecordCopyValue(record,kABPersonFirstNameProperty);
                    NSString* lastName = (__bridge_transfer NSString*)ABRecordCopyValue(record,kABPersonLastNameProperty);

                    CFTypeRef bDayProperty = ABRecordCopyValue((ABRecordRef)record, kABPersonBirthdayProperty);

                    NSDate *birthday;

                    if (ABRecordCopyValue((ABRecordRef)record, kABPersonBirthdayProperty))
                    {
                        birthday=(__bridge NSDate*)bDayProperty;
                    }

                }
                CFRelease(addressBook);

            }
        });
    });
} else {
    // iOS 4/5
    addressBook = ABAddressBookCreate();
    CFRelease(addressBook);
} 
4

1 に答える 1