我有一个应用程序,我想将地址簿的详细信息导入到vcard格式。这是我已经完成的代码,但是我的电子邮件地址,照片,组织名称等问题没有保存在vcard中。如何使用地址簿联系人详细信息在iPhone中生成vcard?
-(NSString*)vcardrepresentation
{
NSMutableArray *mutableArray = [[NSMutableArray alloc] init];
[mutableArray addObject:@"BEGIN:VCARD"];
[mutableArray addObject:@"VERSION:3.0"];
[mutableArray addObject:[NSString stringWithFormat:@"FN:%@ %@", self.contactlist.objContact.firstname,self.contactlist.objContact.lastname]];
[mutableArray addObject:[NSString stringWithFormat:@"ORG:%@",self.contactlist.objContact.companyname]];
[mutableArray addObject:[NSString stringWithFormat:@"ADR:%@",self.contactlist.objContact.City]];
if ([phoneArray count]!=0)
[mutableArray addObject:[NSString stringWithFormat:@"TEL:%@", phoneemail.phoneNumber]];
if ([emailArray count]!=0)
{
[mutableArray addObject:[NSString stringWithFormat:@"EMAIL:%@",phoneemail.phoneNumber]];
}
if ([contactlist.objContact.Photo length]==0)
{
[mutableArray addObject:[NSString stringWithFormat:@"PHOTO:%@",[UIImage imageNamed:@"man.png"]]];
}
else
{
[mutableArray addObject:[NSString stringWithFormat:@"PHOTO:%@",[UIImage imageWithData:contactlist.objContact.Photo]]];
}
[mutableArray addObject:@"END:VCARD"];
NSString *string = [mutableArray componentsJoinedByString:@"\n"];
return string;
}
如何以vcard格式保存所有联系人数据?
vCard版本3.0中'ENCODING'参数的正确值是'B'而不是'BASE64'。版本2.1中使用了BASE64。 3.0规范的链接是:http://tools.ietf.org/html/rfc2426。 – Michael