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

Re: threads and delegates


  • Subject: Re: threads and delegates
  • From: Kyle Sluder <email@hidden>
  • Date: Wed, 15 Dec 2010 08:17:50 -0800

On Wed, Dec 15, 2010 at 8:10 AM, julius <email@hidden> 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 (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: threads and delegates
      • From: julius <email@hidden>
References: 
 >threads and delegates (From: julius <email@hidden>)

  • Prev by Date: threads and delegates
  • Next by Date: Re: threads and delegates
  • Previous by thread: threads and delegates
  • Next by thread: Re: threads and delegates
  • Index(es):
    • Date
    • Thread