Aliaksandr 的解决方案并不安全:例如,如果您尝试在特定 ABSource 中创建 ABPerson 记录并使用此方法,您可能会发现联系人无法正确同步到该来源。
我只是从 ABPerson 复制了 25 个 ABPropertyID 的列表,将它们放在一个简单的 int[] 中,然后迭代它们......
// Loop over all properties of this Person
// taken from Apple's ABPerson reference page on 9.12.13.
// URL: https://developer.apple.com/library/ios/documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/c/func/ABPersonGetTypeOfProperty
// count = 25. All are type ABPropertyID
int propertyArray[25] = {
kABPersonFirstNameProperty,
kABPersonLastNameProperty,
kABPersonMiddleNameProperty,
kABPersonPrefixProperty,
kABPersonSuffixProperty,
kABPersonNicknameProperty,
kABPersonFirstNamePhoneticProperty,
kABPersonLastNamePhoneticProperty,
kABPersonMiddleNamePhoneticProperty,
kABPersonOrganizationProperty,
kABPersonJobTitleProperty,
kABPersonDepartmentProperty,
kABPersonEmailProperty,
kABPersonBirthdayProperty,
kABPersonNoteProperty,
kABPersonCreationDateProperty,
kABPersonModificationDateProperty,
kABPersonAddressProperty,
kABPersonDateProperty,
kABPersonKindProperty,
kABPersonPhoneProperty,
kABPersonInstantMessageProperty,
kABPersonSocialProfileProperty,
kABPersonURLProperty,
kABPersonRelatedNamesProperty
};
int propertyArraySize = 25;
for ( int propertyIndex = 0; propertyIndex < propertyArraySize; propertyIndex++ ) {
...code here
}