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

  • Home
  • SEARCH
  • 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 6352517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:13:15+00:00 2026-05-24T22:13:15+00:00

Hey Friends i got all contacts detail of my iphone by using this function

  • 0

Hey Friends i got all contacts detail of my iphone by using this function ..

    -(void)collectContacts
{
    ABAddressBookRef addressBook = ABAddressBookCreate();
    CFArrayRef people  = ABAddressBookCopyArrayOfAllPeople(addressBook);
    //NSLog(@" the Name %@%",people);
    for(int i = 0;i<ABAddressBookGetPersonCount(addressBook);i++)
    {
        ABRecordRef ref = CFArrayGetValueAtIndex(people, i);
        // Get First name, Last name, Prefix, Suffix, Job title 
        NSString *firstName = (NSString *)ABRecordCopyValue(ref,kABPersonFirstNameProperty);
        NSString *lastName = (NSString *)ABRecordCopyValue(ref,kABPersonLastNameProperty);
        NSString *prefix = (NSString *)ABRecordCopyValue(ref,kABPersonPrefixProperty);
        NSString *suffix = (NSString *)ABRecordCopyValue(ref,kABPersonSuffixProperty);
        NSString *jobTitle = (NSString *)ABRecordCopyValue(ref,kABPersonJobTitleProperty);
        NSLog(@" the phoneType %@%",firstName);
        NSLog(@" the phoneType %@%",lastName);

        ABMultiValueRef phones = ABRecordCopyValue(ref, kABPersonPhoneProperty);
        for(CFIndex j = 0; j < ABMultiValueGetCount(phones); j++)
        {       
            CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(phones, j);   
            NSString *phoneLabel =(NSString*) ABAddressBookCopyLocalizedLabel (ABMultiValueCopyLabelAtIndex(phones, j));
            NSString *phoneNumber = (NSString *)phoneNumberRef;
            NSLog(@" the phoneType %@%",phoneLabel);
            NSLog(@" the phoneNumber %@%",phoneNumber);
        }

        CFStringRef address;
        CFStringRef label;
        ABMutableMultiValueRef multi = ABRecordCopyValue(ref, kABPersonAddressProperty);    
        for (CFIndex i = 0; i < ABMultiValueGetCount(multi); i++) 
        {           
            label = ABMultiValueCopyLabelAtIndex(multi, i);
            CFStringRef readableLabel = ABAddressBookCopyLocalizedLabel(label);
            NSLog(@" Lable %@%",readableLabel);
            address = ABMultiValueCopyValueAtIndex(multi, i);
            NSLog(@" Address %@%",address);
            CFRelease(address);
            CFRelease(label);
        } 

        ABMultiValueRef emails = ABRecordCopyValue(ref, kABPersonEmailProperty);
        for(CFIndex idx = 0; idx < ABMultiValueGetCount(emails); idx++)
        {
            CFStringRef emailRef = ABMultiValueCopyValueAtIndex(emails, idx);
            NSString *strLbl = (NSString*) ABAddressBookCopyLocalizedLabel (ABMultiValueCopyLabelAtIndex (emails, idx));
            NSLog(@" Email Lable %@%",strLbl);
            NSString *strEmail_old = (NSString*)emailRef;
            NSLog(@" Email-Id %@%",strEmail_old);
            //[[strEmail_old componentsJoinedByString:@","] writeToFile:@"components.csv" atomically:YES encoding:NSUTF8StringEncoding error:NULL];
        }
    }
    //[[ContactsText componentsJoinedByString:@","] writeToFile:@"components.csv" atomically:YES encoding:NSUTF8StringEncoding error:NULL];
//  NSLog(@" Data in the .CSV file = %@%",ContactsText);
}
'

Now i want to make .csv file from this function’s output .. and m getting all data in NSLog . I juat want to write .csv file from that data .. Can anyone help me in that ?? Data coming are proper but .csv file not gonna written …Thanks

  • 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-24T22:13:16+00:00Added an answer on May 24, 2026 at 10:13 pm

    Assuming you will have all the data in “ContactsText”, try following code:

        NSArray  *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString* savePath = [paths objectAtIndex:0];
        savePath = [savePath stringByAppendingPathComponent:@"components.csv"]; 
        [[ContactsText componentsJoinedByString:@","] writeToFile:savePath atomically:YES encoding:NSUTF8StringEncoding error:NULL];
    

    Remember that you cannot just save “components.csv” file. You have to save the file in documents folder only.

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

Sidebar

Related Questions

Hey friends any one please help me for this issue.in this javascript code i
Hey Friends I've got another xsl/xpath problem. Sure a beginners problem, but I'm thinking
Hey,firends,This is my first post. I'm just begin to using Gcc to compile java,and
hey. friends i dont know this question is really asked before or not ?
Hey, i need a little help with this django function. I wan't to insert
Hey all i am probably overthinking this but how can i check the textbox
Hey Hi Friends I got exception in my method... please help me error like
Hey Friends I want to make a form builder using Yii. For that I
hey friends, i have been assigned a query planning project. in this project if
Hey, friends, I am using squeak for developing and I found primitives is useful,

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.