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 8805177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:47:51+00:00 2026-06-14T01:47:51+00:00

I have been using the following code for a few years now and it

  • 0

I have been using the following code for a few years now and it has always worked, but it looks like with iOS 6 it doesn’t anymore. How do I get a list of all contacts on an iOS 6 device?

ABAddressBookRef myAddressBook = ABAddressBookCreate();
        NSMutableArray *people = (__bridge_transfer NSMutableArray *)ABAddressBookCopyArrayOfAllPeople(myAddressBook);
        CFRelease(myAddressBook);

        // repeat through all contacts in the inital array we loaded
        for(int i=0; i<[people count]; i++)
        {
            NSString *aName;
            NSString *firstName = (__bridge_transfer NSString *)ABRecordCopyValue((__bridge ABRecordRef)([people objectAtIndex:i]), kABPersonFirstNameProperty);
            NSString *lastName = (__bridge_transfer NSString *)ABRecordCopyValue((__bridge ABRecordRef)([people objectAtIndex:i]), kABPersonLastNameProperty);

            if (([firstName isEqualToString:@""] || [firstName isEqualToString:@"(null)"] || firstName == nil) &&
                ([lastName isEqualToString:@""] || [lastName isEqualToString:@"(null)"] || lastName == nil))
            {
                // do nothing
            }
            else 
            {
                aName = [NSString stringWithFormat:@"%@ %@", firstName, lastName];

                if ([firstName isEqualToString:@""] || [firstName isEqualToString:@"(null)"] || firstName == nil)
                {
                    aName = [NSString stringWithFormat:@"%@", lastName];
                }

                if ([lastName isEqualToString:@""] || [lastName isEqualToString:@"(null)"] || lastName == nil)
                {
                    aName = [NSString stringWithFormat:@"%@", firstName];
                }

                [self.tableItems addObject:aName];
            }

        }

        [self.tableItems sortUsingSelector:@selector(compare:)];
  • 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-06-14T01:47:53+00:00Added an answer on June 14, 2026 at 1:47 am

    In ios6 you need to ask for permission to read the AddressBook, otherwise you’ll get nil. Use something like this:

    - (BOOL)askContactsPermission {
        __block BOOL ret = NO;
        if (ABAddressBookRequestAccessWithCompletion != NULL) { // we're on iOS6
    
            dispatch_semaphore_t sema = dispatch_semaphore_create(0);
            ABAddressBookRef addressBook = ABAddressBookCreate();
            ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
                ret = granted;
                dispatch_semaphore_signal(sema);
            });
            if (addressBook) {
                CFRelease(addressBook);
            }
    
            dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
            dispatch_release(sema);
        }
        else { // we're on iOS5 or older
            ret = YES;
        }
    
        return ret;
    }
    

    If this method returns NO, bad luck, you won’t be able to access the AB. I’m locking with a semaphore here because I don’t want to continue with my app if the user does not allow the AB. There other methods, just check the API.

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

Sidebar

Related Questions

I am using the following code for the Share Price Application I have been
I have been using the following code to zoom the mapview, so that all
I have been using the following sort: var query = _cityRepository.GetAll( .OrderBy(item => item.RowKey.Substring(0,
I have been using the following CSS to apply an effect at the bottom
I have been using the following to add a dynamic link on a page
I have been following the following post on using multiple ItemTemplates in a ListView
I have been doing some research for using MSMQ. Following 2 gave me fundamental
Following the standard instruction for using AES algorithm, I have not been able to
I have been using TortoiseSVN for some time and I really like it. I
I've been programming for a few years but I'm new to JavaScript. I'm trying

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.