gpt4 book ai didi

ios - ABAddressBookGetPersonWithRecordID 使我的应用程序崩溃

转载 作者:行者123 更新时间:2023-11-29 01:38:00 25 4
gpt4 key购买 nike

我目前正在开发的应用程序必须使用委托(delegate)来检索联系人的 ABRecord,因为对象的所有关联联系人的表都在容器 View 中。到目前为止一切正常,唯一的问题是当我尝试从 AddressBook View Controller 向后移动后再次检索记录时,应用程序崩溃了。这是错误的屏幕截图和代码:

Error on ABRecord

代码

func showContactInterface(contacto: AnyObject) {
print(self.addressBookRef)

let peopleViewController = ABPersonViewController()

let recordID:ABRecordID = (((contacto as! Contacto).valueForKey("recordRef")?.intValue) as ABRecordID?)!

var recordRef:ABRecordRef? = ABAddressBookGetPersonWithRecordID(self.addressBookRef, recordID).takeRetainedValue()

peopleViewController.displayedPerson = recordRef!
self.navigationController?.pushViewController(peopleViewController, animated: true)
}

最佳答案

我遇到了同样的问题。我不完全确定为什么,但是将 takeRetainedValue() 更改为 takeUnretainedValue() 解决了这个问题。

var recordRef:ABRecordRef? ABAddressBookGetPersonWithRecordID(self.addressBookRef, recordID).takeUnretainedValue()

关于ios - ABAddressBookGetPersonWithRecordID 使我的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32747312/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com