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

NSOperationQueue vs GCD

In what cases would you prefer to use NSOperationQueue over GCD? From my limited experience of these two, I take it that with NSOperationQueue you basically have control over how many concurrent operations there are. With GCD you can't do this,…
12
votes
2 answers

NSOperation, start vs main

According to Apple document on NSOperation, we have to override main method for non-concurrent operations and start method for concurrent operations. But why?
Anshu
  • 511
  • 1
  • 5
  • 15
12
votes
2 answers

NSAttributedString initWithData and NSHTMLTextDocumentType crash if not on main thread

calling NSAttributedString * as = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute:…
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
12
votes
2 answers

NSOperation blocks UI painting?

I'm after some advice on the use of NSOperation and drawing: I have a main thread create my NSOperation subclass, which then adds it to an NSOperationQueue. My NSOperation does some heavy processing, it is intended to loop in its main() method for…
Yup
  • 121
  • 1
  • 3
12
votes
3 answers

AFNetworking: enqueueBatchOfHTTPRequestOperations issue with completion block

I use this AFNetworking method to start multiple requests at once: - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations progressBlock:(void (^)(NSUInteger numberOfCompletedOperations, NSUInteger…
Felix
  • 35,354
  • 13
  • 96
  • 143
11
votes
5 answers

Equivalent of GCD serial dispatch queue in iOS 3.x

Apple's Grand Central Dispatch (GCD) is great, but only works on iOS 4.0 or greater. Apple's documentation says, "[A] serialized operation queue does not offer quite the same behavior as a serial dispatch queue in Grand Central Dispatch does"…
11
votes
3 answers

How to properly deal with a deallocated delegate of a queued nsoperation

In my current project, several view controllers (like vc) spawn NSOperation objects (like operation) that are executed on a static NSOperationQueue. While the operation is waiting or running, it will report back to the view controller via delegation…
epologee
  • 11,229
  • 11
  • 68
  • 104
11
votes
1 answer

Properly dealloc NSOperationQueue

I'd like to know what is the proper way to dealloc an ivar NSOperationQueue in case it has still some operations running, which can typically occur when the user suddenly quits the app. In some examples I saw the waitUntilAllOperationsAreFinished…
Tomas Camin
  • 9,996
  • 2
  • 43
  • 62
11
votes
2 answers

How do I cancel an NSOperation's dependencies?

I have some NSOperations in a dependency graph: NSOperation *op1 = ...; NSOperation *op2 = ...; [op2 addDependency:op1]; Here's how I'm running them: NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [queue addOperation:op1]; [queue…
Matt Fenwick
  • 48,199
  • 22
  • 128
  • 192
11
votes
3 answers

How to communicate results between NSOperation dependencies?

The new Cloud Kit framework uses NSOperation extensively for it's CRUD. The results of those operations are returned in blocks. For example: let fetchOperation = CKFetchRecordsOperation(recordIDs: [recordID1,…
Ward Bekker
  • 6,316
  • 9
  • 38
  • 61
11
votes
3 answers

With NSOperationQueue, how do you add to a background queue instead of main, and how does controlling amount of operations work?

I'm loving NSOperationQueue but I'm having some issues understanding some portions of it. In the second issue of objc.io they go over NSOperationQueue and mention that it has two kinds of queues, the main queue which runs on the main thread, and the…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
11
votes
1 answer

What's the equivalent of NSOperationQueue in java android?

I love nsoperationqueue in iOS. What's the equivalent in java?
user4951
  • 32,206
  • 53
  • 172
  • 282
11
votes
2 answers

When does an NSOperationQueue start its first operation?

I've created a test project in which I'm testing my assumptions about NSOperation and NSOperationQueue before using them in my main project. My code is pretty simple, so I'm going to include all of it here. This is using a command line Foundation…
Steven Fisher
  • 44,462
  • 20
  • 138
  • 192
10
votes
2 answers

How to use NSOperation & NSOperationQueue in Objective-C?

I am developing a custom camera application.What I am doing is , I am taking picture using camera and showing them in same VC bottom of the screen. I am storing the image in local dictionaries and NSDocument directory path. If the picture is in…
kavi
  • 143
  • 1
  • 1
  • 9
10
votes
3 answers

iOS App Architecture with NSOperations

Two month ago I started to write a new iPhone Application and for this reason I created a generic RESTFul web service, which allows me to have a lot of these necessary features like user authentication, user profiles, a friendship system, media…
Henrik P. Hessel
  • 36,243
  • 17
  • 80
  • 100
1 2
3
69 70