• 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: runloops and NSURLConnection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: runloops and NSURLConnection


  • Subject: Re: runloops and NSURLConnection
  • From: Torsten Curdt <email@hidden>
  • Date: Sun, 1 Jun 2008 14:27:26 +0200

If you handle the modal session yourself, it's easy to let the connection do some processing while the modal window is open:
Replace -[NSApp runModalForWindow:[self window]] by this and it should do the trick.


/* Create a modal session, and in each loop,
we process the default runloop event sources (url download, network connections, etc.) */
NSModalSession session = [NSApp beginModalSessionForWindow:[self window]];
for (;;) {
if ((result = [NSApp runModalSession:session]) != NSRunContinuesResponse)
break;
/* Note: Do not use a 0 timeout, else this loop will never block and will consume a lots of CPU.
In fact, the Cocoa UI event port is scheduled in the default runloop, so each Cocoa event will wakeup the runloop. */
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]];
}
[NSApp endModalSession:session];

So that basically means I create my own run loop and call out into the non-modal one from time to time, right?
Just wondering about the "from time to time" part.


cheers
--
Torsten
_______________________________________________

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


  • Follow-Ups:
    • Re: runloops and NSURLConnection
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: Leak when animating Core Animation Superlayer
  • Next by Date: Re: runloops and NSURLConnection
  • Previous by thread: Re: email
  • Next by thread: Re: runloops and NSURLConnection
  • Index(es):
    • Date
    • Thread