我正在尝试使用 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." )
欢迎提出建议。盖伊