我正在尝试使用CNContact.My获取本地化的电话标签值到目前为止:
NSError *error = nil; CNContactFetchRequest *fetchRequest =[[CNContactFetchRequest alloc] initWithKeysToFetch:keysToFetch]; [addressBook enumerateContactsWithFetchRequest:fetchRequest error:&error usingBlock:^(CNContact * _Nonnull contact,BOOL * _Nonnull stop) { CNLabeledValue *phoneNumberValue = contact.phoneNumbers.firstObject; NSString *label = phoneNumberValue.label; NSLog(@"Phone Label: %@",label); //Logs value like _$!<Home>!$_ CNPhoneNumber *phoneNumber = phoneNumberValue.value; NSString *phoneNumberString = phoneNumber.stringValue; NSLog(@"Phone No: %@",phoneNumberString); }];
问题是手机标签返回的原始值如_ $!< Home>!$_,_ $!< Mobile>!$_.但我需要像Home,Mobile这样的纯文本.有什么办法可以使用Contact框架获取本地化值.我不想使用Addressbook,因为它在iOS 9中已被弃用.