0

我使用此代码,因为kABPersonEmailProperty它有效,但kABPersonLastNameProperty不是。为什么?

NSMutableArray *allNumbers = [[NSMutableArray alloc] initWithCapacity:CFArrayGetCount(people)];
for (CFIndex i = 0; i < CFArrayGetCount(people); i++) {
    ABRecordRef person2 = CFArrayGetValueAtIndex(people, i);
    ABMultiValueRef numbers = ABRecordCopyValue(person2, kABPersonLastNameProperty);
    for (CFIndex j=0; j < ABMultiValueGetCount(numbers); j++) {
        NSString* number = (NSString *)CFBridgingRelease(ABMultiValueCopyValueAtIndex(numbers, j));
        [allNumbers addObject:number];
    }
    CFRelease(numbers);
}
4

1 回答 1

1

一个联系人只有一个姓氏。只需这样做:

NSString *lastName = (__bridge_transfer NSString *)ABRecordCopyValue(person2, kABPersonLastNameProperty);
于 2015-09-18T14:30:23.270 回答