KeyChainItem

From Xojo Documentation
Jump to: navigation, search

Class (inherits from Object)


Refers to a Macintosh Keychain item.


Properties
AccountName Description Label
Comment Handle ReadOnlyProperty.png ServiceName


Methods
Delete


Notes

KeyChainItems can access passwords for applications only, not internet passwords.

Examples

The following example adds a KeyChainItem for an application and assigns a password.

Dim 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
MsgBox("You don't have a key chain.")
End If

Exception err As KeyChainException
MsgBox("Can't add item: " + err.Message)

The following example retrieves the password and displays it in a message box.

Dim itemToFind As KeyChainItem
Dim password As String

itemToFind = New KeyChainItem
// Indicate the name of the application whose keychain item you wish to find
itemToFind.ServiceName = "MyApplication"

// get application's password from the system keychain
password = System.KeyChain.FindPassword(itemToFind)
MsgBox("The password for this item is: " + password)

Exception err As KeyChainException
MsgBox("Can't find item: " + err.Message)

See Also

KeyChain class; KeyChainException error; System module.

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About