Questions tagged [dispatch-queue]

231 questions
0
votes
1 answer

How Do I Fix My Activity Indicator From Not Appearing/Freezing?

@IBOutlet weak var Input: UITextField! @IBOutlet weak var Heads: UILabel! @IBOutlet weak var working: UIActivityIndicatorView! @IBAction func Toss(_ sender: Any) { DispatchQueue.global().sync { //set up variables and method …
0
votes
1 answer

SwiftUI: Return MLKit result to SwiftUI view not working

I have a ScannerService class that has the following function: func detectText(photo: UIImage) -> String { let textRecognizer = TextRecognizer.textRecognizer() let visionImage = VisionImage(image: photo) var textRecognized…
0
votes
1 answer

tableview.reloaddata() still works outside of Dispatchqueue.main.sync when we retrieve data from FireStore

The rule is that "if you update the user-interface inside a closure that works in another thread, then you should call in DispatchQueue.main.async method. However, after I retrieved the data from the Firestore, tableview.reloadData() still works…
Akif
  • 73
  • 5
0
votes
1 answer

How can I organize a network login with Swifts DispatchQueue() and completionHandlers?

I'm trying to organize my login process with swifts DispatchQueue() and completionHandlers. First the user should log in and receive a jwt -token from the server, after that an automated download of a few things should happen. I do have a function…
0
votes
0 answers

NSWindow translation animation in swift

I'm trying to animate an NSPanel after a delay. class ViewController: NSViewController { var alertPanel = NSPanel() func removePanel(){ NSAnimationContext.runAnimationGroup { (cont) in DispatchQueue.main.asyncAfter(deadline:…
unknown
  • 788
  • 9
  • 24
0
votes
1 answer

Why Running torchscript model inference on IOS results in threading error?

I have been trying to integrate pytorch model developed on python into IOS. The example I have looked at is from this github repo. I used the same d2go model in my own application. One thing I noticed is that if the model inference code isn't…
calveeen
  • 621
  • 2
  • 10
  • 28
0
votes
0 answers

How Can I Fetch API Results in Queue

Firstly a domain name should be entered. Then, I have an add button, which adds keywords in an array[String], which keyword used for google searches through the API URL. If the specified domain name matches with any URL in search results the API…
0
votes
0 answers

DispatchSourceTimer schedule (GCD swift macOS) stops after 40 seconds when the app is hidden

For a macOS app (SwiftUI). I'm setting up a simple timer using DispatchSource.makeTimerSource as shown below. It runs properly, but when the app is in background (hidden, minimized or not active), after 40 seconds it slows down a lot. Events are…
0
votes
1 answer

Where can I find the implementation of "class DispatchQueue : DispatchObject"?

I am interested to learn more about the implementation details of class DispatchQueue : DispatchObject. I have looked here, and here but I can't find the matching implementation.
ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
0
votes
1 answer

How to start and stop Firebase performance traces from a singleton dictionary with DispatchQueue

I am in the process of implementing Firebase performance traces, so i made a shared instance and added a dictionary to hold them. What i understand dictionaries are not thread safe and i need to add a dispatch queue to handle this. How should i be…
0
votes
0 answers

Is there a way to remove observers after all new data is added?

Right now I am removing observer with DispatchQueue.main.asyncAfter(deadline: .now() + 2) {}. It should never take more that 2 seconds to load the data; this is swift not python. However, it is still a very unelegant solution. Also,…
0
votes
1 answer

Background Queue processes Terminates app when minimised

I have 3 Background Queue tasks running on app launch. They take approximately 25sec to complete. There is no memory issues, nor an issue with the tasks themselves, the tasks simply go through a database for filtering/reading data purposes…
Paul
  • 183
  • 1
  • 12
0
votes
2 answers

Why does this function append the object twice to the array each time it runs?

I'm using swift's DispatchGroup() to help orchestrate a for loop that finds a document in firesbase converts the document to a custom object appends the custom object to an array With each pass, the function ends up appending each object twice to…
phil
  • 993
  • 1
  • 10
  • 34
0
votes
1 answer

Way to stop action repeating SwiftUI

I am using the following code in a quiz, where once the user answers the question an alert pops up. They then have the option to go to the next question OR review the question again and then after a time period the next question appears. The issue…
Jon
  • 23
  • 5
0
votes
2 answers

How to add numbers using multiple threads?

I'm trying to add the numbers in a range eg. 1 to 50000000. But using a for-loop or reduce(_:_:) is taking too long to calculate the result. func add(low: Int, high: Int) -> Int { return (low...high).reduce(0, +) } Is there any way to do it…
PGDev
  • 23,751
  • 6
  • 34
  • 88