981 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
3
votes
1
answer
804
views
NSOperation with a delay - is it async or sync?
I'm creating an NSOperation that executes a closure with a delay. The operations are added into a queue, every time before a new operation is added I cancel all existing ones in the queue:
let myOp = ...
-1
votes
1
answer
655
views
Why does my BlockOperation continue after I add it to an OperationQueue?
Apple documentation says that Operations run synchronously. Why then does the code continue to run after an operation is added to a queue?
Here is my code:
let op = BlockOperation(block: { print("...
1
vote
1
answer
488
views
how many operations NSOperationQueue can cache
I created an NSOperationQueue and set the maxConcurrentOperationCount property to 2.
If I create 2 operations that do not stop, when I continue to add operations to it, the NSOperationQueue will cache ...
1
vote
1
answer
686
views
How to schedule a NSOperation to the head of queue and let all other operations waiting for it? [closed]
I have a NSOperationQueue that is concurrent. For a specific NSOperation, if it fails, I want to immediately retry this operation at the highest priority, and suspend all other operations until it ...
1
vote
2
answers
664
views
NSOperation Queue waitUntilAllOperationsAreFinished causes NSOperation instance deinit late
Our app currently using NSOperation (Operation in Swift) to manage serials of network request and data parsing.
Some code are required to be executed after like all 5 operations in a queue are ...
0
votes
0
answers
59
views
How to perform all delay operations right away with NSOperation or GCD?
I have some operations with different delay times.
While using GCD it looks like:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayTime * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
...
0
votes
1
answer
51
views
Using Operations to manage imbalances between function calls
I am writing a VideoPlayer() class that has a start() and stop() function to initiate playback for a given video. Each instance of VideoPlayer() manages a single video
The start() and stop() functions ...
1
vote
2
answers
210
views
Crashing at queue.sync { self._state }
I'm trying to create an async subclass of Operation.
The code crashes on the getter of the "state" Property.
I have found an article which solves the async Subclass, but i'm curios as to why ...
1
vote
2
answers
368
views
Can NSBlockOperation cancel itself while executing, thus canceling dependent NSOperations?
I have a chain of many NSBlockOperations with dependencies. If one operation early in the chain fails - I want the other operations to not run. According to docs, this should be easy to do from the ...
1
vote
0
answers
82
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(_ ...
0
votes
1
answer
80
views
Operation queuePriority not working as expected
I'm trying to explore queuePriority of Operation. I have three Operation objects with queuePriority veryhigh,high and normal. But I'm getting unexpected output, in log I can see Operation objects with ...
2
votes
3
answers
1k
views
Alternatives to GCD to run code with a delay under SwiftUI
Swift 5, iOS 13
I am running this code, it works.
var body: some View {
...
Button(action: {
self.animateTLeft()
quest = quest + "1"
}) { Wedge(startAngle: .init(degrees: 180), endAngle: .init(...
1
vote
0
answers
89
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 ...
1
vote
1
answer
843
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 ...
5
votes
3
answers
6k
views
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
...