내 앱은 연락처의 AddressBook recordIds를 동일한 이름으로 저장 한 다음 나중에 사용자에게 주소를 제시하여 원하는 사람을 선택하려고합니다. 그러나 ABAddressBookGetPersonWithRecordID 함께 저장된 recordIds 사용할 때 nil을 반환합니다. 아래 코드는 코드 프로젝트를 나타냅니다. 나중에 레코드를 저장하는 코드 바로 아래에서 연락처를 검색하려고 시도하는 코드를 "복사"했습니다. 모두, 그때 IDS (143) 및 (305)와 ABAddressBookGetPersonWithRecordID을 시도 할 때 IDS (143)와 305 만 -ABAddressBookGetPersonWithRecordID return nil
NSString *full = person.compositeName;
CFArrayRef contacts = ABAddressBookCopyPeopleWithName(addressBook, (__bridge CFStringRef)(full));
CFIndex nPeople = CFArrayGetCount(contacts);
if (nPeople)
{
NSMutableArray *rIds = [[NSMutableArray alloc] init];
int numberOfContactsMatchingName = (int)CFArrayGetCount(contacts);
if (numberOfContactsMatchingName>1)
{
for (int i=0; i<numberOfContactsMatchingName; ++i)
{
ABRecordID thisId = ABRecordGetRecordID(CFArrayGetValueAtIndex(contacts, i));
NSNumber *rid = [NSNumber numberWithInteger:thisId];
FLOG(@"%d Matched, this ID = %@", numberOfContactsMatchingName, rid);
[rIds addObject:rid];
}
for (int i=0; i<rIds.count; ++i)
{
//contactRecord = ABAddressBookGetPersonWithRecordID(addressBook, (ABRecordID)recId);
ABRecordRef contactRecord;
contactRecord = ABAddressBookGetPersonWithRecordID(addressBook, rIds[i]);
if (contactRecord)
{
}
else
{
FLOG (@"Noone found with recordId %@", rIds[i]);
}
}
그래서, 예를 들어, 난 그냥이 실행, 그것은 동일한 이름을 가진 주소록이 연락처를 발견 반환 된 nil. 내가 뭘 잘못 알아 냈어?
물론 - 내 어리 석다. 나는 컴파일러가 그것에 대해 경고를 할 수 있었는지 궁금하지만, NSNumber의 주소를 사용하고 int로 취급한다고 가정합니다. 당신의 도움을 주셔서 감사합니다. – guinnessman