我试图获取保存在联系人中的所有电子邮件,我可以在 ipod 中获取 eemail,但是当我在 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
}