0

this works in MacRuby (having required 'Security' framework)

error=SecKeychainAddGenericPassword(
                              nil,
                              "someservice".length,
                              "someservice",
                              "someusername".length,
                              "someusername",
                              "somepassword".length,
                              "somepassword".pointer,
                              nil)

In RubyMotion, there is no ".pointer" method, so I thought one would have to do :

lpointer=Pointer.new(:string)
lpointer.assign("somepassword")

But in RubyMotion this does not really store the password on the keychain. The Key is created fine, but there is no password in it.

error=SecKeychainAddGenericPassword(
                              nil,
                              "someservice".length,
                              "someservice",
                              "someusername".length,
                              "someusername",
                              "somepassword".length,
                                    lpointer,
                              nil)

What am I missing ?

MichaelC
  • 357
  • 2
  • 12

1 Answers1

1

this is working

error=SecKeychainAddGenericPassword(
                              nil,
                              "someservice".length,
                              "someservice",
                              "someusername".length,
                              "someusername",
                              "somepassword".length,
                              "somepassword".dataUsingEncoding(NSUTF8StringEncoding).bytes
                              nil)

.dataUsingEncoding makes an NSData from an NSString, and .bytes makes a Pointer to the data.

Morality : it seems

.dataUsingEncoding(NSUTF8StringEncoding).bytes

in RubyMotion is equivalent to

.pointer for an NString
MichaelC
  • 357
  • 2
  • 12