Questions tagged [nsoperation]

The NSOperation class is an abstract class you use to encapsulate the code and data associated with a single task. This is a legacy pattern, largely supplanted by Swift concurrency.

nsoperation
239 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10 votes
0 answers
4k views

Does Alamofire support NSOperation queue?

I want to implement a batch of request using alamofire. I want to use NSOperation queue to manage it. Is it supported using Alamofire framework.
kalim sayyad's user avatar
  • 1,076
8 votes
0 answers
4k views

App crashed in Dispatch queue: NSOperationQueue

I sometimes get the following crash in my app: Crashed Thread: 4 Dispatch queue: NSOperationQueue 0x7fc2d96277c0 :: NSOperation 0x7fc2d9704440 (QOS: UTILITY) Exception Type: ...
Mugen's user avatar
  • 8,803
5 votes
0 answers
502 views

Crash at NSOperationQueue addOperation Custom NSOperation

I have a NSOperationQueue, maxConcurrentOperationCount = 1, and Custom NSOperation has a property is block, when the NSOperationQueue addOperation, the app crash, in iOS 9.x, the NSOperation is not ...
fyxrhyry's user avatar
  • 135
3 votes
0 answers
109 views

NSOperation completionBlock retain cycle warning?

I have similar code in two parts of my app, xcode gives the warning for one but not the other. From my understanding of the documentation I think there should be no warning in either case. // In one ...
trapper's user avatar
  • 11.8k
3 votes
1 answer
2k views

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 ...
sebastiansson's user avatar
3 votes
0 answers
210 views

NSOperation finished KVO is sent on main thread

I have an asynchronous NSOperation in my app that executes an asynchronous method with a callback block that by default is executed on the main thread: - (void)start { self.executing = YES; [...
jim's user avatar
  • 140
3 votes
0 answers
348 views

Overriding 'finished' in asynchronous NSOperation

I've subclassed NSOperation, to perform an asynchronous operation. But I'm not clear on how I declare the operation to be finished. I overrided it as follows, but it just doesn't seem right that I ...
Andrew's user avatar
  • 7,823
3 votes
2 answers
230 views

What is the best way to deal with the fact that NSOperation completionBlock is called on a different thread?

Lets say we have NSOperation A and NSOperation B. B is dependant on A finishing and performing some setup as a result of A.completionBlock being called and finished. This means that B.addDependency(A) ...
Michael's user avatar
  • 2,288
2 votes
0 answers
1k views

Download with URLSession and Operation queue does not start next operation when application is in background

Use case : Download file from a server via one API which will give the download server url(download server url vality is for 10 secs only). I have enabled the background capabilities. Then created ...
Bhavesh Patel's user avatar
2 votes
0 answers
144 views

Let NSOperation Wait for CoreBluetooth Write Confirmation?

I wish to queue CoreBluetooth writes using NSOperation: class BtWriteOperation: Operation { private let data: Data private let characteristic: CBCharacteristic private let ...
meaning-matters's user avatar
2 votes
0 answers
458 views

NSOperation crash

This crash was not came up every time. I think the mutableData's address is not valid or multiple thread access the mutableData's address. It happened in the state of memory low. Big screen devices ...
weiguang meng's user avatar
2 votes
0 answers
478 views

Core Image filter intermittently crashes when running in a NSOperation

I have a simple Core Image filter running in a NSOperation. It works most of the time, but, every now and then it will crash (the rest of the code never crashes that doesn't use Core Image). When it ...
Jeshua Lacock's user avatar
2 votes
0 answers
255 views

How to catch exceptions in an NSBlockOperation while in unit tests?

I'm trying to create a subclass of NSBlockOperation to catch exceptions with an alternate execution block if anything is thrown. However, in the unit tests, Xcode will not let me get passed the ...
Christian Di Lorenzo's user avatar
2 votes
0 answers
651 views

Dispatch Group inside NSOperation - Still allowing multiple operations despite maxConcurrentOperationCount = 1

I am aiming for a serial download queue within NSOperation subclass using dispatch groups to manage async tasks. I have maxConcurrentOperationCount set to 1 i have defined my queue var ...
DuckMan's user avatar
  • 133
2 votes
2 answers
101 views

Should I use operation queue for this complete scenario?

I need to perform a scenario with the following steps: To make a network call with some search parameters provided by the user Then, to parse its JSON response and create model entities Then, for ...
AppsDev's user avatar
  • 12.4k
2 votes
0 answers
287 views

Why is `CKDiscoverUserIdentitiesOperation` calling the `userIdentityDiscovered` block for all input entries?

My understanding is that when CKDiscoverUserIdentitiesOperation is executed, the userIdentityDiscovered block is called only when a user identity is actually found. (I assume this to mean a phone ...
Anthony C's user avatar
  • 2,000
2 votes
0 answers
603 views

Waiting for operation to complete in Swift 3

I'm trying to use the new DispatchGroup mechanism with an OperationQueue so that my unit test will wait for completion. After watching the WWDC videos I've only seen how to use groups with async calls ...
Mercutio's user avatar
  • 1,227
2 votes
0 answers
722 views

How to queue, pause and resume download Alamofire.Request?

I'm using Alamofire as my HTTP framework, I'm currently using NSOperation and NSOperationQueue to limit my concurrent request to 3. This works fine without modifying my request queue. However, I'm in ...
chlkdst's user avatar
  • 175
2 votes
0 answers
52 views

Naming dispatch_queue's in NSOperationQueue

In my app I use NSOperations and NSOperationQueue a lot. When I use regular dispatch_queue_t I get to name them at instantiation time, so they show up in Xcode's Debug Navigator with that name while ...
niklassaers's user avatar
  • 8,702
2 votes
1 answer
901 views

Advanced NSOperation - Add dependency at runtime

Is there a way to create an NSoperation at run time and add it as a dependency to an operation which is in progress and already in execute state? If not, Is there any other alternative way to ...
Sankar Narayanan's user avatar
2 votes
0 answers
103 views

Why NSOperation class is an abstract class ?

While we can make its object and object respond to all Selector. And it does not have any protcol so assume any method without body.
Anish Kumar's user avatar
2 votes
0 answers
290 views

Responsiveness and improve performance in iOS app

I want to implement responsive UI in my iOS application.I mean to that my app never block UI while navigation during web call. it should be cancelled the web call request if user pop from current ...
korat prashant's user avatar
2 votes
0 answers
91 views

How do I fix a testing issue in Swift when I forget to set a delegate?

Background: I'm learning Swift and TDD simultaneously for self improvement purposes and to try to keep up with current tech. This issue, I'm not calling it a bug, made me scratch my head for a while. ...
macawm's user avatar
  • 142
2 votes
0 answers
52 views

Creating an NSOperationQueue with an operation that will terminate if not finished in a given time

How do I create a NSOperationQueue with an operation that will time out if not completed within a given amount of time ?
Daniel I's user avatar
  • 127
2 votes
0 answers
499 views

App crashes on OS X Yosemite due to NSOperation (QOS, Quality Of Service)

My application keeps crashing on OS X Yosemite for the following reason: Crashed Thread: 7 Dispatch queue: NSOperationQueue 0x608000239d80 :: NSOperation 0x60000013b3a0 (QOS: UTILITY) Changed ...
Paul Simon Bracha's user avatar
2 votes
0 answers
214 views

Propagating NSError from inside an NSOperation's autoreleasepool

What I currently have I'm having some trouble propagating my NSErrors that are created inside an NSOperation's main method. @interface FooOperation() @property (nonatomic, strong) NSError * error; ...
Vitor M. Barbosa's user avatar
2 votes
1 answer
3k views

NSOperation crash in NSKeyValueNotifyObserver

Our app has had a crash since launch. We've fixed all the other big crashes, leaving us with just this one. Crashlytics reports the crash like so: Crashed: com.apple.root.default-priority ...
Soroush Khanlou's user avatar
2 votes
0 answers
436 views

GCDAsyncSocket "didReadDataWithTag" Never called with NSOperation subclass

In a "getMyFile" method of some XIB file. I am creating a object of class "A"(subclass of NSOperation) and adding it to a "myFileQueue"(object of NSOperationQueue). myFileQueue....
SandyNegi.037's user avatar
2 votes
0 answers
815 views

NSOperationQueue Crash

My app is crashing when invoking a completion block for an NSOperation subclass (AFURLConnectionOperation). I'm not sure what this error message means: NSOperation low-priority concurrency-limiting ...
Gabriel Ortega's user avatar
2 votes
0 answers
569 views

Serially queueing conditional HTTP requests with AFNetworking and NSOperationQueue

I am refactoring some existing code. It has about 20 HTTP requests which are executed serially, assuming the previous one returns HTTP status 200 (OK). If the status is not 200, the process stops. ...
Aaron Brager's user avatar
  • 65.3k
2 votes
1 answer
367 views

NSOperationQueue blocking unrelated NSOperationQueue?

I'm loading an image in the background using NSOperation and NSOperationQueue (for a 2d game). To understand how NSOperations behaves, I've tried adding the following unrelated NSOperationQueue / ...
baris's user avatar
  • 304
2 votes
1 answer
102 views

Not all NSOperations returning value

I am running a mathematical formula in a NSOperation: NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [queue setMaxConcurrentOperationCount:20]; for (int i = 0; i<runCount; i++) { ...
user1028028's user avatar
  • 6,383
2 votes
2 answers
267 views

NSOperationQueue callback before an operation is started?

Is there a way I can find out if/when an operation is about to start/execute on an NSOperationQueue? I am using NSURLConnection's setDelegateQueue: and I need to know when it fires.
0xSina's user avatar
  • 21.3k
2 votes
1 answer
777 views

How to stop AFHTTPRequestOperation?

The cancel could stop the instance of AFHTTPRequestOperation, but sometimes, it will failed. Anyone have the solution to stop the AFHTTPRequestOperation instance immediately or with seconds delay ?
Forrest's user avatar
  • 125k
2 votes
0 answers
1k views

What should I do when i cancel a NSOperation? It did not remove from queue when I cancel it

As I know, a NSOperation will remove from its NSOperationQueue when I send isFinished KVO notification and isFinished=YES, and will not remove from its NSOperationQueue when I send isCancelled KVO ...
Tony's user avatar
  • 158
2 votes
2 answers
252 views

Using NSAutoReleasePool in an NSOperation on Secondary Thread in start and finish methods): Crashes

I have an NSOperation that I wanted to bracket with an NSAutoreleasePool, like this: - (void) start { opPool = [[NSAutoreleasePool alloc] init]; if (self.isCancelled) { [self finish]...
Jim's user avatar
  • 5,970
2 votes
1 answer
1k views

Blocks within NSOperation

I'm using AFNetworking to perform URL request and defining success/error blocks within NSOperation - so that's basically running asynchronous process within NSOperation. I understand the caveat ...
user1187378's user avatar
2 votes
0 answers
344 views

Yield with NSThread?

I have an NSOperationQueue and I want to cancel some operations. Therefore I iterate over the operation and cancel some tasks. At another point in the code which is executed subsequent in the same (UI)...
Lars Schneider's user avatar
2 votes
1 answer
440 views

NSOperationQueue and NSFetchedResultsController

i use a combination of queue and resultscontroller to update and display some coredata objects. in my uitableviewcontroller i call every X second a method in my main controller object. [NSTimer ...
user547064's user avatar
2 votes
1 answer
1k views

initWithContentsOfURL leaks memory within NSOperation subclass. Anyone else seeing this?

I have been living on Instruments for last few hours staring at a puzzling memory leak. I have isolated it to this single line of code in an NSOperation subclass I wrote: NSData *myData = [[NSData ...
dugla's user avatar
  • 12.9k
1 vote
0 answers
63 views

Do you need to use URLSession's dataTask(with: URL) inside of an Operation class's main() method?

Do you need to use URLSession's dataTask(with: URL) inside of an Operation class's main() method? For example: class Downloader: Operation { let postDetailsPage: PostDetailsPage init(_ ...
Eden's user avatar
  • 1,810
1 vote
0 answers
81 views

(NS)Operation KVO dependencies

I’m trying to observe when a new dependency is being added to an operation: let token = operation.observe(\.dependencies, options: [.old, .new]) { (operation, changes) in print("dependencies ...
Alessandro's user avatar
1 vote
1 answer
755 views

App crash : NSInvalidArgumentException - Operation is already enqueued on a queue

I am using Rob's implementation of AsynchronousOperation Following is my AsynchronousOperation subclass class AsynOperation : Operation { // Same implementation as mentioned in Rob's ...
Sayooj's user avatar
  • 375
1 vote
1 answer
1k views

Xamarin.iOS Download Manager

I am working with Xamarin.iOS and implementing a Downloadmanager. I have found a tutorial on how to implement a DownloadManager in swift, lead by that tutorial I have transcribed the logic written in ...
Igor Jakovljevic's user avatar
1 vote
0 answers
112 views

OperationQueue cancelAllOperations is not changing the value to isCancelled

I have Implemented my own "MyOperation" and "MyOperationQueue" both. MyOperation: Implementation private var _executing : Bool = false override var isExecuting : Bool { get { return ...
AppleBee's user avatar
  • 472
1 vote
0 answers
114 views

NSOperationQueue - executing concurrent operations without subclassing

I need to have an NSOperationQueue to be able to perform following: maxConcurrentOperationCount on NSOperationQueue add dependency between the operations. need ability to cancel an operation. The ...
SandeepAggarwal's user avatar
1 vote
0 answers
89 views

Networking search + image downloads operations in OperationQueue: Operations vs URLSession's delegateQueue

I need to perform this scenario: User provides some search parameters which I should use to call an URL and parse its response (I use an URLSessionDataTask for this). That response is a JSON that ...
AppsDev's user avatar
  • 12.4k
1 vote
0 answers
246 views

OperationQueue.cancelAllOperations does not call deinit method

In a for loop, I'm adding 10 operations in a queue. Also I'm setting maxConcurrentOperationCount = 3. In viewWillDisappear I'm calling cancelAllOperations. When, for ex. 3 operations are executed, ...
Slavcho's user avatar
  • 2,802
1 vote
1 answer
274 views

Waiting for async download

In my NSOperation that downloads mp3 file, i use NSURLSession for downloading. Also i use NSURLSessionDownloadDelegate for checking my progress. I need to use NSOperationQueue....
Denis Petrov's user avatar
1 vote
1 answer
458 views

dispatch_semaphore_wait doesn't work with concurrent background NSOperation

Edit: In fact semaphore works perfectly with background NSOperation, the problem was that sometimes operation becomes cancelled even before it has chance to start, which produced extra call to ...
AlKir's user avatar
  • 63

1
2 3 4 5