Mac Developer Library

Developer

AppKit Framework Reference NSHelpManager Class Reference

Options
Deployment Target:

On This Page
Language:

NSHelpManager

The NSHelpManager class provides an approach to displaying online help. An application contains one NSHelpManager object.

  • Returns the shared NSHelpManager instance, creating it if it does not already exist.

    Declaration

    Swift

    class func sharedHelpManager() -> NSHelpManager

    Objective-C

    + (NSHelpManager *)sharedHelpManager

    Return Value

    Shared help manager.

    Availability

    Available in OS X v10.0 and later.

  • Performs a search for the specified string in the specified book.

    Declaration

    Swift

    func findString(_ query: String, inBook book: String?)

    Objective-C

    - (void)findString:(NSString *)query inBook:(NSString *)book

    Parameters

    query

    String to search for.

    book

    Localized help book to search. When nil, all installed help books are searched.

    Discussion

    To search for a string in your bundle’s localized help book, you could use code similar to the following:

    1. NSString *locBookName = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleHelpBookName"];
    2. [[NSHelpManager sharedHelpManager] findString:@"Hello" inBook:locBookName];

    This is a wrapper for AHRegisterHelpBook (which is called only once to register the help book specified in the application's main bundle) and AHSearch.

    Availability

    Available in OS X v10.3 and later.

  • Finds and displays the text at the given anchor location in the given book.

    Declaration

    Swift

    func openHelpAnchor(_ anchor: String, inBook book: String?)

    Objective-C

    - (void)openHelpAnchor:(NSString *)anchor inBook:(NSString *)book

    Parameters

    anchor

    Location of the desired text.

    book

    Help book containing the anchor. When nil, all installed help books are searched.

    Discussion

    To open an anchor in your bundle’s localized help book, you could use code similar to the following:

    1. NSString *locBookName = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleHelpBookName"];
    2. [[NSHelpManager sharedHelpManager] openHelpAnchor:@"anchor1" inBook:locBookName];

    This method is a wrapper for AHRegisterHelpBook (which is called only once to register the help book specified in the application's main bundle) and AHLookupAnchor.

    Availability

    Available in OS X v10.3 and later.

  • Registers one or more help books in the given bundle.

    Declaration

    Swift

    func registerBooksInBundle(_ bundle: NSBundle) -> Bool

    Objective-C

    - (BOOL)registerBooksInBundle:(NSBundle *)bundle

    Parameters

    bundle

    The bundle for additional help books. Books in the main bundle are automatically registered.

    Return Value

    YEStrue if registration is successful, NOfalse if if the bundle doesn't contain any help books or if registration fails.

    Discussion

    You use registerBooksInBundle: to register help books in, for example, a plug-in bundle. The Info.plist in the bundle should contain a help book directory path, which specifies one or more folders containing help books.

    The main bundle is automatically registered by openHelpAnchor:inBook: and findString:inBook: .

    Availability

    Available in OS X v10.6 and later.

  • Indicates whether context-sensitive help mode is active.

    Declaration

    Swift

    class func isContextHelpModeActive() -> Bool

    Objective-C

    + (BOOL)isContextHelpModeActive

    Return Value

    YEStrue when the application is in context-sensitive help mode, NOfalse otherwise.

    Discussion

    In context-sensitive help mode, when a user clicks a user interface item, help for that item is displayed in a small window just below the cursor.

    Availability

    Available in OS X v10.0 and later.

  • Specifies whether context-sensitive help mode is active.

    Declaration

    Swift

    class func setContextHelpModeActive(_ active: Bool)

    Objective-C

    + (void)setContextHelpModeActive:(BOOL)contextHelpActive

    Parameters

    contextHelpActive

    YEStrue turns on context-sensitive help, NOfalse turns it off.

    Discussion

    You never send this message directly; instead, the NSApplication method activateContextHelpMode: activates context-sensitive help mode, and the first mouse click after displaying the context-sensitive help window deactivates it.

    When the application enters context-sensitive help mode, the help manager posts an NSContextHelpModeDidActivateNotification to the default notification center. When the application returns to normal operation, the help manager posts an NSContextHelpModeDidDeactivateNotification.

    Availability

    Available in OS X v10.0 and later.

  • Associates help content with an object.

    Declaration

    Swift

    func setContextHelp(_ attrString: NSAttributedString, forObject object: AnyObject)

    Objective-C

    - (void)setContextHelp:(NSAttributedString *)help forObject:(id)object

    Parameters

    help

    Help content to associate with object.

    object

    Object to associate with help.

    Discussion

    When the application enters context-sensitive help mode, if object is clicked, help appears in the context-sensitive help window.

    Availability

    Available in OS X v10.0 and later.

  • Removes the association between an object and its context-sensitive help.

    Declaration

    Swift

    func removeContextHelpForObject(_ object: AnyObject)

    Objective-C

    - (void)removeContextHelpForObject:(id)object

    Parameters

    object

    Object to disassociate from its help content.

    Discussion

    If object does not have context-sensitive help associated with it, this method does nothing.

    Availability

    Available in OS X v10.0 and later.

  • Posted when the application enters context-sensitive help mode. This typically happens when the user holds down the Help key.

    The notification object is the help manager. This notification does not contain a userInfo dictionary.

    Declaration

    Swift

    let NSContextHelpModeDidActivateNotification: String

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Posted when the application exits context-sensitive help mode. This happens when the user clicks the mouse button while the cursor is anywhere on the screen after displaying a context-sensitive help topic.

    The notification object is the help manager. This notification does not contain a userInfo dictionary.

    Declaration

    Swift

    let NSContextHelpModeDidDeactivateNotification: String

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.