0
验证码失败Semgentation故障:11,我不明白为什么MacRuby的指针typedef结构
framework 'Cocoa'
framework 'CoreFoundation'
framework 'Security'
* keychainObject = Pointer.new_with_type('^{OpaqueSecKeychainRef}')
SecKeychainOpen("/Users/charbon/Library/Keychains/Josja.keychain",keychainObject)
SecKeychainLock(keychainObject)
我敢肯定,它与keychainObject类型做,因为这个工程(它锁默认钥匙串)。
SecKeychainLock(nil)
我使用“^ {} OpaqueSecKeychainRef”为指针的类型,因为这是调试器告诉我,它预计,当我使用了错误类型的指针。
我希望解决这个问题有助于抓住macruby/cocoa魔术。
仅供参考,完整的输出是
cobalt:~ charbon$ macirb Desktop/test.rb
irb(main):001:0> framework 'Cocoa'
=> true
irb(main):002:0> framework 'CoreFoundation'
=> true
irb(main):003:0> framework 'Security'
=> true
irb(main):004:0> * keychainObject = Pointer.new_with_type('^{OpaqueSecKeychainRef}')
=> [#<Pointer:0x4007ac200>]
irb(main):005:0> SecKeychainOpen("/Users/charbon/Library/Keychains/Josja.keychain",keychainObject)
=> 0
irb(main):006:0> SecKeychainLock(keychainObject)
Segmentation fault: 11
感谢弗雷德的提示!不应该在keychainObject之前使用*作为第三行? SecKeychainOpen(“/ Users/charbon/Library/Keychains/Josja.keychain”,* keychainObject) – MichaelC
不可以。 *在红宝石是完全不同的 –
好吧,明白了,谢谢。在这里发布“反向”问题:http://stackoverflow.com/questions/17902293/macruby-pointer-referencing-dereferencing-when-using-cocoa-frameworks – MichaelC