SFKeychainSavePanel Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/SecurityInterface.framework
Availability
Available in OS X v10.3 and later
Companion guide
Declared in
SFKeychainSavePanel.h

Overview

The SFKeychainSavePanel class displays a sheet or panel that allows the user to create a keychain.

The following figure shows an example of a keychain save panel.

Figure 1  Keychain save panel
Keychain save panel

Tasks

Returning a Shared Keychain Save Panel Object

Displaying a Sheet or Panel

Returning Information from the Sheet or Panel

Class Methods

sharedKeychainSavePanel

Returns a shared keychain save panel object. If the object has not already been created, this method allocates and initializes the object first.

+ (SFKeychainSavePanel *)sharedKeychainSavePanel
Availability
  • Available in OS X v10.3 and later.
Declared In
SFKeychainSavePanel.h

Instance Methods

beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:

Displays a sheet that allows a user to create a new keychain.

- (void)beginSheetForDirectory:(NSString *)path file:(NSString *)name modalForWindow:(NSWindow *)docWindow modalDelegate:(id)delegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo
Parameters
path

The path to the folder where the keychain is created. Specify nil for ~/Library/Keychains.

name

The keychain name to be automatically displayed in the Save As field of the sheet.

docWindow

The parent window to which the sheet is attached. If this parameter is nil, the behavior defaults to a standalone modal window.

delegate

The delegate object in which the method specified in the didEndSelector parameter is implemented.

didEndSelector

A method selector for a delegate method called after the modal session has ended, but before the sheet has been dismissed. Implementation of this delegate method is optional.

contextInfo

A pointer to data that is passed to the delegate method. You can use this data pointer for any purpose you wish.

Discussion

The delegate method has the following signature:

-(void)createPanelDidEnd:(NSWindow *)sheet
       returnCode:(int)returnCode
       contextInfo:(void *)contextInfo

The parameters for the delegate method are:

sheet

The window to which the sheet was attached.

returnCode

The result code indicating which button the user clicked: either NSFileHandlingPanelOKButton or NSFileHandlingPanelCancelButton.

contextInfo

Client-defined contextual data that is passed in the contextInfo parameter of the beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo: method.

The delegate method may dismiss the keychain settings sheet itself; if it does not, the sheet is dismissed on return from the beginSheetForDirectory:... method.

Use the keychain method to obtain the keychain created by the user.

Availability
  • Available in OS X v10.3 and later.
Declared In
SFKeychainSavePanel.h

error

Returns the last error encountered by the keychain save panel.

- (NSError *)error
Availability
  • Available in OS X v10.5 and later.
Declared In
SFKeychainSavePanel.h

keychain

Returns the keychain created by the keychain save panel.

- (SecKeychainRef)keychain
Availability
  • Available in OS X v10.3 and later.
Declared In
SFKeychainSavePanel.h

runModalForDirectory:file:

Displays a panel that allows a user to create a new keychain.

- (NSInteger)runModalForDirectory:(NSString *)path file:(NSString *)name
Parameters
path

The path to the folder where the keychain is created. Specify nil for ~/Library/Keychains.

name

The keychain name to be automatically displayed in the Save As field of the panel.

Discussion

This method returns a result code from the runModalForDirectory:file: method of the NSSavePanel class: NSFileHandlingPanelOKButton if the user clicks the OK button or NSFileHandlingPanelCancelButton if the user clicks the Cancel button.

Use the keychain method to obtain the keychain created by the user.

Availability
  • Available in OS X v10.3 and later.
Declared In
SFKeychainSavePanel.h

setPassword:

Specifies the password for the keychain that will be created.

- (void)setPassword:(NSString *)password
Parameters
password

The password to be used for the new keychain.

Discussion

This method is optional. If you don’t call this method, the keychain save panel displays a password-entry dialog.

Availability
  • Available in OS X v10.3 and later.
Declared In
SFKeychainSavePanel.h