Coin
2005.03.11, 04:30 PM
I + My friend are writing a program with Applescript and Cocoa.
here is what happens
applescript calls a method with a parameter/argument that contains a URL
my cocoa program takes the URL loads it into a webview and gets the source code, then sends that back in a string varible
my cocoa program has control over one inteface object. a webView for loading the url then retriving the source
here is what i have so far.. its a mess
appControl.h
/* appControl */
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
@interface appControl : NSObject
{
IBOutlet id webView;
}
- (NSString *)Source;
- (void)getCode;
- (IBAction)loadCodeFromURL:(NSString)inString;
@end
appControl.m
#import "appControl.h"
#import <WebKit/WebKit.h>
#import <WebKit/WebView.h>
#import <WebKit/WebDocument.h>
@implementation NSApplication (ASKAFullScreen)
- (void)getCodeh
{
}
- (IBAction)loadCodeFromURL:(NSString *)inString
{
NSURL *URL = [NSURL URLWithString:inString];
[webView setFrameLoadDelegate:self];
WebFrame *mainFrame = [webView mainFrame];
[mainFrame loadRequest:[NSURLRequest requestWithURL:URL]];
WebFrame *mainFrame = [webView mainFrame];
id documentRepresentation = [[mainFrame dataSource] representation];
if ([documentRepresentation canProvideDocumentSource]){
[out setStringValue: [documentRepresentation documentSource]];
}
else {
// NSRunAlertPanel(@"Wait", @"Page not done loading", @"Ok", nil, nil);
}
}
- (NSString *)Source
{
return @"Test";
}
-(void)dealloc
{
[super dealloc];
}
@end
i really dont know how to do any of this...
grammars fixed?
here is what happens
applescript calls a method with a parameter/argument that contains a URL
my cocoa program takes the URL loads it into a webview and gets the source code, then sends that back in a string varible
my cocoa program has control over one inteface object. a webView for loading the url then retriving the source
here is what i have so far.. its a mess
appControl.h
/* appControl */
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
@interface appControl : NSObject
{
IBOutlet id webView;
}
- (NSString *)Source;
- (void)getCode;
- (IBAction)loadCodeFromURL:(NSString)inString;
@end
appControl.m
#import "appControl.h"
#import <WebKit/WebKit.h>
#import <WebKit/WebView.h>
#import <WebKit/WebDocument.h>
@implementation NSApplication (ASKAFullScreen)
- (void)getCodeh
{
}
- (IBAction)loadCodeFromURL:(NSString *)inString
{
NSURL *URL = [NSURL URLWithString:inString];
[webView setFrameLoadDelegate:self];
WebFrame *mainFrame = [webView mainFrame];
[mainFrame loadRequest:[NSURLRequest requestWithURL:URL]];
WebFrame *mainFrame = [webView mainFrame];
id documentRepresentation = [[mainFrame dataSource] representation];
if ([documentRepresentation canProvideDocumentSource]){
[out setStringValue: [documentRepresentation documentSource]];
}
else {
// NSRunAlertPanel(@"Wait", @"Page not done loading", @"Ok", nil, nil);
}
}
- (NSString *)Source
{
return @"Test";
}
-(void)dealloc
{
[super dealloc];
}
@end
i really dont know how to do any of this...
grammars fixed?