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
3
votes
4 answers

How to reload UITableView when OperationsQueue is done with all operations

I am trying to update the cells in a UITableView by calling .reloadData() but it reloads the data before the process finishes therefore not really updating anything since the array that it gets data from is still empty. The way I have the code…
3
votes
1 answer

Why is [weak self] or [unowned self] not needed in Operation Queue?

After learning about Swift's capture list and how it can be used to avoid retain cycle, I can't help noticing something puzzling about OperationQueue: it doesn't need either [weak self] or [unowned self] to prevent memory leak. class SomeManager { …
3
votes
1 answer

Switch from main queue to current NSOperation Thread

I want to download and process a image from Firebase to local directory on secondary thread and then update the UI. The problem is firebase returns in completion on main thread and not on the thread on which my NSOperation is being executed. I want…
user3519594
  • 387
  • 1
  • 11
3
votes
2 answers

NSOperationQueue and concurrent operation

As the NSOperationQueue Class Reference said: In iOS, operation queues do not use Grand Central Dispatch to execute operations. They create separate threads for non-concurrent operations and launch concurrent operations from the current thread. But…
3
votes
1 answer

iOS: A specific function can be called from multiple threads/places, but I want each call to execute in a queue

I have a function readData reading data from HealthKit that takes a few seconds to execute. This function can be called from multiple threads/places, but I want each call to execute in a queue, one at a time, rather than in parallel. Is there a…
3
votes
1 answer

NSOperationQueue finishes all tasks swift 3

I am trying to achieve NSOperationQueue finishing all tasks operation in swift 3. I create a below demo code and it is working according to my expectation. func downloadTopStroiesDetails(){ let operationQueue: OperationQueue = OperationQueue() …
Chandan kumar
  • 1,074
  • 12
  • 31
3
votes
2 answers

Swift: downloading data from url causes semaphore_wait_trap freeze

In my application, button tapping downloads data from an Internet site. The site is a list of links containing binary data. Sometimes, the first link may not contain the proper data. In this case, the application takes the next link in the array and…
Igor Tupitsyn
  • 1,193
  • 3
  • 18
  • 45
3
votes
2 answers

Change dictionary values wrong when using KVO with NSOperationQueue?

I was working through an example in the concurrency chapter of "More iPhone 3 Development," and can't get KVO on an NSOperationQueue working as expected. I create an NSOperationQueue and observe its operations array using: NSOperationQueue *newQueue…
3
votes
3 answers

How to wait for all tasks of an NSURLSession to complete?

Why is NSURLSession operation queue empty after creating and resuming an NSURLSessionTask? Is there a way to tell if an NSURLSession has tasks pending? The goal is to wait for multiple tasks to complete, but this doesn't work: NSURLSessionUploadTask…
Cœur
  • 37,241
  • 25
  • 195
  • 267
3
votes
3 answers

How to wait until all NSOperations is finished?

I have the following code: func testFunc(completion: (Bool) -> Void) { let queue = NSOperationQueue() queue.maxConcurrentOperationCount = 1 for i in 1...3 { queue.addOperationWithBlock{ Alamofire.request(.GET,…
Andrey M.
  • 3,021
  • 29
  • 42
3
votes
2 answers

Executing the NSOperation when all other operations in NSOperationQueue finished no matter whether they finished successfully or not

Hi I have a strange situation here : OverView: I am working on an app where user can initiate multiple operations and all these operations will run on a background thread hence will not block the UI. Some of these operations are dependent on each…
Sandeep Bhandari
  • 19,999
  • 5
  • 45
  • 78
3
votes
1 answer

[NSBlockOperation addExecutionBlock:]: blocks cannot be added after the operation has started executing or finished

I am trying to start again NSBlockOperation after completing or canceling it, but getting an error? Any one have any idea where is mistake? Thanks let imageURLs = ["http://www.planetware.com/photos-large/F/france-paris-eiffel-tower.jpg", …
ZAFAR007
  • 3,049
  • 1
  • 34
  • 45
3
votes
1 answer

iOS app crashes on NSOperationQueue when in Low Power Mode

I've written an app in Swift which crashes on the following lines, when in Low Power Mode. It's basically a request that runs on a background thread. And some UI updates that's happening on the main thread. I can't recreate the crash on my phone…
3
votes
1 answer

What's the correct way to restart an NSOperation?

I'm trying to upload a file to an AWS S3 bucket. If the upload fails for any reason, I want to be able to retry a few times. I have a custom NSOperation, whose main method creates a AWSS3TransferManagerUploadRequest() instance. With the help of the…
3
votes
1 answer

NSOperation's released at queue ending

I have lots of UIImage batching operations. I add them in once with in an instance of NSOperationQueue : self.operationQueue.addOperations(operations, waitUntilFinished: false) But it seems operationQueue captures all the operations and release…
Pierre
  • 10,593
  • 5
  • 50
  • 80