주소록에서 처음 100 개의 연락처를 가져 오려고합니다. 내가 한 것은 모든 연락처를 얻는 것이고 처음에는 100 개를 얻으려고했습니다. 그 이유는 (아래 코드) 작동하지 않습니다.주소록 하위 배열 얻기
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef allContacts = ABAddressBookCopyArrayOfAllPeople(addressBook);
NSRange theRange;
theRange.location = 0;
theRange.length = 100;
CFArrayRef allContactsNew = (CFArrayRef)[(NSMutableArray *)allContacts subarrayWithRange:theRange];//This gets an error
도움을 주시면 감사하겠습니다. 또한 주소록에서 처음으로 100 개 정도만 가져 오는 다른 방법을 알고 있으면 도움이 될 수 있습니다.
theRange.length = MIN(100, CFArrayGetCount(allContacts)); //avoid array out of bounds errors
CFArrayRef allContactsNew = CFBridgingRetain([(NSArray *)CFBridgingRelease(allContacts) subarrayWithRange:theRange]); //Add CFBridging functions recommended by Xcode
오류가 무엇입니까 : 나는 이러한 변경을 할 때 –
일부 런타임 오류. 어쨌든 SSteve가이를 해결합니다. 감사! – Idan