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

NSOperationQueue becomes suspended at random?

I have an app that uses NSOperationQueue intensively. Sometimes I've noticed that some of the NSOperationQueues would "lock up" or enter a "isSuspended" state randomly even though my code never calls the setSuspended: method. It's impossible to…
Jiho Kang
  • 2,482
  • 1
  • 28
  • 38
4
votes
3 answers

How to cancel specific Operation from OperationQueue in swift

There are 3 Operations in my OperationQueue and i'm not able to cancel specific operation from them. I referred this example but i can't understand it NSOperationQueue cancel specific operations This is my code class myOperation1 : Operation { …
NøBi Mac
  • 505
  • 5
  • 15
4
votes
0 answers

Put run-loop-based NSThread to sleep for an indeterminate amount of time

I have a dedicated networking thread in my iOS app. The thread's -main method looks like this: - (void)main { @try { while (!self.isCancelled) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]…
LinenIsGreat
  • 594
  • 4
  • 13
4
votes
1 answer

Cancel NSOperation in for loop?

I am trying to implement search on a background thread using NSOperation on iOS. I didn't want to subclass NSOperation so this is what I'm doing: [searchQueue cancelAllOperations]; NSInvocationOperation *op = [[NSInvocationOperation alloc]…
fabian789
  • 8,348
  • 4
  • 45
  • 91
4
votes
1 answer

iOS - Concurrency performing 5 operations uploading images to server using NSOperationQueue followed by single Task in Objective-c

I have to perform below operations using nsoperationqueue concurrently. I need to perform multiple operations in background at a time like 5(Uploading files to Server) , i have to manage all queues depends up on follow scenorio 1) network is 2G…
4
votes
1 answer

How to force a NSOperationQueue runs on one thread?

I am working with Realm, I would get/set realm object's property from different operations which are added to one NSOperationQueue. Let's say in operation0, I set the realm object's property to a new value, then I add operation1 to the same…
KudoCC
  • 6,912
  • 1
  • 24
  • 53
4
votes
1 answer

Can you use cross-queue dependencies for NSOperation objects?

Is it possible/legal to have cross-queue dependency operations? Consider the following... let operationA = NSBlockOperation(block: someBlock) let operationB = NSBlockOperation(block: someOtherBlock) let operationC = NSBlockOperation(block:…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
4
votes
2 answers

Drawing in NSView from background operation has no effect

I'm trying to draw to a NSView from a background operation, but don't see any effect. let queue = OperationQueue() queue.addOperation() { doTheBackgroundStuff() } starts the background operation, which is doing lots of calculations. In the…
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
4
votes
1 answer

How to stop or cancel execution of dispatch block

I want to execute multiple dispatch block at same time. So when any dispatch block is in progress at same time when I run 2nd dispatch block, I want to stop execution of previous dispatch block. I'm using this below code…
Monika Patel
  • 2,287
  • 3
  • 20
  • 45
4
votes
1 answer

Swift: Retain cycle with NSOperation

In my app I use an image loader class to load images from the web for a collection view. The class keeps track of the download operations and cancels them when the cells for the images are no longer visible in the collection view. This…
Leontien
  • 612
  • 5
  • 22
4
votes
3 answers

NSOperation dependency and completionBlock

We're having a simple problem regarding NSOperationQueue, here's a simple operation logic: self.queue = [[NSOperationQueue alloc] init]; NSOperation *operationA = [NSBlockOperation blockOperationWithBlock:^{ NSLog(@"- Running operation A"); …
4
votes
2 answers

Chaining `NSOperation` : Pass result from an operation to the next one

I've been looking for a way to pass results for chained NSOperation. For example, lets assume we have 3 operations chained: Operation1 to download JSON data from server Operation2 to parse & model JSON received Operation3 to download user…
Haitham
  • 83
  • 4
4
votes
2 answers

Extra retain needed on NSOperation

I'm developing an iPad app. It uses an NSOperation to download something in the background, processed by an NSOperationQueue. I'm finding that, unless I add a retain to the NSOperation, I hit a crash after the operation's action is performed. …
Shaheen
  • 51
  • 1
4
votes
1 answer

NSOperation & NSOperationQueue Cancellation

I'm encountering some weird issues with some custom NSOperation instances queued in an NSOperationQueue instance: When I call either [myOperation cancel] or [myOperationQueue cancelAllOperations] the isCancelled getter for the cancel boolean remains…
Razvan
  • 4,122
  • 2
  • 26
  • 44
4
votes
1 answer

NSOperationQueue addOperations waitUntilFinished

Hi I am building an app using Swift. I need to process notifications in a specific order. Therefore I am trying to use addOperations waitUntilFinished. Here is what I did: let oldify = NSOperation() oldify.completionBlock =…
Quentin Malgaud
  • 405
  • 6
  • 21