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

Crashlytics: "Crashed: NSOperationQueue 0x... :: NSOperation 0x..." - EXC_BAD_ACCESS KERN_INVALID_ADDRESS

I got some crash reports in crashlytics which I don't understand at all, here's the crash log of the thread that crashed: I don't find any hints to my code, nor is it something reproducable or only happening on specific devices. According to…
swalkner
  • 16,679
  • 31
  • 123
  • 210
8
votes
4 answers

Barrier operations in NSOperationQueue

How can we implement dispatch_barrier_async's equivalent behavior using NSOperationQueue or any user-defined data-structure based on NSOperationQueue? The requirement is, whenever a barrier operation is submitted it should wait until all non-barrier…
8
votes
6 answers

NSOperationQueue bug with dependencies

I am using NSOperation and NSOperationQueue for performing a sequence of operations, all dependent on each other (2 on 1, 3 on 2, etc...). I set the dependency after I create the operations. I am encountering problems when the queue completes: the…
Daniel
  • 578
  • 4
  • 17
8
votes
1 answer

Using NSProgress with nested NSOperations

I've been investigating NSProgress but have found the existing documentation, class reference and tutorials to be lacking. I'm mainly wondering if my NSProgress is applicable to my use case. The class reference documentation alternatively refers to…
8
votes
4 answers

Naming Threads in an NSOperationQueue

NSOperationQueue creates many threads, as you'd expect, and desire. But when you pause the app and debug it in Xcode, it's unclear which threads belong to one operation queue and which belong to another. I've tried: [NSThread currentThread] setName:…
Nick Locking
  • 2,147
  • 2
  • 26
  • 42
8
votes
1 answer

AFNetworking + NsOperationQueue - Download thousands of Images

I am working on a task (iOS5 + only) that involves downloading thousands of images from the server. The images belong to certain categories and each category can have hundreds of images. What I need to do is this :- 1) Make sure the app downloads…
Anuj Gakhar
  • 681
  • 2
  • 13
  • 26
8
votes
6 answers

use NSOperationQueue as a LIFO stack?

i need to do a series of url calls (fetching WMS tiles). i want to use a LIFO stack so the newest url call is the most important. i want to display the tile on the screen now, not a tile that was on the screen 5 seconds ago after a pan. i can create…
Padin215
  • 7,444
  • 13
  • 65
  • 103
7
votes
3 answers

How to stop current NSOperation?

I'm using NSOperationQueue, and NSOperation for running some function on background click. But I want to be able, when user clicks some button, stop that Operation. How can I do it? Something like, [currentoperation stop]; Cancel - won't work me.…
User1234
  • 2,362
  • 4
  • 27
  • 57
7
votes
1 answer

NSOperationQueue is crashing in IOS

I have a project which downloads images in background using NSOperationQueue. It was working until now on devices with IOS 4.3. However if I build the app with base sdk 4.3 or with 5 and run the app on device with IOS5, the app crashes. When app is…
CKT
  • 1,223
  • 4
  • 21
  • 39
7
votes
1 answer

Is there a way to enforce serial scheduling of async/await calls similar to a GCD serial queue?

Using Swift's new async/await functionality, I want to emulate the scheduling behavior of a serial queue (similar to how one might use a DispatchQueue or OperationQueue in the past). Simplifying my use case a bit, I have a series of async tasks I…
7
votes
1 answer

Unit Test NSOperation?

I would like to test an NSOperation subclass. I tried to do this in my SenTestCase subclass: - (void)setUp { [super setUp]; _importQueue = [[NSOperationQueue alloc] init]; [_importQueue setMaxConcurrentOperationCount:1]; …
fabian789
  • 8,348
  • 4
  • 45
  • 91
7
votes
2 answers

How to assure that operations in an OperationQueue are finished one after another

When performing operations that are dependent on each other OperationQueue could be used to assure they are executed in the correct order. However, would it also be possible to assure that operations are finished one after another? Let's assume a…
Taco
  • 701
  • 7
  • 21
7
votes
1 answer

Pause NSOperation

I have NSOperationQueue with some NSOperations in it (NSInvocationOperations, in particular). This operations do some calculations and change states of UI elements accordingly (of course, via performSelectorOnMainThread:...), often with use of…
kpower
  • 3,871
  • 4
  • 42
  • 62
7
votes
1 answer

NSOperation Queue behaving abnormally

I have a task of uploading multiple images to the server one by one. So I am using the batch operation process for this. Every time I start the upload procedure, some operations specially the first one completes as soon as it starts and the image…
7
votes
0 answers

Rapid UI updates from a background thread. Best practices

I have a serial NSOperationQueue I have an NSOperation subclass which read a file from disk, create a UIImage from it, and then display the image on the main thread. Pretending the queue containing about a hundred of NSOperations, what would be the…