WebFrame does not respond to loadRequest: ?
WebFrame does not respond to loadRequest: ?
- Subject: WebFrame does not respond to loadRequest: ?
- From: Rob Frohne <email@hidden>
- Date: Tue, 24 Jun 2003 21:56:48 -0700
Hi All,
I decided I would try and play with the new WebKit, and following the
docs I tried to get a web page to display, but I get the warning when I
compile that:
main.m:93: warning: `WebFrame' does not respond to `loadRequest:'
The docs don't agree with the compiler. Nothing happens when I try to
load the page though. Here is my code in case it is of use to figure
this strange behavior out. (I modified Tiny.m, from "Cocoa
Applications" for my purposes.)
Any ideas?
Rob
//
// main.m
// Tiny
//
// A tiny cocoa application that creates a window
// and then displays graphics in it.
// Created by Rob Frohne on Sun Aug 18 2002.
// Copyright (c) 2002 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <WebKit/WebView.h>
@interface DemoView : WebView //interface of DeomView class
{
}
//-(void)drawRect:(NSRect)rect; // instance method interface
@end
@implementation DemoView // implementation of DemoView class
#define X(t) (sin(t)+1)*width*0.5
#define Y(t) (cos(t)+1)*height*0.5
/*
-(void)drawRect:(NSRect)rect //instance method implementation
{
double f,g;
double const pi = 2*acos(0.0);
int n=12; // number of sides of the polygon
// get the size of the application's window and view objects
float width = [self bounds].size.width;
float height = [self bounds].size.height;
[[NSColor brownColor] set]; //set the drawing color to white
NSRectFill([self bounds]); //fill the view with white
//the following statements trace two polygons with n sides
// and connect all of the vertices with lines
[[NSColor greenColor] set]; // set the drawing color to black
for (f=0;f<2*pi;f+=2*pi/n){
for (g=0; g<2*pi;g+=2*pi/n) {
NSPoint p1 = NSMakePoint(X(f),Y(f));
NSPoint p2 = NSMakePoint(X(g),Y(g));
[NSBezierPath strokeLineFromPoint:p1 toPoint:p2];
}
}
} //end of drawRect: override mentod
*/
/* windowWillClose: is a delagete method that gets invoked when
* the on-screen window is about to close (user clicked close box).
* In this case we force the entire application to terminate.
*/
-(void)windowWillClose:(NSNotification *) notification
{
[NSApp terminate:self];
}
@end //end of DemoView implementation
/*
* setup() performs the functions that would normally be performed by
* loading a nib file.
*/
void setup()
{
NSWindow *myWindow; // typed pointer to NSWindow object
WebView *myView; // typed pointer to NSView object
NSRect graphicsRect; // contains an origin, width, height
//initialize the rectangle variable
graphicsRect = NSMakeRect(100.0, 350.0, 400.0, 400.0);
myWindow = [[NSWindow alloc] // create window
initWithContentRect: graphicsRect
styleMask: NSTitledWindowMask
|NSClosableWindowMask
|NSMiniaturizableWindowMask
backing:NSBackingStoreBuffered
defer: NO];
[myWindow setTitle: @"Tiny Application Window"];
// create and initialize the DemoView instance
myView = [[[DemoView alloc] initWithFrame:graphicsRect]
autorelease];
[myWindow setDelegate:myView]; // set window's delegate
[myWindow makeKeyAndOrderFront: nil]; // display window
[myView drawRect:graphicsRect];
[[myView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL
URLWithString:@"
http://www.apple.com"]]];
}
int main()
{
// create the autorelease pool
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// create the application object
NSApp = [NSApplication sharedApplication];
// set up the window and drawing mechan ism
setup();
//run the main event loop
[NSApp run];
//we get here when the window is closed
[NSApp release]; // release the app
[pool release]; // release the pool
return(EXIT_SUCCESS);
}
--
Rob Frohne, Ph.D., P.E.
E.F. Cross School of Engineering
Walla Walla College
http://www.wwc.edu/~frohro/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.