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
2
votes
1 answer

Cancelling one (or several) certain ASIHTTPRequests in an ASINetworkQueue

In my iPhone/iPad app I'm handling all network and web-API-requests through a "APIManager" (singleton, created in AppDelegate). Currently the APIManager contains only one single ASINetworkQueue, to which APIRequests (subclass of ASIHTTPRequest) are…
Manne W
  • 1,459
  • 4
  • 17
  • 31
2
votes
1 answer

releasing NSInvocationOperation causes app to crash

Hi I have the following code NSString *analyticsStr = [[NSString alloc] initWithString:[self constructXMLMessage:TagObj]]; NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self …
Asad Khan
  • 11,469
  • 13
  • 44
  • 59
2
votes
0 answers

Error Domain=NSURLErrorDomain Code=-999

I am doing a series of web requests using OperationQueue and Alamofire. I get this error only first time after login. From second time onwards this error doesn't come. Below is my request code: func request(path:String,method:HTTPMethod ,…
Amit Gupta
  • 192
  • 2
  • 13
2
votes
1 answer

PDFKit background search

I'm trying to run a search on a background thread using new iOS PDFKit framework. override func main() { if isCancelled { return } pdfDocument = PDFDocument.init(url: book.document.url)! pdfDocument.delegate = self …
Claudiu Iordache
  • 2,215
  • 1
  • 10
  • 5
2
votes
2 answers

Sequential Network Requests in Swift 3

I have multiple network requests that need to happen in sequential order. They must wait until the previous has finished and received its response from the server. Right now I have a callback pyramid of death. Is there a more automated way of doing…
2
votes
2 answers

how to properly use autoreleasepool for an nsoperationqueue

I have an app that I am refactoring and I just implemented multithreading so that the UI may run smoother. In the iphone simulator I don't get any leaks but testing on my iPhone 3G running on iOS 4.2 I get a memory leak. I have done a lot of…
zambono
  • 21
  • 1
  • 2
2
votes
2 answers

Is there a way we might face race condition when running async tasks on serial queue

Suppose if multiple async tasks running in a serial queue are accessing a same shared resource, are there any chances we might face race condition?
2
votes
6 answers

How to execute second dispatch_async when previous first dispatch_async is finished?

I would like to add a dispatch_async sequentially but I would like them not to be launched randomly. I would like for example : dispatch_async 1 begins... dispatch_async 1 ends. dispatch_async 2 begins... dispatch_async 2 ends. dispatch_async 3…
2
votes
1 answer

Operation State Not Thread Safe Swift

I have subclassed Operation to support async operations. The new class called AsyncOperation and added new field called state which is an enum to help manage the operation state. class AsyncOperation: Operation { // DONE: State enum with keyPath…
orthehelper
  • 4,009
  • 10
  • 40
  • 67
2
votes
1 answer

Adding operation in `Executing` state as dependency to another one

I'm wondering whether it is possible to add as dependency, operation which is in 'Executing' state to another operation which is enqueued and in 'Ready' state? e.g. A operation is in 'Executing' state and I want to perform…
Robert
  • 3,790
  • 1
  • 27
  • 46
2
votes
1 answer

How to ensure FIFO execution in a concurrent NSOperationQueue?

I'm working on a framework and in order to ensure non blocking public methods, I'm using a NSOperationQueue that puts all the public method calls into an operation queue and returns immediately. There is no relation or dependencies between…
Jan
  • 7,444
  • 9
  • 50
  • 74
2
votes
0 answers

URLSession dataTask: with URLRequest/URL? OperationQueue in completionHandler?

I want a URLSession to perform an HTTP network call and parse its JSON response. I'm following an example which more or less matches my scenario, and I found this code: let request = URLRequest(url: url) let dataTask = myUrlSession.dataTask(with:…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
2
votes
1 answer

NSBlockOperation is not waiting on dependency before executing

I am learning NSOperations & NSOperationQueue. I have a set of NSBlockOperation: "UPLOAD" & "DELETE". Delete MUST wait for Upload to finish before executing. What I would like to happen is for one operation set to complete before moving on to the…
user-44651
  • 3,924
  • 6
  • 41
  • 87
2
votes
1 answer

NSOperation does not spawn a new thread?

I have a NSOperationQueue with a number of NSOperations in it. I want to ensure that a particular part of the code is not executed in parallel. I use a NSLock object like this: [myLock lock] some critical code [myLock unlock] Unfortunately instead…
2
votes
1 answer

What do I do with this exception tripped shortly after cancelling all operations on NSOperationQueue

Whenever I cancelAllOperations() I get this wonder message: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSOperationInternal _start:]: something is trying to start the receiver simultaneously from more…
Anton Tropashko
  • 5,486
  • 5
  • 41
  • 66