gpt4 book ai didi

ios - Contact Framework 仅抓取少量联系人

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:10:47 25 4
gpt4 key购买 nike

我正在使用联系人框架将所有联系人从我的 iPhone 抓取到我的应用程序中。但它只获取了很少的联系人。这是我使用此代码的代码:

//ios 9+
CNContactStore *store = [[CNContactStore alloc] init];
[store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted == YES) {

NSArray *keys = @[CNContactGivenNameKey,CNContactFamilyNameKey,CNContactPhoneNumbersKey,CNLabelPhoneNumberMobile,CNLabelPhoneNumberMain,CNContactImageDataKey,CNContactIdentifierKey];
NSString *containerId = store.defaultContainerIdentifier;
NSPredicate *predicate = [CNContact predicateForContactsInContainerWithIdentifier:containerId];
NSError *error;
NSArray *cnContacts = [store unifiedContactsMatchingPredicate:predicate keysToFetch:keys error:&error];

}

最佳答案

试试这个:

    [store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) {

if (granted == YES) {

NSArray *keys = @[CNContactGivenNameKey,CNContactFamilyNameKey,CNContactPhoneNumbersKey,CNLabelPhoneNumberMobile,CNLabelPhoneNumberMain,CNContactImageDataKey,CNContactIdentifierKey];
NSError *error;
NSArray *allContainer = [store containersMatchingPredicate:nil error:&error];

for (CNContainer *container in allContainer) {

NSPredicate *predicate = [CNContact predicateForContactsInContainerWithIdentifier:container.identifier];
NSArray *result = [store unifiedContactsMatchingPredicate:predicate keysToFetch:keys error:&error];
[aryAllContacts addObject:result];
}
}
}];

关于ios - Contact Framework 仅抓取少量联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43884464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com