2017-03-04 34 views
0

我想通过检查传递给协议功能的CNContactProperty完成联系人选择器来检测用户在与CNContactPickerViewController进行交互时选择了何种类型的属性。iOS:CNContactPicker didSelect - 如何确定所选属性的类型?

IE。告诉用户是否选择了电话号码或电子邮件等。

public func contactPicker(_ picker: CNContactPickerViewController, didSelect theContactProperty: CNContactProperty){ 

    if theContactProperty. == CNContactPhoneNumbersKey { // This doesn't work!! 
     // Do stuff when we've received a phone number 
    } 
    else { 
     // Do other stuff when we have received something other than a phone number 
    } 
} 

上面使用的“if”语句不起作用。任何想法为什么?

如何确定用户从联系人选择器屏幕中选择的属性类型?

回答

0

解决方案:

if theContactProperty.key == CNContactPhoneNumbersKey { 

} 
相关问题