• 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: Jean-Daniel Dupas <email@hidden>
  • Date: Sat, 31 May 2008 19:58:01 +0200


Le 31 mai 08 à 19:14, Torsten Curdt a écrit :

On May 31, 2008, at 18:55, Jens Alfke wrote:
On 31 May '08, at 8:07 AM, Torsten Curdt wrote:

I think you want to schedule the connection for the NSModalPanelRunLoopMode runloop mode. This is the mode that is used for modal windows.

You mean with scheduleInRunLoop:forMode: ? ...but that's only available since 10.5

I don't know of a good alternative that's 10.4-compatible, short of running the NSURLConnection on a background thread with its own runloop.

OK ..so at least it was a real shortcoming and not me fighting the framework again.


What about my current solution with the run loop? Does it smell really bad ...or is the workaround OK as well?

But have you considered _not_ using a modal panel? IMHO, modal panels are a "UI smell", to coin a phrase. Does it really need to be impossible for the user to interact in any other way with the app while that panel is open? Usually a sheet will suffice, and sheets don't use a special runloop mode, so that would solve your problem.

Indeed - modal is smelly ...and I have considered non-modal. It would make my life easier. But since I have just integrated your exception handling into the FeedbackReporter framework ...wouldn't you expect the dialog that pops up in case of an uncaught exception to be modal?


cheers
--
Torsten

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];



_______________________________________________

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: 
 >runloops and NSURLConnection (From: Torsten Curdt <email@hidden>)
 >Re: runloops and NSURLConnection (From: Michael Vannorsdel <email@hidden>)
 >Re: runloops and NSURLConnection (From: Torsten Curdt <email@hidden>)
 >Re: runloops and NSURLConnection (From: Jens Alfke <email@hidden>)
 >Re: runloops and NSURLConnection (From: Torsten Curdt <email@hidden>)

  • Prev by Date: Re: runloops and NSURLConnection
  • Next by Date: Re: Weird NSInvocationOperation init behavior
  • Previous by thread: Re: runloops and NSURLConnection
  • Next by thread: Re: runloops and NSURLConnection
  • Index(es):
    • Date
    • Thread