区切られた文字列を配列に分割しようとすると、少し問題が発生します。基本的にはMECARD QRCodeの結果を渡し、addressBookに新規エントリを追加したい。
これが私のコードです(「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 を分離し、適切なデータを適切なフィールドに送信するには何が欠けていますか?