我有一个应用程序,我想将通讯录详细信息导入到 vcard 格式中。这是我已经完成的代码,但问题是我的电子邮件地址、照片、组织名称等没有保存在 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 格式保存所有联系人数据?