I have two class (AppDelegate and WebViewController) with two nib file: one is the main window and one is a window with WebView. In AppDelegate I have this code to show WebViewController Window at launch:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
self.iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotification:) name:@"com.apple.iTunes.playerInfo" object:nil];
[self.lyricsTextView setAlignment:NSCenterTextAlignment];
[self refreshLyrics];
// Here I show my WebViewController Window
newWebViewController = [[WebViewController alloc] init];
[NSBundle loadNibNamed:@"WebViewWindow" owner:newWebViewController];
}
My WebView initialize itself correctly. In WebViewController I have this code:
- (void)goToURLFromExternal:(NSString *)urlToGo {
NSLog(@"%@", urlToGo);
NSURL *newURL = [[NSURL alloc] initWithString:urlToGo];
NSLog(@"%@", newURL);
NSURLRequest *newRequest = [[NSURLRequest alloc] initWithURL:newURL];
NSLog(@"%@", newRequest);
[self.myWebView.mainFrame loadRequest:newRequest];
}
But when I use from AppDelegate this code:
[newWebViewController goToURLFromExternal:[[urlArray objectAtIndex:0] stringValue]];
my WebView doesn’t do anything. The page loaded is still the same.
Here there is the output of console for (void)goToURLFromExternal:(NSString *)urlToGo:
2011-10-04 16:55:54.838 iTunes Lyrics[25379:707] http://lyrics.wikia.com/Cake:Dime
2011-10-04 16:55:54.838 iTunes Lyrics[25379:707] http://lyrics.wikia.com/Cake:Dime
2011-10-04 16:55:54.838 iTunes Lyrics[25379:707] <NSURLRequest http://lyrics.wikia.com/Cake:Dime>
Someone have any idea about to resolve my issue?
Thank you so much!!!
Have you link your WebViewController class with the WebViewWindow.nib?
In The WebViewWindow.nib set the File’s Owner Class property to WebViewController.