Programmatically open up Help Book.

I want to trigger opening the help documentation of my macOS game.

In my info.plist I have:

Code Block
<key>CFBundleHelpBookFolder</key>
        <string>TrainHelp</string>
        <key>CFBundleHelpBookName</key>
        <string>Hexa Trains Help</string>


What code will kick off a (browser) window with the documentation?

I have included TrainHelp/ReadMe.html in my Resource bundle.

Replies

I ended up with this:
Code Block
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFStringRef resourceName = (bridge CFStringRef)@"ReadMe";
CFStringRef resourceType = (bridge CFStringRef)@"html";
CFStringRef resourceDir  = (__bridge CFStringRef)@"TrainHelp";
CFURLRef url = CFBundleCopyResourceURL( mainBundle, resourceName, resourceType, resourceDir );
OSStatus s = LSOpenCFURLRef(url, 0);
if (s) NSLog( @"Failed to open help documentation." );
CFRelease( url );

Although it seems to me that this could have been done an easier way.