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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:21:25+00:00 2026-06-18T03:21:25+00:00

+(NSMutableArray *)getLastName { ABAddressBookRef addressBook = ABAddressBookCreate(); NSMutableArray *lastNameArray = [[NSMutableArray alloc]init]; ABRecordRef source

  • 0
+(NSMutableArray *)getLastName
{

   ABAddressBookRef addressBook = ABAddressBookCreate();
    NSMutableArray *lastNameArray = [[NSMutableArray alloc]init];
    ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);
    CFIndex numberOfContacts  = ABAddressBookGetPersonCount(addressBook);
    NSLog(@"%ld",numberOfContacts);
    CFArrayRef people = (__bridge CFArrayRef)((__bridge NSArray*)ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonSortByLastName));
    NSArray * tempArray = [[NSArray alloc]init];
    tempArray = (__bridge  NSArray *)(people);
    if ([tempArray count]>0) {
    for (int personIndex = 0; personIndex < [tempArray count]-1; personIndex++) {
        ABRecordRef person = (__bridge ABRecordRef)([tempArray objectAtIndex:personIndex]);
        ABMultiValueRef lastName = ABRecordCopyValue(person, kABPersonLastNameProperty);
        NSString *lastNameString = (__bridge NSString *)lastName;
        if (lastName!=nil)
            [lastNameArray addObject:lastNameString];
          }
    }
    return lastNameArray;
}

I am using the xcode 6.0. iphone 3s is working fine but iphone 4s and iphone 5 not working in that code

  • 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-18T03:21:26+00:00Added an answer on June 18, 2026 at 3:21 am

    I think the problem is with you iOS version…. If you’re using iOS 6.0 then ABAddressBookCreate() won’t work… it is fine for iOS 5.1 or before…. so you can do like,

    ABAddressBookRef addressBook;
    
    if ([self isABAddressBookCreateWithOptionsAvailable])
    {
        // iOS 6
        CFErrorRef error = nil;
        addressBook = ABAddressBookCreateWithOptions(NULL,&error);
    
        ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error)
                                                 {
                                                 });
        ABAddressBookRevert(addressBook);
    }
    else
    {
        // iOS 4/5
        addressBook = ABAddressBookCreate();
    }
    
    
    
    -(BOOL)isABAddressBookCreateWithOptionsAvailable
    {
        return &ABAddressBookCreateWithOptions != NULL;
    }
    

    By this you can get all contacts…:)

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

Sidebar

Related Questions

NSMutableArray *insideArray = [[NSMutableArray alloc] init]; NSMutableArray *outsideArray = [[NSMutableArray alloc] init]; [insideArray addObject:@Hello
NSMutableArray *output = [[NSMutableArray alloc]init]; or NSArray *output = [[NSMutableArray alloc]init]; I can set
I got an NSMutableArray, created like this: NSMutableArray *expr = [[NSMutableArray alloc] init]; [expr
Do [[NSMutableArray alloc] init]; and [[NSMutableArray alloc] initWithCapacity:0]; compile into the exact same thing?
- (void)viewDidLoad { webCollectionOnScroller=[[NSMutableArray alloc] init]; scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 370, 320, 94)];
NSMutableArray*array = [[NSMutableArray alloc]init]; NSArray*Somearray = [NSArray arrayWithObjects:1st Object,2ndObject,3rd Object,4th object,5th Object,nil]; In the
NSMutableArray * lCellColValues = (NSMutableArray * ) nil; lCellColValues = [[[NSMutableArray alloc] init] autorelease];
NSMutableArray *lCellColValues =(NSMutableArray *)nil; lCellColValues = [[[NSMutableArray alloc] init] autorelease]; if(0 == lSecModulus) //trans
NSMutableArray *tempMutableArray = [[NSMutableArray alloc] init]; if (street != NULL) { [tempMutableArray addObject:(NSString *)street];
NSMutableArray *nameArray = [[NSMutableArray alloc] init]; [nameArray addObject:@abc]; [nameArray addObject:@cdf]; [nameArray addObject:@jkl]; //Use a

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.