System.KeychainCount
From Xojo Documentation
Read-Only Property (As Integer )
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 number of available Keychains (macOS only).
Notes
This number includes all Keychains within the Keychains folder as well as any other Keychains known to the Keychain's manager.
Example
The following example adds a KeychainItem for an application and assigns a password. It first checks to make sure that there are some keychain items.
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)