Questions tagged [nsoperationqueue]

On Mac OS X, the NSOperationQueue class regulates the execution of a set of NSOperation objects.

The NSOperationQueue class regulates the execution of a set of NSOperation () objects. After being added to a queue, an operation remains in that queue until it is explicitly canceled or finishes executing its task. Operations within the queue (but not yet executing) are themselves organized according to priority levels and inter-operation object dependencies and are executed accordingly. An application may create multiple operation queues and submit operations to any of them.

References:

1047 questions
19
votes
3 answers

NSOperation wait until asynchronous block executes

i need to put asynchronous operations into an operation queue, however, they need to execute on after the other self.operationQueue = [NSOperationQueue new]; self.operationQueue.maxConcurrentOperationCount = 1; [self.operationQueue…
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
19
votes
3 answers

Difference between Dispatch Queue and NSOperationQueue

I am very new to GCD and threading. I have gone through the tutorials and getting very much confusion. Can some one explain in simple words.Please don't suggest apple developer links.. Thanks in advance !
18
votes
3 answers

How to do two concurrent API calls in swift 4

Thanks in advance for help, I have two API calls, both are concurrent and any call could be success first(I don't want call in sequence), after success of both calls, I have to stop my activity indicator and reload my tableView, Here is my code but…
King
  • 259
  • 1
  • 4
  • 12
18
votes
2 answers

how to cancel out of operation created with addOperationWithBlock?

I'm using NSOperationQueue's addOperationWithBlock. From within the block, how do I check to see if I'm supposed to cancel the operation? Or access any NSOperation properties/methods? [myOperationQueue addOperationWithBlock: ^{ while ( /* long…
TomSwift
  • 39,369
  • 12
  • 121
  • 149
18
votes
7 answers

dispatch_after equivalent in NSOperationQueue

I'm moving my code from regular GCD to NSOperationQueue because I need some of the functionality. A lot of my code relies on dispatch_after in order to work properly. Is there a way to do something similar with an NSOperation? This is some of my…
sinθ
  • 11,093
  • 25
  • 85
  • 121
18
votes
3 answers

How can I Pause a NSOperation in a NSOperationQueue?

I need to pause a running NSOperation which was inserted in an NSOperationQueue. Currently I am canceling all operations and restarting them. But this would lead to some kind of duplication in terms of process done. I tried with setSuspended flag of…
Advaith
  • 1,087
  • 3
  • 12
  • 31
17
votes
3 answers

NSOperationQueue serial FIFO queue

Is it possible to use an NSoperationQueue object as a serial FIFO queue by setting its maxConcurrentOperationCount to 1? I note that the docs state... For a queue whose maximum number of concurrent operations is set to 1, this equates to a serial…
Barjavel
  • 1,626
  • 3
  • 19
  • 31
16
votes
2 answers

When does the NSOperationQueue remove an operation from the queue?

I need to know that When does a NSOperationQueue remove an operation from the queue? I have NSOperationQueue which has list of NSOperation. At which point the NSOperationQueue removes an operation from queue? After starting an operation? OR After…
jailani
  • 2,260
  • 2
  • 21
  • 45
15
votes
6 answers

Wait for all Operations in queue to finish before performing task

I have an Operation subclass and Operation queue with maxConcurrentOperationCount = 1. This performs my operations in a sequential order that i add them which is good but now i need to wait until all operations have finished before running another…
WanderingScouse
  • 281
  • 1
  • 3
  • 16
15
votes
5 answers

Waiting for multiple blocks to finish

I have those methods to retrieve some object information from the internet: - (void)downloadAppInfo:(void(^)())success failure:(void(^)(NSError *error))failure; - (void)getAvailableHosts:(void(^)())success …
15
votes
1 answer

[NSOperation cancelAllOperations]; does not stop the operation

xCode 4.4.1 OSX 10.8.2, looks like [operation cancelAllOperations]; isn't working - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSOperationQueue *operation = [[NSOperationQueue alloc] init]; [operation…
Awesome
  • 153
  • 1
  • 1
  • 4
15
votes
1 answer

How can I better optimize networking on iOS?

I have created a project on GitHub so I can learn how to optimize networking for my iOS apps. I have used blocks and GCD heavily and after watching WWDC 2012 videos and videos from past years I learned that I may be able to do more with…
Brennan
  • 11,546
  • 16
  • 64
  • 86
14
votes
4 answers

Managing a bunch of NSOperation with dependencies

I'm working on an application that create contents and send it to an existing backend. Content is a title, a picture and location. Nothing fancy. The backend is a bit complicated so here is what I have to do : Let the user take a picture, enter a…
Romain Pouclet
  • 864
  • 2
  • 8
  • 17
14
votes
1 answer

NSOperationQueueDefaultMaxConcurrentOperationCount in the wild

The Apple docs say that if you set the maxConcurrentOperationCount property of an NSOperationQueue to NSOperationQueueDefaultMaxConcurrentOperationCount (the default) then it will adjust the value at run time based on "system conditions". If you…
Joel
  • 15,654
  • 5
  • 37
  • 60
13
votes
1 answer

Is this the correct usage of an Operation Queue completion block?

I'm using Objective-C blocks and Operation Queues for the first time. I'm loading some remote data while the main UI shows a spinner. I'm using a completion block to tell the table to reload its data. As the documentation mentions, the completion…
Jeremy Mullin
  • 4,170
  • 4
  • 36
  • 54
1
2
3
69 70