我应该检索/提取ABPerson的所有可用属性。IOS ABPerson的官方文档不包括MACOS可用方法的ABPerson属性
我能做什么?
发布于 2012-09-11 20:41:03
您可以使用在Personal Information Properties头下的ABPerson reference中找到的所有属性创建一个NSArray/NSSet。
然后只需使用for-in来遍历NSArray,如下所示。
NSArray *allPropertiesForABPerson = [NSArray arrayWithObjects: @"kABPersonFirstNameProperty", @"kABPersonLastNameProperty", /*rest of props here*/, nil];
for (id property in allPropertiesForABPerson) {
id valueForProperty = ABRecordCopyValue(theRecord, property);
NSLog(@"Value: %@ for property: %@", valueForProperty, property);
CFRelease(valueForProperty);
}发布于 2015-05-06 10:26:05
假设您有一个名为myFriend的ABPerson。您可以通过以下方式访问它的名字:
NSString* firstName = (__bridge_transfer NSString*)ABRecordCopyValue(myFriend, kABPersonFirstNameProperty);当然,您可以用其他属性常量替换kABPersonFirstNameProperty来获取其他属性。
以下是其中的一些:
kABPersonFirstNameProperty
kABPersonLastNameProperty
kABPersonMiddleNameProperty
kABPersonPrefixProperty
kABPersonSuffixProperty
kABPersonNicknameProperty
kABPersonFirstNamePhoneticProperty
ckABPersonLastNamePhoneticProperty
kABPersonMiddleNamePhoneticProperty
kABPersonOrganizationProperty
kABPersonJobTitleProperty
kABPersonDepartmentProperty
kABPersonEmailProperty
kABPersonBirthdayProperty
kABPersonNoteProperty
kABPersonCreationDateProperty
kABPersonModificationDatePropertyhttps://stackoverflow.com/questions/12297556
复制相似问题