1,047 questions
2
votes
1
answer
435
views
iOS custom Operation for Operation Queue gives warning Class must restate inherited '@unchecked Sendable' conformance
I am using Xcode 16.2.
I have the below Operation:
import Foundation
import UIKit
typealias ParsingCompletionHandler = ((ParsedRecord) -> ())
class RecordParseOperation: Operation {//THIS GIVES ...
0
votes
1
answer
1k
views
How to make sure that OperationQueue tasks are always getting executed on background(global) thread in swift?
I encountered a problem with non-iOS developer while describing the flow of OperationQueue. We already know that with OperationQueue we can start as many threads as we want to execute the tasks in ...
0
votes
1
answer
775
views
How to interrupt Thread.sleep. Alternatives?
I have implemented an Operation on an OperationQueue.
override func main() {
super.main()
if isCancelled {
return
}
if member.memberType == .timed {
triggerRestEvent(...
0
votes
2
answers
1k
views
How to use OperationQueue to handle URLSessions for an image downloader
I'm trying to create a simple ImageDownloader framework in swift.
What I'd like to achieve:
Able to download images with given URLs
Cache with url string
So fetching just one image is no problem, I ...
12
votes
1
answer
7k
views
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 ...
14
votes
1
answer
5k
views
Swift 5.5 Concurrency: how to serialize async Tasks to replace an OperationQueue with maxConcurrentOperationCount = 1?
I’m currently migrating my app to use the concurrency model in Swift. I want to serialize Tasks to make sure they are executed one after the other (no paralellism). In my use case, I want to listen to ...
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
1
answer
127
views
Swift Multiple async web service response handler
Approach 1: -
let fetchedImageArray = [Images]()
let requestQueue = OperationQueue()
func fetchProductImage() {
let completionBlock = BlockOperation { [weak self] in
...
0
votes
3
answers
1k
views
Swift -Start/Stop Synchronous OperationQueue
I have some operations that need to run synchronously. I tried to follow this link but it's not clear enough for my situation.
op2 doesn't start until op1 is finished and op3 doesn't start until op2 ...
0
votes
1
answer
144
views
Objc memory and threading crash caused by xcode 12.4 upgrade
For the last few weeks I have been trying to solve a crash which manifested itself seemingly at random. I believe it coincides with a build being created with xcode 12.4 from 12.3. My sync operation ...
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
0
answers
1k
views
OperationQueue wait for async task to be done
I am trying to understand OperationQueue's and its advantages over the DispatchQueue. So when I learn dependencies between Operations I think I can use over the DispatchGroups but I am still trying to ...
1
vote
2
answers
365
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 ...
2
votes
1
answer
132
views
SwiftySandboxFileAccess UserDefaults value
SwiftySandboxFileAccess works the first time the user approves the NSOpenPanel selection, but the next time the app opens, the security bookmark doesn't have access even though SwiftySandboxFileAccess ...
-1
votes
1
answer
379
views
URLSessionTaskDelegate never called in Command Line tool [duplicate]
I'm trying to write my first Swift command line tool. The tool creates a network request and I want to print the progress of the request using URLSessionTaskDelegate.
The basic URL request code is ...
0
votes
2
answers
927
views
Swift OperationQueue time to start next operation [closed]
I have a collection of tasks which operate asynchronously and have inter dependencies. Right now all this is managed with custom code and I would like to use an OperationQueue instead. However, timing ...
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
1
answer
186
views
stop dispatchquene().async in loop globally using swift
override func viewDidLoad() {
super.viewDidLoad()
worktask = DispatchWorkItem {
for i in 1…4 {
sleep(2)
...
2
votes
2
answers
2k
views
Completion handlers and Operation queues
I am trying to do the following approach,
let operationQueue = OperationQueue()
operationQueue.maxConcurrentOperationCount = 10
func registerUser(completionHandler: @escaping (Result<Data, Error&...
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
...
2
votes
2
answers
1k
views
NSOperationQueue operations and operationsCount deprecated. How to cancel operations of a specific class?
This documentation says that operations is deprecated with no hint of a replacement function:
https://developer.apple.com/documentation/foundation/nsoperationqueue/1415168-operations?language=objc
...
4
votes
1
answer
1k
views
How to suspend dispatch queue inside for loop?
I have play and pause button. When I pressed play button, I want to play async talking inside for loop. I used dispatch group for async method's waiting inside for loop. But I cannot achieve pause.
...
0
votes
1
answer
561
views
How to check if operation was cancelled?
I'd like to know whether my operation was cancelled or finished normally. Here is my code snippet :
class PacketReceiver {
private let m_executer = OperationQueue()
private var m_operation : ...
1
vote
3
answers
3k
views
How to pause operation queue in Swift
I have a couple of operations to perform on the IoT device from iOS App. So All my operations are in OperationsQueue with serial operations.
Here I want to perform one operation at a time and each ...