目前我在看电话号码时出了故障。带空标签的:
致命错误:在展开可选值时意外找到零
if let phones: ABMultiValueRef = ABRecordCopyValue(person,
kABPersonPhoneProperty)?.takeRetainedValue(){
for counter in 0..<ABMultiValueGetCount(phones){
let label = ABMultiValueCopyLabelAtIndex(phones,
counter).takeRetainedValue() as String
let phone = ABMultiValueCopyValueAtIndex(phones,
counter).takeRetainedValue() as! String
}
}我试着把标签读成:
let label = ABMultiValueCopyLabelAtIndex(phones,
counter).takeRetainedValue() as? String ?? ""但结果是一样的。
发布于 2015-05-21 11:29:55
我没有测试,但这应该有效
if let phoneTest = ABMultiValueCopyValueAtIndex(phones, counter).takeRetainedValue()
{
let phone = phoneTest as String
}发布于 2015-05-22 16:08:39
let label = ABMultiValueCopyLabelAtIndex(phones,
counter).takeRetainedValue() as? String ?? ""是正确的方法。我的应用程序中还有其他一些bug,这就是为什么我认为这个解决方案不起作用。
https://stackoverflow.com/questions/30371305
复制相似问题