I’m currently trying to set up a nice back button contextual menu for my browser. It populates itself with items from the array provided by -backListWithLimit, complete with item titles and icons. Each item has its representedObject set to its respective WebHistoryItem and its action set to goToHistoryItem:, a method of mine which grabs the sender’s representedObject and attempts to tell the main webView to navigate to that history item. Here’s the code:
- (IBAction)goToHistoryItem:(id)sender
{
WebHistoryItem *historyItem = [sender representedObject];
[[mainWebView backForwardList] goToItem:historyItem];
}
The menu renders perfectly, with each item appropriately titled and badged. For some reason, though, selecting an item simply fails. I’ve checked with NSLog, and the WebHistoryItem IS getting passed along… the webView just won’t do anything with it. It leaves no error, no console log, nothing, and I can’t figure out where I’ve gone wrong.
Am I missing something here? Why doesn’t this work?
Well, I ended up figuring it out. Turns out I needed to use [webView goToBackForwardItem:] instead of [[webView backForwardList] goToItem:].