• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Calling javascript from Cocoa 'facelessly'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling javascript from Cocoa 'facelessly'


  • Subject: Re: Calling javascript from Cocoa 'facelessly'
  • From: Michael Ash <email@hidden>
  • Date: Wed, 30 Jun 2010 14:30:26 -0400

On Wed, Jun 30, 2010 at 1:01 PM, Geoffrey Holden
<email@hidden> wrote:
> I realize that this is a hell of a big query, and I'm not entirely sure that I've given enough information for anyone to help answer it.  At the very least, I guess I'm hoping for a reference to some really solid documentation on how to do what I'm trying to do - the documentation on ADC seems to be a little light in this area.

>From the code you've posted, I suspect the problem is that the page
hasn't actually loaded by the time you try to run your JS code.
WebView generally works asynchronously. Something like [mainFrame
loadRequest:request] will return quickly and the WebView will not
actually load things until the runloop runs, and then you'll get
notified later on when it's done loading.

What you'll want to do is call loadRequest:, then run the NSRunLoop on
the main thread until your load delegate is told that the page is done
loading. Then you should be able to do your JS stuff.

Note that it is possible, and not all that hard, to run an NSRunLoop
in a faceless program, it just requires a bit more manual intervention
than in a GUI app where it's all set up for you.

If you're already doing that and your code was just abbreviated, well,
ignore the above....

Mike
_______________________________________________

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

References: 
 >Calling javascript from Cocoa 'facelessly' (From: Geoffrey Holden <email@hidden>)

  • Prev by Date: Re: Tracking multiple NSURLConnections
  • Next by Date: Re: NSOpenPanel won't allow selecting aliases
  • Previous by thread: Calling javascript from Cocoa 'facelessly'
  • Next by thread: class_respondsToSelector() in runtime.h?
  • Index(es):
    • Date
    • Thread