Re: wait for the event?
Re: wait for the event?
- Subject: Re: wait for the event?
- From: Jens Alfke <email@hidden>
- Date: Mon, 5 Oct 2009 17:47:23 -0700
On Oct 5, 2009, at 5:34 PM, jon wrote:
and i put the rest in the selector method like so... to be executed
when the page is fully loaded, which works... but the thing is,
the code immediately following the main call to "loadThePage" isn't
waiting, it keeps on executing... which defeats the purpose, the
whole program needs that data.....
That's the expected behavior. The -loadRequest: method doesn't block;
it returns immediately, but the action hasn't happened yet. The
delegate callbacks will tell you when it's finished.
Most Cocoa networking calls work this way. Rather than block the
thread, which forces you to run the operation on a background thread
to avoid locking up the UI, they're asynchronous. You have to write
your code somewhat differently this way, but it's a lot better than
having to deal with multithreading hell.
in reality the page takes a while to load, and in the mean time,
the rest of my application (the code after the "loadThePage" keeps
on executing so i have not successfully controlled the running of
the app., it is executing methods left and right, without the
finishLoadingTheWebPage ever being called until half the application
has already executed...
You need to write your app so it keeps running without having the data
yet. Probably you can just return from your event handler back to the
event loop. Any fields in the UI that will show results should start
out being blank. Once your delegate method is called to tell you the
network activity is finished, you can fill in the data.
—Jens_______________________________________________
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