• 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: iOS - NSOperation/NSOperationQueue Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iOS - NSOperation/NSOperationQueue Question


  • Subject: Re: iOS - NSOperation/NSOperationQueue Question
  • From: Dave <email@hidden>
  • Date: Tue, 03 Jun 2014 20:17:09 +0100

I’ve tried that, addOperations:waitUntilFinished: waits for operations currently queued to finish before adding the current operation, it doesn’t Add it to the queue and then wait for it to complete which is what I want.

Thanks
Dave

On 3 Jun 2014, at 19:26, Jeffrey Robert Kelley <email@hidden> wrote:

> I think you’re looking for NSOperationQueue’s -addOperations:waitUntilFinished: method. Should do what you want.
>
>
> Jeff Kelley
>
> email@hidden | @SlaunchaMan | jeffkelley.org
>
> On Jun 3, 2014, at 5:51 AM, Dave <email@hidden> wrote:
>
>> Hi,
>>
>> I think this has been covered before, but all the searches I’ve done don’t really cover what I’d like to do.
>>
>> I have an API that has two modes of operation, Sync and Async.
>>
>> In Sync mode calls to the API MUST be on a background thread and the data is returned to the caller with a possibility that the thread is blocked until the operation has completed.
>>
>> In Async mode calls to the API may be on the background thread or the Main Thread, a delegate is passed to the API method which returns immediately and the Delegate is called when the operation completes or fails.
>>
>> This all works, however I have some existing code that I’d like to have the same API and be called by a “Manager Class” which calls the correct underlying API depending on the context, e.g.
>>
>> AppLayer—>ManagerClass—>API_A
>>                                            —>API_B
>>
>> API_A is the existing API supporting the Sync/Async interface.
>> API_B is the one I wish to create.
>>
>> The problem is that the existing code uses NSOperationQueue/NSOperation accomplish it’s task, this works fine in Async mode, it was easy enough to adapt to call the Delegate methods, but I’m not sure how to implement Sync mode?
>>
>> Basically I want to add the NSOperation to the queue and then wait for it to complete before returning with the results.
>>
>> Any ideas suggestions would be greatly appreciated as there seem to be a lot of conflicting advice out there on how to do this and I’ve not been able to find anything worked as described above.
>>
>> Thanks a lot.
>>
>> All the Best
>> Dave
>>
>>
>> _______________________________________________
>>
>> 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
>
> _______________________________________________
>
> 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


_______________________________________________

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: iOS - NSOperation/NSOperationQueue Question
      • From: Jeffrey Robert Kelley <email@hidden>
References: 
 >iOS - NSOperation/NSOperationQueue Question (From: Dave <email@hidden>)
 >Re: iOS - NSOperation/NSOperationQueue Question (From: Jeffrey Robert Kelley <email@hidden>)

  • Prev by Date: Re: iOS - NSOperation/NSOperationQueue Question
  • Next by Date: Re: Getters/Setters via Property/Synthesize...
  • Previous by thread: Re: iOS - NSOperation/NSOperationQueue Question
  • Next by thread: Re: iOS - NSOperation/NSOperationQueue Question
  • Index(es):
    • Date
    • Thread