System.Keychain
From Xojo Documentation
Read-Only Property (As Keychain )
This property is only available on the macOS platform. For cross-platform compatibility, use #If...#Endif with the Target... specifiers to make sure you will not attempt to use this property on an incompatible platform. |
Returns the default Keychain (macOS only).
Notes
You can assign the default Keychain by setting this to another Keychain. If no Keychain exists, it will try to create one. If you don't want it to create one, you should first call System.KeyChainCount and check against 0.
Example
The following example adds a KeychainItem for an application and assigns a password.
Var newItem As KeychainItem
If System.KeychainCount > 0 Then
newItem = New KeychainItem
// Indicate the name of the application
newItem.ServiceName = "MyApplication"
// Create a new keychain item for the application and assign the password
System.Keychain.AddPassword(newItem, "SecretPassword")
Else
Beep
MessageBox("You don't have a key chain.")
End If
Exception e As KeychainException
MessageBox("Can't add item: " + e.Message)
If System.KeychainCount > 0 Then
newItem = New KeychainItem
// Indicate the name of the application
newItem.ServiceName = "MyApplication"
// Create a new keychain item for the application and assign the password
System.Keychain.AddPassword(newItem, "SecretPassword")
Else
Beep
MessageBox("You don't have a key chain.")
End If
Exception e As KeychainException
MessageBox("Can't add item: " + e.Message)