gpt4 book ai didi

ios - swift : Issue with accessing CFDictionaryRef for ABAddressBookRef

转载 作者:可可西里 更新时间:2023-11-01 01:43:53 25 4
gpt4 key购买 nike

我已经在 ObjC 中收集了联系人的地址信息,

ABMultiValueRef addressProperty = ABRecordCopyValue(contactRef, kABPersonAddressProperty);
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(addressProperty, 0);
if(dict)
{
NSString *street = (NSString *)CFDictionaryGetValue(dict, kABPersonAddressStreetKey);
}

所以,等效的 Swift 代码是,

let addressProperty : ABMultiValueRef = ABRecordCopyValue(contactRef, kABPersonAddressProperty).takeUnretainedValue() as ABMultiValueRef

if let dict : CFDictionaryRef = ABMultiValueCopyValueAtIndex(addressProperty, 0).takeUnretainedValue() as? CFDictionaryRef
{
let street = CFDictionaryGetValue(dict,kABPersonAddressStreetKey)
// Stuck here, among CFString!, UnsafePointer<Void>, CFDictionaryRef ...
}

我将如何获取街道和其他类似信息?

最佳答案

你能用 NSDictionary 代替吗? (未测试)

if let dict : NSDictionary = ABMultiValueCopyValueAtIndex(addressProperty, 0).takeUnretainedValue() as? NSDictionary
{
let street = dict[kABPersonAddressStreetKey]
}

关于ios - swift : Issue with accessing CFDictionaryRef for ABAddressBookRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25542404/

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