Help Yourself Help Others
by James Duncan Davidson05/25/2001
Among the myriad features in Mac OS X is an integrated "help" system called Apple Help. Apple Help was introduced in Mac OS 8.5 as part of Carbon and has been updated in each system release since then.
The Help Viewer displays help content authored using the industry standard HTML 3.2 specification. This means that you can use your favorite tool, such as Dreamweaver or GoLive, to edit your documentation.
It can display any media supported by QuickTime which means that most of the major image formats are supported, as are videos and Flash content (such as the animation that welcomes you when you first launch Apple Help from the Finder). It uses Sherlock functionality to allow searching of a help book, or even all help books in the system. And, it can serve content from either the local system or over the Internet allowing frequently updated docs to be accessible to users.
As part of OS X, Apple Help comes with these new features:
An API for registering application help books with the system.
An API for calling into the Help Viewer from your application.
The ability to package Help into application bundles.
Recipe to add a help book to your app
To add a help book to your application requires following a simple recipe.
|
More Apple Worldwide Developers Conference Coverage: Jobs to Developers: 'A Problem or an Opportunity?' Java Plays Prominent Role at WWDC 2001 Mac Technologies Enabled for Java Related Books: |
First, two keys must be placed in your application's Info.plist. These entries are the CFBundleHelpBookFolder key and the
CFBundleHelpBookName key. The CFBundleHelpBookFolder
points to the directory inside your application bundle's Resource
directory that contains your help files. The CFBundleHelpBookName key contains the name of your help book's title. When these two keys are placed in your application's Info.plist file, they will look something like:
<key>CFBundleHelpBookFolder</key>
<value>
<string>MyCoolApp Help</string>
</value>
<key>CFBundleHelpBookName</key>
<value>
<string>MyCoolApp Help</string>
</value>
There are two other keys that must be part of the Info.plist file, and that should be already set by your application. These are they CFBundleName and CFBundleIdentifier keys.
These keys are discussed in the book Inside Mac OS X: System Overview. Briefly, they let the system know the name of the bundle and give it an identifier to use when saving preferences and other information.
To finish the recipe of adding help to an application, you will need a bit of content. A very simple amount of content for your help would be a single index.html file containing the following HTML:
<html>
<head>
<meta name="AppleTitle" content="MyCoolApp Help"/>
<title>MyCoolApp Help</title>
</head>
<body>
<h1>Welcome to MyCoolApp's Help!</h1>
<p>Content...</p>
</body>
</html>
The most important part of this file is the meta tag with a name of AppleTitle. This tag must contain a value that matches the value of the CFBundleHelpBookName key defined above in the Info.plist. Of course, for a real help system, you would want to provide quite a bit more content in the form of many more HTML pages, but for the sake of this example, we'll keep it simple.
Once you have these keys defined, and your help is copied into the correct directory in your Application's Bundle (this is easy enough to do if you are using Project Builder to build your application), then everything just works. When your application tells the system to display help (a feature built into Cocoa applications for free), then the Help Viewer will open up and show you the following page.
|
There is much more to providing effective help functions to your application. The Apple Help system allows your help to launch AppleScripts and to provide advanced hints to the indexing engine. This article is intended to give you the absolute basics to get started. You can find out all about it by reading the documentation that comes with the Developer Tools.
James Duncan Davidson is a freelance author, software developer, and consultant focusing on Mac OS X, Java, XML, and open source technologies. He currently resides in San Francisco, California.
Return to the Mac DevCenter.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 7 of 7.
-
slm
2007-04-07 19:39:41 minikperi222 [Reply | View]
barbie oyunlari (http://minik_barbie_oyunlari.sitemynet.com)
en kral oyunlar (http://www.oyunfan.com)
kraloyun (http://www.oyunzap.com)
minik peri (http://minikperi_oyunlari.sitemynet.com/)
-
Anyone make this work?
2004-09-11 19:32:54 steve_bryan [Reply | View]
Can anyone get these instructions to work? Like many otherwise helpful articles I suppose I'm missing something simple or the author left out something that was supposed to be obvious. Whatever the case is I'm missing something and I never get a positive response for my Cocoa app when I try to select from the Help menu. When I goggled the topic on comp.sys.mac.programers.* there seem to be a lot of people facing a similar situation. It seems as though there is some piece of the puzzle which isn't quite being revealed.
What has me puzzled is why they think something is finished when it is as fragile as this. If you want developers to make help available then make it easy, not a black art to provide. Maybe make a utility application that causes all the right things to happen whether you know all the secret handshakes. Damn this gets frustrating. -
Anyone make this work?
2004-09-11 21:55:54 steve_bryan [Reply | View]
Here is the step that was missing in my earlier attempt. The text that appears in the Help menu item in your MainMenu.nib file is crucial. It has to exactly match the text you have entered elsewhere or the whole thing simply, quietly fails. So, for instance, if you have multiple targets that are slight variants and they have different names to avoid collisions, those variations will prevent the instructions given above from working. It is for reasons like this that the "for dummies" series have been so successful. You assume almost nothing and explain in complete detail so that trivial errors are avoided. Oh, well. It only slowed me down a few hours.
For others encountering this topic I would recommend the instructions about Help given in the documentation folder of the Developer folder. In particular the Tutorial points out the pitfall that got me.
-
Warning about plist keys
2001-05-30 14:04:07 chaoswerks [Reply | View]
Be certain that your app's Info.plist file does not contain the NSHelpFile key which is a legacy key from the old Cocoa-specific help system.
-
Errata about the HTML
2001-05-30 11:32:23 James Duncan Davidson |
[Reply | View]
Apple's engineers have stated on the cocoa-dev mailing list that the syntax that I gave in the article for the META tag might be problematic in some future version of the help system. Even though it works fine under OS X 10.0.3 where I tested the code, it could break at some point in the future.
The tag I gave is <meta name="AppleTitle" content="MyCoolApp Help"/>. This is written using XHTML syntax which always makes sure that empty tags are really closed with an ending slash. Because Apple has committed to supporting HTML 3.2, and HTML 3.2 doesn't have this syntax feature of XHTML, there could be a potential future problem if the parser becomes more strict.
Because of this potential future hazard, I've put in a request to have the HTML snippet fixed in the article. However, because XML is an important feature in OS X (configuration files, etc) and XHTML is the dialect of HTML that authors should be using, I have also put in a feature request to Apple to migrate the Help system to XHTML, or to at least ensure that XHTML is a supported content type in addition to HTML 3.2.
What do you think? Should Apple have XHTML support in Apple Help?






