gpt4 book ai didi

iphone - 无法从 iPhone 获取联系人

转载 作者:行者123 更新时间:2023-11-28 18:38:14 25 4
gpt4 key购买 nike

我试图获取保存在联系人中的所有电子邮件,我能够在 ipod 中获取邮件,但是当我在 iphone 上测试时它显示数组为空。但是我的 iphone 中有联系人

为什么会这样?

 -(IBAction)contactfriends:(id)sender
{
ABAddressBookRef _addressBookRef = ABAddressBookCreate();
NSArray* allPeople = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeople(_addressBookRef);

NSMutableDictionary *contactsInformation = [[NSMutableDictionary alloc] initWithCapacity:[allPeople count]];
NSMutableArray *propertyList = [[NSMutableArray alloc] init];

NSLog(@"property lsit %@",propertyList); // I am getting this null
NSLog(@"all people %@",allPeople); // I am getting this null


for (id record in allPeople)
{
CFTypeRef emailProp = ABRecordCopyValue((__bridge ABRecordRef)record, kABPersonEmailProperty);
NSString *email = [((__bridge NSArray *)ABMultiValueCopyArrayOfAllValues(emailProp)) objectAtIndex:0 ];
if (!email) {
email = @"";
}
[propertyList addObject:email];

}

NSLog(@"property lsit %@",propertyList); // I am getting this null

最佳答案

试试这个:

    ABAddressBookRef addressBook = ABAddressBookCreate();
NSArray *people = (NSArray*)ABAddressBookCopyArrayOfAllPeople(addressBook);
for(id person in people){
ABMultiValueRef multiemail = ABRecordCopyValue(person, kABPersonEmailProperty);
for (CFIndex j=0; j < ABMultiValueGetCount(multiemail); j++) {
NSString* email = (NSString*)ABMultiValueCopyValueAtIndex(multiemail, j);
[arrAllEmail addObject:email];
NSLog(@"%@",email);
[email release];
}
}

关于iphone - 无法从 iPhone 获取联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15337518/

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