我使用此代码恢复和备份iOS联系人。 Backup complete iPhone AdressBook programmatically 我在模拟器和设备中的联系人总是填充,但是 对于备用代码:
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef peopleForBackup = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFDataRef vcards = (CFDataRef)ABPersonCreateVCardRepresentationWithPeople(peopleForBackup);
vcardString = [[NSString alloc] initWithData:(NSData *)vcards encoding:NSUTF8StringEncoding];
vcardString总是空字符串和 删除联系人' arrayCount'总是零:
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
int arrayCount = CFArrayGetCount(people);
ABRecordRef abrecord;
for (int i = 0; i < arrayCount; i++) {
abrecord = CFArrayGetValueAtIndex(people, i);
}
}
CFRelease(people);
我也用过
ABAddressBookCreateWithOptions(NULL, NULL);
用于创建&#39;地址簿&#39;对象但没有发生变化。 为什么会这样? 任何人都可以帮助我吗?感谢&#39;