Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4026672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:00:01+00:00 2026-05-20T11:00:01+00:00

I am trying to get people in three sources (1 MobileMe source and 2*

  • 0

I am trying to get people in three sources (1 MobileMe source and 2* ExchangeGAL sources) of my iOS 4 addressbook.
The NSLog statement always return 0 people for ExchangeGAL, but returns a count of people for MobileMe.
After getting all the sources from the iOS address book by using ABAddressBookCopyArrayOfAllSources(addressBook), I am trying to iterate source by source to get more info for each source.

Am I using the ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering correctly?
Would expect a count of all people in the different addressbook sources.

-(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:
It looks like the code works, but I have a problem getting people count from ExhangeGALs.
Has anyoune successfully retrieved people from ExchangeGAL?
MobileMe source reports back a people count.
Here is the log from Console:

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:00:02+00:00Added an answer on May 20, 2026 at 11:00 am

    Try Using:

    ABRecordRef sourceWithType (ABSourceType mySourceType)
    {
    ABAddressBookRef addressBook = ABAddressBookCreate();
    CFArrayRef sources = ABAddressBookCopyArrayOfAllSources(addressBook);
    CFIndex sourceCount = CFArrayGetCount(sources);
    ABRecordRef resultSource = NULL;
    for (CFIndex i = 0 ; i < sourceCount; i++) {
        ABRecordRef currentSource = CFArrayGetValueAtIndex(sources, i);
        ABSourceType sourceType = [(NSNumber *)ABRecordCopyValue(currentSource, kABSourceTypeProperty) intValue];
        if (mySourceType == sourceType) {
            resultSource = currentSource;
            break;
        }
    }
    
    return resultSource;
    }
    
    ABRecordRef localSource()
    {
        return sourceWithType(kABSourceTypeLocal);
    }
    
    ABRecordRef exchangeSource()
    {
         return sourceWithType(kABSourceTypeExchange);
    }
    
    ABRecordRef mobileMeSource()
    {
         return sourceWithType(kABSourceTypeMobileMe);
    }
    

    You might find this helpful :abaddressbook-absource-and-absourcetype

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning pyramid and it seems they are trying to get people to use
I am trying to get the list of people from the http://en.wikipedia.org/wiki/Category:People_by_occupation . I
We're currently using Salesforce for our sales process, which involve trying to get people
I am trying to get the functionality of SQL servers MERGE statement in Entity
I'm trying to get a small project compiled but am getting this error, I've
So i am trying get 2 div-containers which both should contain centered text (Both
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
I am trying get Struts 2 and Tiles to work and I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.