Ну, это довольно долгое время, когда задается этот вопрос. Но ответ теперь может также помочь кому-то, кто находится на этой странице. Вы можете использовать приведенный ниже метод для ссылки для анализа данных VCF.
NSString *str = [NSString stringWithString:response.vcfString];
NSArray *subStrings = [str componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\n"]];
NSArray *getData = [[NSArray alloc]init];
NSString *arr = @"";
for (int i=0;i<[subStrings count];i++)
{
arr = [subStrings objectAtIndex:i];
NSArray *abc = [arr componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@";"]];
if([[abc objectAtIndex:0] isEqualToString:@"FN"])
{
getData=[[abc objectAtIndex:1] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"] ];
if([getData count] > 1)
fullName = [getData objectAtIndex:1];
}
else if([[abc objectAtIndex:0] isEqualToString:@"N"])
{
getData=[[abc objectAtIndex:1] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([getData count] > 1)
lastName = [getData objectAtIndex:1];
FirstName = [abc objectAtIndex:2];
}
else if([[abc objectAtIndex:0] isEqualToString:@"TITLE"])
{
getData=[[abc objectAtIndex:1] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([getData count] > 1)
title = [getData objectAtIndex:1];
}
else if([[abc objectAtIndex:0] isEqualToString:@"TEL"])
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if([abc count] == 3)
{
getData=[[abc objectAtIndex:2] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([[abc objectAtIndex:1] isEqualToString:@"WORK"])
{
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Tel"];
}
else if([[abc objectAtIndex:1] isEqualToString:@"CELL"])
{
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Tel"];
}
}
else if([abc count] == 4)
{
getData=[[abc objectAtIndex:3] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([[abc objectAtIndex:1] isEqualToString:@"WORK"] && [[abc objectAtIndex:2] isEqualToString:@"FAX"])
{
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Tel"];
}
}
else
{
getData=[[abc objectAtIndex:1] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([[getData objectAtIndex:0] isEqualToString:@"WORK"])
{
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Tel"];
}
else if([[getData objectAtIndex:0] isEqualToString:@"FAX"])
{
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Tel"];
}
}
[_telList addObject:dict];
}
else if([[abc objectAtIndex:0] isEqualToString:@"EMAIL"])
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if([abc count] == 3)
{
getData=[[abc objectAtIndex:2] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([[abc objectAtIndex:1] isEqualToString:@"WORK"])
{
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Email"];
}
}
else
{
getData=[[abc objectAtIndex:1] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Email"];
}
[_emailList addObject:dict];
}
else if([[abc objectAtIndex:0] isEqualToString:@"ORG"])
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if([abc count] == 5)
{
getData=[[abc objectAtIndex:2] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([[abc objectAtIndex:1] isEqualToString:@"WORK"])
{
NSString *orgStr = @"";
if([getData count] > 1)
{
orgStr = [getData objectAtIndex:1];
}
[dict setObject:[orgStr stringByAppendingString:[abc objectAtIndex:4]] forKey:@"Org"];
}
}
else
{
getData=[[abc objectAtIndex:1] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Org"];
}
[_orgList addObject:dict];
}
else if([[abc objectAtIndex:0] isEqualToString:@"ADR"])
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
if([abc count] == 9)
{
[dict setObject:[abc objectAtIndex:4] forKey:@"Add"];
[dict setObject:[abc objectAtIndex:8] forKey:@"Country"];
[dict setObject:[abc objectAtIndex:7] forKey:@"Zip"];
[dict setObject:[abc objectAtIndex:5] forKey:@"City"];
}
else
{
}
[_addrList addObject:dict];
}
else if([[abc objectAtIndex:0] isEqualToString:@"URL"])
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
if([abc count] == 3)
{
getData=[[abc objectAtIndex:2] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Url"];
}
else
{
getData=[[abc objectAtIndex:1] componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":"]];
if([getData count] > 1)
[dict setObject:[getData objectAtIndex:1] forKey:@"Url"];
}
[_urlList addObject:dict];
}
else
{
}
}
NSLog(@"Details: \nFull Name - %@\nLast Name - %@\nFirst Name - %@\ntitle - %@\nEmail - %@\norg - %@\nAddress - %@\nUrl - %@", fullName,lastName,FirstName,title,[[_emailList valueForKey:@"description"] componentsJoinedByString:@""],[_orgList description],[_addrList description],[_urlList description]);
нам нужен какой-то код, как принести эта информация означает код Fo QR код, который вы использовали. –
@SAMIRRATHOD Я использую для этого Zbar sdk. – sachi