0

我正在尝试使用 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." )

欢迎提出建议。盖伊

4

1 回答 1

1

升级到 RubyMotion 1.9 包括此修复:

  • 修复了编译器中的错误,即无法为接受指向 CoreFoundation 类型的指针的 API 提供 :object 类型的指针对象(例如 CFErrorRef*)。

sudo motion update会给你这个。

于 2012-06-01T01:46:12.693 回答