CocoaDev

Edit AllPages

Hi, I’m modifying my WebView subclass (DXWebView) so I can display custom menus for links. The menu is created, displayed correctly and all, but I can’t get NSWorkspace actions on the subclass to worl, here is the code:

DXWebView.h

/* DXWebView */

#import <Cocoa/Cocoa.h> #import <WebKit/WebView.h> #import <WebKit/WebUIDelegate.h>

@interface DXWebView : WebView { NSString *urlLink;

NSMenuItem *menuOpenSafari;
NSMenuItem *menuDownloadAttachment; }

@end

DXWevView.m

@implementation DXWebView

@end

So, when i load an html file and control-click on the link, the menu with the two menu items declared and set there are displayed. But when I click the one that calls openWithSafari, I get this:

2005-09-25 11:11:47.296 Flexus[477] ** -[NSURL length]: selector not recognized 2005-09-25 11:11:47.397 Flexus[477] ** -[NSURL length]: selector not recognized

I don’t know why that happens, when I log urlLink, the string is fine, but somehow the URL created from it gets messed up. Any ideas? Thank you in advance -FernandoLucasSantos


The object for WebElementLinkURLKey is an NSURL, but you’re treating it like an NSString. Hence, [NSURL URLWithString:urlLink] will fail, because urlLink is already an NSURL.


feels dumb - Thank you very much!