我正在使用以下代码检索联系人姓名:
for( int i = 0 ; i < n ; i++ )
{
Contact *c = [[Contact alloc] init];
ABRecordRef ref = CFArrayGetValueAtIndex(all, i);
NSString *firstName = (NSString *)ABRecordCopyValue(ref, kABPersonFirstNameProperty);
NSString *lastName = (NSString *)ABRecordCopyValue(ref, kABPersonLastNameProperty);
c.firstName = firstName; //[NSString stringWithFormat:@"%@ %@", firstName, lastName];
c.lastName = lastName;
[contacts addObject:c];
[c release];
}
有谁知道按字母顺序排列此列表的方法?我已经阅读过,sortedArrayUsingSelector:@selector(compare:)
但我不知道它应该如何工作。