当我尝试将分隔字符串拆分为数组时,我遇到了一个小问题。基本上,我想从 MECARD QRCode 传递结果并将新条目添加到地址簿。
这是我的代码(仅适用于“FirstName”字段): :
NSLog(@"found CB");
NSLog(@"_code.text = %@", code.content);
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef person = ABPersonCreate();
NSString *_n = [NSString stringWithFormat:@"_code.text = %@", code.content];
NSArray *n = [_n componentsSeparatedByString:@";"];
NSLog(@"_code.text = %@",n);
ABRecordSetValue(person, kABPersonFirstNameProperty, _name, nil);
ABAddressBookAddRecord(addressBook, person, nil);
CFRelease(addressBook);
ABNewPersonViewController *c = [[ABNewPersonViewController alloc] init];
[c setNewPersonViewDelegate:self];
[c setDisplayedPerson:person];
CFRelease(person);
[self.navigationController pushViewController:c animated:YES];
[c release];
MECARD QRCode 被很好地解码并且 viewController 出现了......但是所有的 URL(如:“MECARD:N:name;ORG:company;TEL:89878978;...等)都进入第一个字段(FistName 字段)...
将我的 MECARD URL 分开并在正确的字段中发送正确的数据缺少什么?