gpt4 book ai didi

ios - 带有 é,è ... 和多个号码的地址簿名称

转载 作者:行者123 更新时间:2023-11-29 01:48:06 25 4
gpt4 key购买 nike

我想在 NSDictionary 中存储来自Address Book 的联系人。

我成功地记录联系人的名字+姓氏并存储在NSDictionary“名称”中。但是,当名字或姓氏中出现笑脸符号或类似“é”或“è”的重音时,就会出现这样的错误:"Name = "Manon\Ud83d\Udc9c (null)";"

第二个错误:当联系人有多个号码时,将号码存储在我的 NSDictionary“号码”中,但给我这样的错误 "Number = "06\U00a067\U00a054\U00a069\U00a034";" 也许只使用搜索手机号码的东西(在法国以“06”或“+336”开头)?并将其添加到 NSDictionary “number” ?

如何修复它?

这是我在 ViewDidLoad 中的代码:

//ADDRESS BOOK
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
if (addressBook != NULL) {
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
if (granted)
{

NSArray *arrayOfPeople = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);

//The array in which the first names will be stored as NSStrings
// self.allContact = [[NSMutableArray alloc] init];

for(NSUInteger index = 0; index <= ([arrayOfPeople count]-1); index++){

ABRecordRef person = (__bridge ABRecordRef)[arrayOfPeople objectAtIndex:index];
NSString *currentFirstName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
NSString *currentLastName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
NSString *allName = [NSString stringWithFormat:@"%@ %@", currentFirstName, currentLastName];
[self.allContact addObject: allName];
self.contact = [NSMutableDictionary
dictionaryWithDictionary:@{
@"Name" : @"Number"
}];
[self.contact setObject:allName forKey:@"Name"];
ABMultiValueRef phones = ABRecordCopyValue(person, kABPersonPhoneProperty);
if (phones != NULL)
{
for (NSInteger index = 0; index < ABMultiValueGetCount(phones); index++)
{

NSString *phone = CFBridgingRelease(ABMultiValueCopyValueAtIndex(phones, index));
[self.contact setObject:phone forKey:@"Number"];
}
}

NSLog(@"%@", self.contact);
}

//OPTIONAL: The following line sorts the first names alphabetically
NSArray *sortedFirstNames = [self.allContact sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
// NSLog(@"%@", sortedFirstNames);


}
});
}

最佳答案

"Name = "Manon \Ud83d\Udc9c (null)";"
"Number = "06\U00a067\U00a054\U00a069\U00a034"

这不是一个错误。 \U00a067 等都是unicode符号。控制台只是不知道如何显示此类符号(“é”或“è”),这就是它显示 unicode 符号的原因。 然而在应用程序中,这些符号将按预期显示。
我一直对俄语角色有同样的行为。

关于ios - 带有 é,è ... 和多个号码的地址簿名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31687052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com