0

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);
}
Tobia Tesan
  • 1,938
  • 17
  • 29

1 Answers1

1

A contact only has one last name. Simply do:

NSString *lastName = (__bridge_transfer NSString *)ABRecordCopyValue(person2, kABPersonLastNameProperty);
rmaddy
  • 314,917
  • 42
  • 532
  • 579