kABPersonLastName not working

35 Views Asked by At

I use this code, for kABPersonEmailProperty it works, but for kABPersonLastNameProperty not. Why?

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);
}
1

There are 1 best solutions below

0
rmaddy On

A contact only has one last name. Simply do:

NSString *lastName = (__bridge_transfer NSString *)ABRecordCopyValue(person2, kABPersonLastNameProperty);