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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:07:49+00:00 2026-06-14T00:07:49+00:00

I do not know how to create vCard from Address book. I can generate

  • 0

I do not know how to create vCard from Address book. I can generate NSString for vCard data by searching but I dont know how to convert NSString to .vcf. Here is my code for NSString of vCard data.

NSString *vcard = @"BEGIN:VCARD\nVERSION:3.0\n";

    // Name
    vcard = [vcard stringByAppendingFormat:@"N:%@;%@;%@;%@;%@\n",
             (contact.lastname ? contact.lastname : @""),
             (contact.firstname ? contact.firstname : @""),
             (contact.middlename ? contact.middlename : @""),
             (contact.prefix ? contact.prefix : @""),
             (contact.suffix ? contact.suffix : @"")
             ];

    vcard = [vcard stringByAppendingFormat:@"FN:%@\n",contact.compositeName];
    if(  contact.nickname ) vcard = [vcard stringByAppendingFormat:@"NICKNAME:%@\n",contact.nickname];
    if(  contact.firstnamephonetic ) vcard = [vcard stringByAppendingFormat:@"X-PHONETIC-FIRST-NAME:%@\n",contact.firstnamephonetic];
    if(  contact.lastnamephonetic ) vcard = [vcard stringByAppendingFormat:@"X-PHONETIC-LAST-NAME:%@\n",contact.lastnamephonetic];


    // Work
    if( contact.organization || contact.department ) vcard = [vcard stringByAppendingFormat:@"ORG:%@;%@\n",(contact.organization?contact.organization:@""),(contact.department?contact.department:@"")];
    if( contact.jobtitle ) vcard = [vcard stringByAppendingFormat:@"TITLE:%@\n",contact.jobtitle];


    // Mail
    vcard = [vcard stringByAppendingString:[VCard toVcardField:@"email" items:contact.emailArray labels:contact.emailLabels]];

    // Tel
    vcard = [vcard stringByAppendingString:[VCard toVcardField:@"phone" items:contact.phoneArray labels:contact.phoneLabels]];

    // Adress
    vcard = [vcard stringByAppendingString:[VCard toVcardField:@"address" items:contact.addressArray labels:contact.addressLabels]];

    // url
    vcard = [vcard stringByAppendingString:[VCard toVcardField:@"url" items:contact.urlArray labels:contact.urlLabels]];

    // IM
    vcard = [vcard stringByAppendingString:[VCard toVcardField:@"im" items:contact.smsArray labels:contact.smsLabels]];

    // birthday
    NSDate *birthday = contact.birthday;
    if (birthday)
    {
        NSString *bday = [NSString stringWithFormat:@"%@",birthday];
        NSArray *bdayArr = [bday componentsSeparatedByString:@" "];
        bday = [bdayArr objectAtIndex:0];

        vcard = [vcard stringByAppendingFormat:@"BDAY;value=date:%@\n",bday];
    }

    // Photo
    NSData *imageData = contact.thumbData;//contact.imageData;
    if (imageData)
    {
        //vcard = [vcard stringByAppendingFormat:@"PHOTO;BASE64:%@\n",[imageData base64Encoding]];
    }

    // end
    vcard = [vcard stringByAppendingString:@"END:VCARD"];

and I get NSSTring as an output :

vCard : BEGIN:VCARD
VERSION:3.0
N:def;Abc;;;
FN:Abc def
ORG:slk;
EMAIL;type=INTERNET;type=HOME:fdf@gmail.com
TEL;type=CELL:(258) 963-4889
TEL;type=IPHONE:(435) 768-6343
item1.ADR;type=HOME:;;aashram road;Ahmedabad;;;India
item1.X-ABADR:in
END:VCARD 

Can anybody help me to convert this NSString to .vcf file to get vCard?

  • 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-14T00:07:50+00:00Added an answer on June 14, 2026 at 12:07 am
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents directory
    
    NSError *error;
    BOOL succeed = [yourNSString writeToFile:[documentsDirectory stringByAppendingPathComponent:@"contact.vcf"]
                              atomically:YES encoding:NSUTF8StringEncoding error:&error];
    if (!succeed){
        // Handle error here
        NSLog(@"Error");
    }
    

    This code save the vcard on Documents directory of your app.

    yourNSString is the variable you use when you generate the vcard

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

Sidebar

Related Questions

I need create clone repository. but I do not know where can I get
I need to create a generic type, but I do not know the type
i want create date validation but not know why return is false? $data_go =
I wanted to create an extension of java.text.Format but I do not know what
I'm trying to create an app launcher in vb.net but I do not know
I would like to create the following effect, but do not know if it
I am trying to create facebook app, and I do not know how to
I know that we should only create repositories for Aggregate Roots and not for
I do not know javascript right now but I am planning on learning it.
I do not know why there are 2 matches found aside from the input

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.