I am trying to attract people from three sources (1 MobileMe source and 2 * ExchangeGAL sources) from my iOS 4 address book.
The NSLog operator always returns 0 people for ExchangeGAL, but returns the number of people for MobileMe.
After getting all the sources from the iOS address book using ABAddressBookCopyArrayOfAllSources (addressBook), I try to iterate the source by source to get more information for each source.
Am I using ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering correctly?
It would expect counting all the people in different sources of the address book.
-(void)countPeopleInSources
{
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef allSources = ABAddressBookCopyArrayOfAllSources(addressBook);
for (CFIndex i = 0; i < CFArrayGetCount(allSources); i++)
{
ABRecordRef source = (ABRecordRef)CFArrayGetValueAtIndex(allSources, i);
NSNumber *sourceTypeRef = (NSNumber *)((CFNumberRef)ABRecordCopyValue(source, kABSourceTypeProperty));
ABPersonSortOrdering sortOrdering = ABPersonGetSortOrdering();
int sourceType = [sourceTypeRef intValue];
switch (sourceType) {
case kABSourceTypeCardDAV:
NSLog(@"SourceTypeCardDAV");
break;
case kABSourceTypeCardDAVSearch:
NSLog(@"SourceTypeCardDAVSearch");
break;
case kABSourceTypeExchange:
NSLog(@"SourceTypeExchange");
break;
case kABSourceTypeExchangeGAL:
NSLog(@"SourceTypeExchangeGAL");
break;
case kABSourceTypeLDAP:
NSLog(@"SourceTypeLDAP");
break;
case kABSourceTypeLocal:
NSLog(@"SourceTypeLocal");
break;
case kABSourceTypeMobileMe:
NSLog(@"SourceTypeMobileMe");
break;
default:
break;
}
CFArrayRef allPeopleInSource = ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, sortOrdering );
NSLog(@"Count allPeopleInSource: %i", CFArrayGetCount(allPeopleInSource));
[sourceTypeRef release];
}
}
EDIT FEB24:
, , ExhangeGAL.
- ExchangeGAL?
MobileMe .
:
2011-02-24 07:04:32.578 Contacts[10099:307] SourceTypeExchangeGAL
2011-02-24 07:04:32.593 Contacts[10099:307] Count allPeopleInSource: 0
2011-02-24 07:04:32.597 Contacts[10099:307] SourceTypeMobileMe
2011-02-24 07:04:32.641 Contacts[10099:307] Count allPeopleInSource: 151
2011-02-24 07:04:32.646 Contacts[10099:307] SourceTypeExchangeGAL
2011-02-24 07:04:32.652 Contacts[10099:307] Count allPeopleInSource: 0