Hi everybody,
Happy new year. I’m new to this forum and I’d like to ask you a little question about using WebView in ApplescriptObjC.
If the cocoa code for loading a web view looks like this,
NSString *urlAddress = @“http://www.apple.com ”;
//Create a URL object.
NSURL *myurl = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:myurl];
//Load the request in the UIWebView.
[mywebView loadRequest:requestObj];
, then where is the mistake in this ASOC version?
property mywebView : missing value
property urlAddress : “http://www.apple.com ”
on load_webview_(sender)
tell class “NSURL” of current application
set myurl to URLWithString_(urlAddress)
end tell
tell class "NSURLRequest" of current application
set myurlobj to requestWithURL_(myurl)
end tell
mywebView's loadRequest_(myurlobj)
end load_webview_
Thanks a lot for your help.
jpg
mywebView's mainFrame's loadRequest_(myurlobj)
Excellent. Thank you Craig.
I was reading the iPhone documentation where it seems there is no main frame for a webview object…
Can someone help me?
--
-- Webkit_BrowserAppDelegate.applescript
-- Webkit Browser
--
-- Created by Dylan Weber on Monday, January 4, 2010.
-- Copyright 2010 __MyCompanyName__. All rights reserved.
--
script Webkit_BrowserAppDelegate
property webview : missing value
property internetlocation : missing value
on internet_(sender)
set myurlobj to internetlocation's stringValue()
webview's mainFrame's loadRequest_(myurlobj)
end internet_
end script
I also got this in the log:
run
[Switching to process 2126]
Running.
2010-01-04 18:46:36.273 Webkit Browser[2126:a0f] An uncaught exception was raised
2010-01-04 18:46:36.276 Webkit Browser[2126:a0f] *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)
2010-01-04 18:46:36.278 Webkit Browser[2126:a0f] *** Terminating app due to uncaught exception ‘NSInvalidUnarchiveOperationException’, reason: ‘*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)’
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff85514444 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff844460f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff85514267 +[NSException raise:format:arguments:] + 103
3 CoreFoundation 0x00007fff855141f4 +[NSException raise:format:] + 148
4 Foundation 0x00007fff8618fa92 _decodeObjectBinary + 2427
5 Foundation 0x00007fff86190811 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1229
6 Foundation 0x00007fff86190d51 -[NSArray(NSArray) initWithCoder:] + 462
7 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
8 Foundation 0x00007fff8618ef85 _decodeObject + 208
9 AppKit 0x00007fff82af33bb -[NSView initWithCoder:] + 362
10 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
11 Foundation 0x00007fff8618ef85 _decodeObject + 208
12 AppKit 0x00007fff82b0177f -[NSWindowTemplate initWithCoder:] + 3824
13 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
14 Foundation 0x00007fff86190811 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1229
15 Foundation 0x00007fff86190254 -[NSSet(NSSet) initWithCoder:] + 447
16 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
17 Foundation 0x00007fff8618ef85 _decodeObject + 208
18 AppKit 0x00007fff82a833ca -[NSIBObjectData initWithCoder:] + 1983
19 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
20 Foundation 0x00007fff8618ef85 _decodeObject + 208
21 AppKit 0x00007fff82a82af9 loadNib + 146
22 AppKit 0x00007fff82a82059 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248
23 AppKit 0x00007fff82a81e91 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326
24 AppKit 0x00007fff82a7f413 NSApplicationMain + 279
25 Webkit Browser 0x0000000100000ef2 main + 70
26 Webkit Browser 0x0000000100000ea4 start + 52
27 ??? 0x0000000000000001 0x0 + 1
)
terminate called after throwing an instance of ‘NSException’
Program received signal: “SIGABRT”.
sharedlibrary apply-load-rules all
kill
Error resetting ObjC debugger mode: The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use “set unwindonsignal off”
Evaluation of the expression containing the function (gdb_objc_endDebuggerMode) will be abandoned.
[Session started at 2010-01-04 18:47:58 -0600.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18 20:40:51 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “x86_64-apple-darwin”.tty /dev/ttys001
Loading program into debugger.
Program loaded.
run
[Switching to process 2147]
Running.
2010-01-04 18:47:59.929 Webkit Browser[2147:a0f] An uncaught exception was raised
2010-01-04 18:47:59.931 Webkit Browser[2147:a0f] *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)
2010-01-04 18:47:59.933 Webkit Browser[2147:a0f] *** Terminating app due to uncaught exception ‘NSInvalidUnarchiveOperationException’, reason: ‘*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)’
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff85514444 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff844460f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff85514267 +[NSException raise:format:arguments:] + 103
3 CoreFoundation 0x00007fff855141f4 +[NSException raise:format:] + 148
4 Foundation 0x00007fff8618fa92 _decodeObjectBinary + 2427
5 Foundation 0x00007fff86190811 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1229
6 Foundation 0x00007fff86190d51 -[NSArray(NSArray) initWithCoder:] + 462
7 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
8 Foundation 0x00007fff8618ef85 _decodeObject + 208
9 AppKit 0x00007fff82af33bb -[NSView initWithCoder:] + 362
10 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
11 Foundation 0x00007fff8618ef85 _decodeObject + 208
12 AppKit 0x00007fff82b0177f -[NSWindowTemplate initWithCoder:] + 3824
13 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
14 Foundation 0x00007fff86190811 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1229
15 Foundation 0x00007fff86190254 -[NSSet(NSSet) initWithCoder:] + 447
16 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
17 Foundation 0x00007fff8618ef85 _decodeObject + 208
18 AppKit 0x00007fff82a833ca -[NSIBObjectData initWithCoder:] + 1983
19 Foundation 0x00007fff8618fb0b _decodeObjectBinary + 2548
20 Foundation 0x00007fff8618ef85 _decodeObject + 208
21 AppKit 0x00007fff82a82af9 loadNib + 146
22 AppKit 0x00007fff82a82059 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248
23 AppKit 0x00007fff82a81e91 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326
24 AppKit 0x00007fff82a7f413 NSApplicationMain + 279
25 Webkit Browser 0x0000000100000ef2 main + 70
26 Webkit Browser 0x0000000100000ea4 start + 52
27 ??? 0x0000000000000001 0x0 + 1
)
terminate called after throwing an instance of ‘NSException’
Program received signal: “SIGABRT”.
sharedlibrary apply-load-rules all
You should add the WebKit framework to your project.