title: How to create vCard from address book using ios sdk?
body: <p>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.</p>
  
  <pre><code>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"];
  </code></pre>
  
  <p>and I get NSSTring as an output :</p>
  
  <pre><code>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 
  </code></pre>
  
  <p>Can anybody help me to convert this NSString to .vcf file to get vCard?</p>