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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:23:43+00:00 2026-05-15T05:23:43+00:00

I’m utilising the AddressBook.framework in my iPhone app, and I’d like to replicate something

  • 0

I’m utilising the AddressBook.framework in my iPhone app, and I’d like to replicate something along the lines of the share feature in Contacts.app. This basically attach’s a specific contacts vCard to an email. As far as I know, there is nothing in the documentation that mentions generating a vCard.

Is this a case of generating one myself? Or is there something available that can help me?

  • 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-15T05:23:43+00:00Added an answer on May 15, 2026 at 5:23 am

    Totally agree with Dave DeLong’s answer. Just want to add that since I simply wanted to create a vCard file (.vcf) and attach it to an in-app email action what I did was create a string, then a temporary file, with all the vCard fields I had data for.

    In my case I made a method in my NSManagedObject subclass to return a -vCardRepresentation string.

    An Objective-c category or simple framework would be a great help – I might do it when time.

    The Wikipedia page and the formal spec for vCard (3.0) really help.

    UPDATE 3: If you’re using iOS 5 or later there’s now a function in ABPerson that can return the vCard representation of the given person records:

    CFDataRef ABPersonCreateVCardRepresentationWithPeople(CFArrayRef people);
    

    UPDATE 2: I’m rushing to get an app complete, but because I did want to create vCard data and add it as attachments to in-app mail messages in several places I’ve now made a separate class controller that makes / hides the details of the vCard syntax. Then I just have a method that returns an NSData version of the vCard string to add directly to a mail message as an attachment. This is a much cleaner solution, you don’t need to create any files, even if they were only temporary. Plus you don’t really need an NSString representation of the data anyway, unless you did want to create a file and use it more than once to save re-making the data?

    My controller class has a number of -setXXXX methods that add values to a dictionary where the keys are strings with the vCard field names, like FN, TEL and ADR. Then when I call its -vCardRepresentation, this now returns an NSData object (built by scanning the dictionary) that can be used directly in MFMailComposeViewController’s -addAttachmentData:mimeType:fileName: method.

    If I can tidy my code, so it’s generic enough, I’ll post it later.

    UPDATE: Here’s my code, it might help someone get started:

    - (NSString *)vCardRepresentation
    {
      NSMutableArray *mutableArray = [[NSMutableArray alloc] init];
    
      [mutableArray addObject:@"BEGIN:VCARD"];
      [mutableArray addObject:@"VERSION:3.0"];
    
      [mutableArray addObject:[NSString stringWithFormat:@"FN:%@", self.name]];
    
      [mutableArray addObject:[NSString stringWithFormat:@"ADR:;;%@",
                               [self addressWithSeparator:@";"]]];
    
      if (self.phone != nil)
        [mutableArray addObject:[NSString stringWithFormat:@"TEL:%@", self.phone]];
    
      [mutableArray addObject:[NSString stringWithFormat:@"GEO:%g;%g",
                               self.latitudeValue, self.longitudeValue]];
    
      [mutableArray addObject:[NSString stringWithFormat:@"URL:http://%@",
                               self.website]];
    
      [mutableArray addObject:@"END:VCARD"];
    
      NSString *string = [mutableArray componentsJoinedByString:@"\n"];
    
      [mutableArray release];
    
      return string;
    }
    

    Obviously I’m making reference to properties in my class, plus a method called -addressWithSeparator to build-up the data for the address, which has to include the ; separator even for optional address fields.

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

Sidebar

Related Questions

No related questions found

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.