Re: Call getElementById in Cocoa
Re: Call getElementById in Cocoa
- Subject: Re: Call getElementById in Cocoa
- From: "Adam R. Maxwell" <email@hidden>
- Date: Mon, 24 Nov 2008 19:02:31 -0800
On Nov 24, 2008, at 6:32 PM, Pierce Freeman wrote:
Sorry for my newbie-ness, but I still don't really get what you are
talking
about. Are you saying that I should do this:
[WebView setFrameLoadDelegate:didFinishLoadForFrame];
- (void)didFinishLoadForFrame
{
// Do stuff
}
No. Here you're sending setFrameLoadDelegate: to the WebView class
instead of an instance, and passing part of the method name as an
argument. It likely won't compile, and certainly won't work.
Additionally, you're missing part of the delegate method signature.
You'd typically have something like this:
- (void)loadURL
{
NSURLRequest *request = [NSURLRequest requestWithURL:_httpURL
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60.0];
// self is an object implementing any delegate methods you want to
receive
[_webView setFrameLoadDelegate:self];
[[_webView mainFrame] loadRequest:request];
}
- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)
error forFrame:(WebFrame *)frame;
{
// do something with error
}
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)
frame
{
// wait until all frames are loaded
if (NO == [_webView isLoading])
// do something with frame/view
}
where the delegate messages are delivered after each frame loads or
fails. This is the basic delegate pattern in Cocoa, which should be
explained pretty thoroughly in the documentation.
See http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/LocationChanges.html
and http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html.
--
Adam
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden