Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
I've just finished implementing a Help book in my app, which works like a charm when run from Help > Search, and Help > MyApp Help in the toolbar.

However, I want to be able to call the Help-docs from within the app, and for this I used NSHelpManager:eek:penHelpAnchor:inBook which should be as easy as follows:

Code:
[[NSHelpManager sharedHelpManager] openHelpAnchor:@"testanchor" inBook:@"MyApp Help"];

In one of my pages in the help docs I insert the following somewhere in the body:

Code:
<a name="testanchor"></a>

Upon calling the code, however, the help-window opens but I am greeted with the following alert:
"Help Viewer cannot open this content."

I've double-checked the name of both the anchor and the Help book and they are correct. I don't really know where to look for other potential causes for this error and documentation of this function is no help here. Any ideas?


[ EDIT 1 ]

The findString-function will work, but instead of jumping directly to the right passage it lists the page with the string in the index. Not as smooth as the openHelpAnchor is supposed to...

This also leads me to believe that the problem for openHelpAnchor relates to the syntax of my anchor. So I've tried setting both id and name in the anchor to "testanchor", but without success.


[ EDIT 2 ]

I forgot to mention that you will need to tick the "Index anchor information in all files"-box in the Help Indexer for all the anchors to be indexed and accessible. Still no luck with my app, though, so I'll continue my search.


[ EDIT 3 ]

Here's the actual doc for clues. It is located one folder below the index.html in folder "pgs".

MyApp Help/pgs/navigation.html
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>


	<!-- TITLE + KEYWORDS + DESCRIPTION (EDIT) -->
	<title>Navigation</title>
	<meta name="keywords" content="navigation, navigating, go forward, go back"/>
	<meta name="description" content="Learn how to navigate."/>


	<!-- Needed for anchors to be indexed -->
	<meta name="robots" content="anchors"/>
	<link href="../sty/task.css" rel="stylesheet" type="text/css" media="all"/>
</head>

<body id="apple-pd">

....

<!-- ANCHOR -->
<a name="testanchor"></a>

....

</body>
</html>

MyApp Help/index.html
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>MyApp Help</title>
	<meta name="AppleTitle" content="MyApp Help" />
	<meta name="AppleIcon"  content="MyApp Help/gfx/APPL.icns" />	
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta name="robots" content="anchors"/>
	
	<link href="sty/home_os.css" rel="stylesheet" type="text/css" media="all" />			
</head>

<body id="apple-pd">

.....

</body>
</html>
 
Last edited:

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
SOLUTION (I hope)

Keep your "Help Book directory name" and "Help Book identifier" the same in info.plist. I had managed to insert a typo in the latter, which cost me a days work. Since the help book will open normally from the toolbar even without this being correct, this might lead you to find the solution in other places as it did with me.

Also, I'm not sure how well the Help Indexer and XCode updates the help book after re-indexinging it, since I occasionally keep getting the "Help Viewer cannot open this content"-error when inserting a new anchor (tripple-checking the syntax). This can happen even after having cleaned the project, deleted the build, closed and reopened xcode, and built it again.

And finally, don't forget to check the "Index anchor information in all files"-box in the Help Indexer, which is turned off and hidden by default.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.