在MacRuby Pointer to typedef struct上,我学习了如何取消引用使用创建的指针
x=Pointer.new_with_type
...
==> use x.value, or x[0]
工作一种享受!
现在我想了解我认为的“对立面”。我正在尝试使用这个 API。
OSStatus SecKeychainCopySettings (
SecKeychainRef keychain,
SecKeychainSettings *outSettings
);
第二个参数必须是一个指针。但我从来没有设法打开钥匙串的真正 outSettings,我只得到默认设置。
framework 'Security'
keychainObject = Pointer.new_with_type('^{OpaqueSecKeychainRef}')
SecKeychainOpen("/Users/charbon/Library/Keychains/Josja.keychain",keychainObject)
#attempt #1
settings=Pointer.new_with_type('{SecKeychainSettings=IBBI}')
SecKeychainCopySettings(keychainObject.value, settings)
p settings.value
#<SecKeychainSettings version=0 lockOnSleep=false useLockInterval=false lockInterval=0>
#attempt #2
settings2=SecKeychainSettings.new
result = SecKeychainCopySettings(keychainObject.value, settings2)
p settings2
#<SecKeychainSettings version=0 lockOnSleep=false useLockInterval=false lockInterval=0>
打开的钥匙串的设置应为
#<SecKeychainSettings version=0 lockOnSleep=true useLockInterval=true lockInterval=1800>
我错过了什么?