gpt4 book ai didi

ios - 如何创建通过 Ruby Motion 修改 ABAddressBook 所需的 CFErrorRef 参数

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

我正在尝试使用 Ruby Motion 向地址簿添加条目。我不知道如何正确实例化 CFErrorRef 参数。

error = nil # compiles but won't capture an error properly
# Here are my numerous attempts:
#error = Pointer.new( :object ) expected instance of Pointer of type `^{__CFError}', got `@' (TypeError)
#error = Pointer.new( '^{__CFError}' ) Can't find pointer description for type `^{__CFError}'
#error = Pointer.new( '{__CFError}' ) Can't find pointer description for type `{__CFError}'
#error = Pointer.new( '__CFError' ) Can't find pointer description for type `__CFError'
#error = Pointer.new( CFError.type ) uninitialized constant AppDelegate::CFError (NameError)
#error = Pointer.new( CFErrorRef.type ) uninitialized constant AppDelegate::CFErrorRef
p = ABPersonCreate()
raise error[0] unless ABRecordSetValue( p, KABPersonFirstNameProperty, "Guy", error )
raise error[0] unless ABRecordSetValue( p, KABPersonLastNameProperty, "Argo", error )
ab = ABAddressBookCreate()
raise error[0] unless ABAddressBookAddRecord( ab, p, error )
raise error[0] unless ABAddressBookSave( ab, error )
NSLog( "Record successfully added." )

欢迎提出建议。盖伊

最佳答案

升级到 RubyMotion 1.9 包括此修复:

  • Fixed a bug in the compiler where APIs accepting pointers to CoreFoundation types could not be given Pointer objects of the :object type (ex. CFErrorRef*).

sudo Motion update 将为您提供此信息。

关于ios - 如何创建通过 Ruby Motion 修改 ABAddressBook 所需的 CFErrorRef 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10805150/

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