|
From: | Стоян Ангелов |
Subject: | Re: [Linphone-developers] importing contacts |
Date: | Tue, 17 Oct 2017 21:35:27 +0300 (EEST) |
CFArrayRef peopleRefs = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFMutableArrayRef mutablePeopleRefs = CFArrayCreateMutableCopy(kCFAllocatorDefault, CFArrayGetCount(peopleRefs), peopleRefs);
CFArraySortValues(mutablePeopleRefs, CFRangeMake(0, CFArrayGetCount(mutablePeopleRefs)), (CFComparatorFunction) ABPersonComparePeopleByName, (void*) (long) kABPersonSortByFirstName);
sortedAddressBook = (__bridge NSMutableArray *)(mutablePeopleRefs);
//make a 27key values array including alphabatic and #.
//make 27 sections on basis of thes keys
//give sectionTitle from this array.
//put values in corrosponding sections from sortedContacts.
indexArray =[[NSArray alloc] initWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z",@"#",nil];
keyContactsDictonary = [[NSMutableDictionary alloc]init];
for (int i = 0; i<[indexArray count]; i++) {
NSString *sectionKey = [indexArray objectAtIndex:i];
NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id record, NSDictionary *b)
{
ABRecordRef recordRef = (__bridge ABRecordRef)record;
NSString *name=(NSString *)CFBridgingRelease(ABRecordCopyCompositeName(recordRef));
if ([name hasPrefix:sectionKey] || [name hasPrefix:[sectionKey lowercaseString]]) {
return YES;
}
return NO;
}];
NSArray *tempArray = [sortedAddressBook filteredArrayUsingPredicate:predicate];
[keyContactsDictonary setValue:tempArray forKey:sectionKey];
Hi,
I've just installed Linphone as my softphone. I've got quite a large contacts list and importing them one by one would take too much time. Is there a way to import all of them at once? Thanks!
_______________________________________________
Linphone-developers mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/linphone-developers
[Prev in Thread] | Current Thread | [Next in Thread] |