我试图使用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)
}
}
}发布于 2015-06-30 04:33:51
只需循环使用正常数字:
for index in 0 ..< ABMultiValueGetCount(numbers) {https://stackoverflow.com/questions/31129559
复制相似问题