从vCard读取/parsing数据

在iOS SDK中是否有任何框架/库可以读取/parsingvCard格式的数据? 我在NSString中以vcard格式接收数据,我必须parsing它。 Googlesearch了很多,但还找不到解决scheme。

BEGIN:VCARD VERSION:2.1 N:LastName;FirstName;MiddleName;Prefix;Sufix ADR;TYPE=HOME: postbox;street2;street1;city;state;zip;country BDAY:2010-08-19 END:VCARD 

我确实为你find了一些解决scheme

看看下面的链接…

1)要准备好的样品代码==> 点击这里

2)写入Vcard ==> 点击这里

代码相关给你:

 ABAddressBookRef addressBook = ABAddressBookCreate(); // create address book record ABRecordRef person = ABPersonCreate(); // create a person NSString *phone = @"0123456789"; // the phone number to add //Phone number is a list of phone number, so create a multivalue ABMutableMultiValueRef phoneNumberMultiValue = ABMultiValueCreateMutable(kABPersonPhoneProperty); ABMultiValueAddValueAndLabel(phoneNumberMultiValue ,phone,kABPersonPhoneMobileLabel, NULL); ABRecordSetValue(person, kABPersonFirstNameProperty, @"FirstName" , nil); // first name of the new person ABRecordSetValue(person, kABPersonLastNameProperty, @"LastName", nil); // his last name ABRecordSetValue(person, kABPersonPhoneProperty, phoneNumberMultiValue, &anError); // set the phone number property ABAddressBookAddRecord(addressBook, person, nil); //add the new person to the record ABRecordRef group = ABGroupCreate(); //create a group ABRecordSetValue(group, kABGroupNameProperty,@"My Group", &error); // set group's name ABGroupAddMember(group, person, &error); // add the person to the group ABAddressBookAddRecord(addressBook, group, &error); // add the group ABAddressBookSave(addressBook, nil); //save the record CFRelease(person); // relase the ABRecordRef variable 

3)导入vCard示例代码==> 点击这里

4)创build自定义分析器==> 点击这里

OS X v10.11和iOS 9引入了CNContactVCardSerialization ,可以轻松parsingVCard。