On Wed, Dec 15, 2010 at 8:10 AM, julius <jul...@juliuspaintings.co.uk> wrote:
> Hello all,
>
> I'm  hoping you can help me with a question about threads and delegates.
> I don't have the terminology to pose the question suscinctly so I'll do so by 
> reference to the program which gave rise to it.
>
> I have an object which implements a number of delegate methods of 
> NSURLConnection:
> - (void)connection: didReceiveResponse:
> - (void)connection: didReceiveData:
> - (void)connection: didFailWithError:
> - (void)connectionDidFinishLoading:
>
> The object also contains a custom method makeConnection which creates an 
> NSURLRequest and makes a call to NSURLConnection
>
> NSURLConnection * myConnection = [[NSURLConnection alloc] 
> initWithRequest:myRequest delegate:self];
>
> after which we test myConnection and return.
>
> My code is an almost perfect copy of the example provided in
> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html
>
> I got the code to execute perfectly and then put the makeConnection method on 
> a separate thread using NSInvocationOperation and NSOperationQueue. What 
> happened was that I could not get any of the delegates to be called.
>
> Now my question:
> 1. Why do they not get called?
> 2. How does one create a situation where they do get called?

You're already using delegates for asynchronous operation. You
therefore do not need the secondary thread.

Asynchronous operation requires a running runloop. Your secondary
thread doesn't have one running. The main thread has a running
runloop; use the main thread.

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to