iOS <9是CNLabeledValue的替代品吗?

问题描述 投票:0回答:1

我已经实现了ContactAddressBook的框架,以便从联系人簿中为iOS上方和下方的用户获取联系人。9.为了按一行访问另一个view,以查看我在CNLabeledValue中使用过didSelectRowAt的联系信息是这样的:

if #available(iOS 9.0, *) {
    switch((number as! CNLabeledValue<CNPhoneNumber> ).label){
        case CNLabelPhoneNumberMobile:phoneContact?.mobilePhone = (number as! CNLabeledValue<CNPhoneNumber>).value.stringValue
        case CNLabelPhoneNumberiPhone:phoneContact?.mobilePhone = (number as! CNLabeledValue<CNPhoneNumber>).value.stringValue
        case CNLabelPhoneNumberMain:phoneContact?.mobilePhone = (number as! CNLabeledValue<CNPhoneNumber>).value.stringValue
        case CNLabelHome:phoneContact?.homePhone = (number as! CNLabeledValue<CNPhoneNumber>).value.stringValue
        case CNLabelWork:phoneContact?.workPhone = (number as! CNLabeledValue<CNPhoneNumber>).value.stringValue
        default:phoneContact?.mobilePhone = (number as! CNLabeledValue<CNPhoneNumber>).value.stringValue
        }
} else {
   // Fallback on earlier versions

   }

ContactBook代码有效,但是在CNLabeledValue之前的iOS 9之前使用了什么?有没有要使用的框架?

swift uitableview contacts addressbook didselectrowatindexpath
1个回答
0
投票
Contacts框架(CN*)已在iOS 9中添加。在此之前,我们使用了AddressBook framework。那里没有等效的CNLabledValue。最接近的是ABMultiValue,它是CoreFoundation类型。

注意,当前文档经常建议其中某些类型仅在macOS 12+中存在,但这是不正确的。其中许多确实存在于旧版本的iOS中。

© www.soinside.com 2019 - 2024. All rights reserved.