ABPeoplePickerNavigationController应该在SelectingPerson弃用之后继续

编程入门 行业动态 更新时间:2024-10-25 04:17:36
本文介绍了ABPeoplePickerNavigationController应该在SelectingPerson弃用之后继续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

由于我将xcode 6的版本更新为beta 3,因此AddressBookUI遇到了很多麻烦.

Since i update my version of xcode 6 to beta 3 i having a lot of trouble with AddressBookUI.

在阅读Apple API文档时,我看到了该功能:

Reading the Apple API documentation i saw the function:

func peoplePickerNavigationController(peoplePicker: ABPeoplePickerNavigationController!, shouldContinueAfterSelectingPerson person: ABRecordRef!) -> Bool {}

在iOS 8中已弃用.如何将该方法更新为正确的版本?

Was deprecated in IOS 8. How can i update this method to the correct version?

在这种方法中,我有代码:

in this method i have the code:

var dadosContato: Dictionary<String, String> = ["firstName": "", "lastName": "","mobileNumber": "", "homeNumber": ""] //NOME var firstName: Unmanaged<AnyObject> = ABRecordCopyValue(person, kABPersonFirstNameProperty) dadosContato["firstName"] = firstName.takeRetainedValue() as? String //SOBRENOME var lastName: Unmanaged<AnyObject> = ABRecordCopyValue(person, kABPersonLastNameProperty) dadosContato["lastName"] = lastName.takeRetainedValue() as? String //RECEBENDO OS TELEFONES var phones: ABMultiValueRef = ABRecordCopyValue(person, kABPersonPhoneProperty).takeUnretainedValue() as ABMultiValueRef for var index = 0; index < ABMultiValueGetCount(phones); ++index{ let currentPhoneLabel = ABMultiValueCopyLabelAtIndex(phones, index).takeUnretainedValue() as CFStringRef as String let currentPhoneValue = ABMultiValueCopyValueAtIndex(phones, index).takeUnretainedValue() as CFStringRef as String if currentPhoneLabel == kABPersonPhoneMobileLabel { dadosContato["mobileNumber"] = currentPhoneValue } if currentPhoneLabel == kABHomeLabel { dadosContato["homeNumber"] = currentPhoneValue } }

在编译时出现一个错误:

With one when i compile i get the error:

Bitcast requires both operands to be pointer or neither %143 = bitcast %objc_object* %142 to %PSs9AnyObject_, !dbg !511 Bitcast requires both operands to be pointer or neither %144 = bitcast %PSs9AnyObject_ %143 to i8*, !dbg !511 Bitcast requires both operands to be pointer or neither %221 = bitcast %objc_object* %220 to %PSs9AnyObject_, !dbg !517 Bitcast requires both operands to be pointer or neither %222 = bitcast %PSs9AnyObject_ %221 to i8*, !dbg !517 Bitcast requires both operands to be pointer or neither %297 = bitcast %objc_object* %296 to %PSs9AnyObject_, !dbg !522 Stored value type does not match pointer operand type! store %PSs9AnyObject_ %297, %objc_object** %298, align 8, !dbg !522 %objc_object*Stored value type does not match pointer operand type! store %PSs9AnyObject_ %297, %objc_object** %303, align 8, !dbg !526 %objc_object*Stored value type does not match pointer operand type! store %PSs9AnyObject_ %297, %objc_object** %319, align 8, !dbg !530 %objc_object*Stored value type does not match pointer operand type! store %PSs9AnyObject_ %297, %objc_object** %349, align 8, !dbg !539 %objc_object*Bitcast requires both operands to be pointer or neither %380 = bitcast %objc_object* %379 to %PSs9AnyObject_, !dbg !542 Bitcast requires both operands to be pointer or neither %381 = bitcast %PSs9AnyObject_ %380 to i8*, !dbg !542 LLVM ERROR: Broken function found, compilation aborted! Command /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 1

推荐答案

您有一半的答案是我没有的. 您需要先执行检查,然后才能在手机中使用代码:

you have the half of the answer I not had. You need to implement a check before use your code in phone:

let phoneV: ABMultiValueRef = ABRecordCopyValue(record, kABPersonPhoneProperty).takeUnretainedValue() as ABMultiValueRef if ABMultiValueGetCount(phoneV) > 0 { var phones: ABMultiValueRef = ABRecordCopyValue(contactPerson, kABPersonPhoneProperty).takeUnretainedValue() as ABMultiValueRef for var index = 0; index < ABMultiValueGetCount(phones); ++index{ let currentPhoneLabel = ABMultiValueCopyLabelAtIndex(phones, index).takeUnretainedValue() as CFStringRef as String let currentPhoneValue = ABMultiValueCopyValueAtIndex(phones, index).takeUnretainedValue() as CFStringRef as String if currentPhoneLabel == kABPersonPhoneMobileLabel { println(currentPhoneValue) } if currentPhoneLabel == kABHomeLabel { println(currentPhoneValue) } } }

更多推荐

ABPeoplePickerNavigationController应该在SelectingPerson弃用之后继续

本文发布于:2023-10-27 11:41:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533251.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ABPeoplePickerNavigationController   SelectingPerson

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!