advertisement

Article:
  BYOB: Build Your Own Browser, Part 2
Subject:   Gah!
Date:   2005-06-29 19:28:52
From:   Abcu
I'm getting errors and warnings such as:
warning: 'WebFrame' may not respond to '-loadRequest:'
warning: (Messages without a matching method signature
warning: will be assumed to return 'id' and accept
warning: '...' as arguments.)
error: wrong type argument to unary minus
warning: 'WebFrame may not respond to '-loadRequest:'
warning: 'WebFrame may not respond to '-loadRequest:'
warning: 'WebFrame may not respond to '-provisionalDataSource'.


The errror "wrong type argument to unary minus" showed up associated with line "- (id)webView;" in the following block:


- (IBAction)connectURL:(id)sender{
- (id)webView;
[urlString setStringValue:[sender stringValue]];
[[webView mainFrame] loadRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:
[sender stringValue]]]];


Did I do something wrong?


Here's my code:
//
// MyDocument.m
// Spitfire II
//
// Created by John on 6/29/05.
// Copyright __MyCompanyName__ 2005 . All rights reserved.
//


#import "MyDocument.h"
static NSString *defaultHP =@"http://www.macdevcenter.com";
@implementation MyDocument


- (id)init
{
self = [super init];
if (self) {

// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.

}
return self;
}


- (NSString *)windowNibName
{
// Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
return @"MyDocument";
}


- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
[webView setUIDelegate:self];
[webView setGroupName:@"MyDocument"];
[urlString setStringValue:defaultHP];
[[webView mainFrame] loadRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:defaultHP]]];
[webView setFrameLoadDelegate:self];
// Add any code here that needs to be executed once the windowController has loaded the document's window.
}


- (NSData *)dataRepresentationOfType:(NSString *)aType
{
// Insert code here to write your document from the given data. You can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.

// For applications targeted for Tiger or later systems, you should use the new Tiger API -dataOfType:error:. In this case you can also choose to override -writeToURL:ofType:error:, -fileWrapperOfType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.


return nil;
}


- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
// Insert code here to read your document from the given data. You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead.

// For applications targeted for Tiger or later systems, you should use the new Tiger API readFromData:ofType:error:. In this case you can also choose to override -readFromURL:ofType:error: or -readFromFileWrapper:ofType:error: instead.

return YES;
}


- (IBAction)connectURL:(id)sender{
- (id)webView;
[urlString setStringValue:[sender stringValue]];
[[webView mainFrame] loadRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:
[sender stringValue]]]];
}


- (id)webView
{
return webView;
}
- (WebView *)webView:(WebView *)sender
createWebViewWithRequest:
(NSURLRequest *)request
{
id myDocument = [
[NSDocumentController
sharedDocumentController]
openUntitledDocumentOfType:
@"DocumentType"
display:YES];


[[[myDocument webView] mainFrame]
loadRequest:request];

return [myDocument webView];
}


- (void)webViewShow:(WebView *)sender
{
id myDocument = [[NSDocumentController
sharedDocumentController]
documentForWindow:
[sender window]];
[myDocument showWindows];
}
-(void)setDefaultHomepage:(NSString*)homepage{
defaultHP = homepage;
}


-(NSString *)getDefaultHomepage{
return defaultHP;
}
- (void)webView:(WebView *)sender
didStartProvisionalLoadForFrame:
(WebFrame *)frame


{
// Only report feedback for the main frame.
if (frame == [sender mainFrame]){
NSString *url = [[[
[frame provisionalDataSource]
request] URL] absoluteString];

[urlString setStringValue:url];
}
}


@end



Here is the header:


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


@interface MyDocument : NSDocument
{
IBOutlet id urlString;
IBOutlet WebView *webView;
}
- (void)setDefaultHomepage:(NSString*) homepage;
-(NSString *)getDefaultHomepage;
- (IBAction)connectURL:(id)sender;
@end


Please help!


1 to 1 of 1
  1. Gah!
    2005-07-13 19:46:08  valiantsoul [View]

1 to 1 of 1