On Wed, Feb 20, 2008 at 6:57 PM, Fraser Speirs <
email@hidden> wrote:
On 20 Feb 2008, at 23:17, Micah Walter wrote:
> If I set this up in a standard Cocoa app, it works just fine, but in
> an Aperture plugin, the delegate handlers don't get called unless
> you click cancel or export on the plugin... I tried doing it in a
> new thread, but that didnt seem to work either... unless I just did
> it wrong..
NSURLConnection doesn't work in a modal runloop, such as Aperture
plugins exist within. You have two choices:
1. Don't use NSURLConnection. cURLHandle (or the bare C cURL API)
might be another possibility for you.
2. Interact with NSURLConnection in a background thread. This is what
FlickrExport does:
- Spawns a new thread to a selector which starts the NSURLConnection
- Receives the NSURLConnection callbacks in the background thread
- Notifies the main thread by calling -
performSelectorOnMainThread:withObject:waitUntilDone:inModes: with
whatever data you want out of the NSURLConnection.
It's a pain, but it does work. If you can require Leopard, I believe
there is some new stuff in NSURLConnection that makes it possible to
schedule them on modal runloops.
HTH,
Fraser
--
http://speirs.org -- http://connectedflow.com