"Binary operator '<' cannot be applied to two CFIndex operands" - 从ABMultiValue(地址簿)中选择一个电话号码



我正在尝试使用AddressBook和AddressBookUI来显示地址簿的视图,用户可以在其中点击联系人,然后点击电话号码,应用程序就会收到电话号码。当我遍历ABMultiValue以查找具有所选标识符的条目时,我遇到了一个问题——for循环的行(第13行)上出现了错误"Binary operator '<' cannot be applied to two CFIndex operands"。

我已经粘贴了下面的代码——有人知道为什么会发生这种情况吗?我能做些什么来修复它吗?谢谢

func peoplePickerNavigationController(peoplePicker: ABPeoplePickerNavigationController!, didSelectPerson person: ABRecord!, property: ABPropertyID, identifier: ABMultiValueIdentifier) {
    self.peoplePickerNavigationController(peoplePicker, shouldContinueAfterSelectingPerson: person, property: property, identifier: identifier)
    // Get name
    //    If wanting a composite name including prefix, suxif, title, both names etc:
    //    NSString *contactName = CFBridgingRelease(ABRecordCopyCompositeName(person));
    let contactName = ABRecordCopyValue(person, kABPersonFirstNameProperty)
    // Get number
    var number = String()
    let numbers = ABRecordCopyValue(person, kABPersonPhoneProperty)
    for var index:CFIndex = 0; index < ABMultiValueGetCount(numbers); ++index{
        if identifier = ABMultiValueGetIdentifierAtIndex(numbers, index) {
            number = ABMultiValueCopyValueAtIndex(numbers, index)
        }
    }
}

仅使用正常数字进行循环:

for index in 0 ..< ABMultiValueGetCount(numbers) {

最新更新