Questions tagged [dispatch-queue]

231 questions
2
votes
1 answer

Is DispatchQueue using RunLoop?

Every Thread has its own RunLoop, how DispatchQueue interact with them? Is DispatchQueue using RunLoop to dispatch task to Thread or do it by another way?
2
votes
0 answers

Swift on Apple Watch: reloadTimeline(for complication) freezes UI

I use the method below in my watchOS app whenever the data changes which should be reflected in the complication. The problem is that executing this method makes my UI freeze for a few seconds. If I remove the reloadTimeline call the problem…
Isaak
  • 1,107
  • 2
  • 11
  • 29
2
votes
3 answers

Avoiding using self in the DispatchQueue

I wonder how to eliminate of using self inside the DispatchQueue. As a good practice, we are supposed to use self only in the init() func loadAllClasses() { DispatchQueue.global(qos: .background).async { self.classVM.fetchAllClasses(id:…
konya
  • 131
  • 2
  • 8
2
votes
1 answer

DispatchQueue freezed main queue

I need to do some methods one by one without interrupting, in a separate thread, that way I have in my class fileprivate var queue = DispatchQueue(label: "ProgressHUD", qos: .userInteractive) and when I need show/hide I do some like this queue.sync…
EvGeniy Ilyin
  • 1,817
  • 1
  • 21
  • 38
2
votes
1 answer

iOS RunLoop and DispatchQueue.main.async

Why does the print("2") part never get called in the following code? I'd think that the inner main.async would push the block into the main loop's queue, and then RunLoop.run would execute it, but apparently that isn't what happens. (It prints 1,…
imre
  • 1,667
  • 1
  • 14
  • 28
2
votes
2 answers

Do I need to call DispatchQueue when presenting a ViewController from other ViewControllers

I'm trying to present the UIActivityViewController in multiple parts of my app by enclosing it in a helper class. The following code works fine, I can call the showActivityController() method from any other view controllers in my app, and the…
fs_tigre
  • 10,650
  • 13
  • 73
  • 146
2
votes
1 answer

How to pass a parameter to a block executed asynchronously in Swift?

In addition to function dispatch_async, that submits a block for asynchronous execution, iOS provides another function dispatch_async_f to submit a function with a single parameter for asynchronous execution. in Swift, I can call dispatch_async as…
2
votes
1 answer

iOS app crashes with EXC_BREAKPOINT (SIGTRAP)

I have an application which crashes on launch. I have identified where the problem originates, but I can't seem to figure out how to resolve it. Let me first explain what I do: I have a LocationManager that checks if a user enters a certain region…
PennyWise
  • 595
  • 2
  • 12
  • 37
2
votes
1 answer

Create a waiting queue for executing an animation

I am currently working on a swift animation. This animation gets triggered by an another function in unsteady time intervals (connected to a server). The animation takes 2 seconds to finish but its possible that it gets triggered before it has…
F.Fabian
  • 77
  • 10
2
votes
1 answer

Dispatchqueue background thread update not working on iOS 12

I have the following piece of code that works perfectly on 11.4.1 but fails on 12 let background = DispatchQueue(label:"task") var debugMeshNode = SCNNode() let myKit = MyKit() func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for…
Pavan K
  • 4,085
  • 8
  • 41
  • 72
2
votes
1 answer

Swift Async With Completion Block

I have two functions that executes async. I tried to "syncronize" them with: DispatchGroup and DispatchQueue let queue = DispatchQueue(label: "com.company.app.queue", attributes: .concurrent) let group = DispatchGroup() queue.async(group: group) { …
2
votes
2 answers

Return object after DispatchGroup with RxSwift

I am using DispatchGroup to download data from 3 different APIs, once this is done I want to return the new created consolidated object from my function. Now Although DispatchGroup is working fine and I am getting data but I am not able to return it…
Panks
  • 565
  • 1
  • 7
  • 20
2
votes
1 answer

Multithreading executing multiple tasks in parallel in swift ios

I know creation of queues and able to execute single task but how can i execute multiple tasks in parallel. Concurrent Queue ----> let concurrentQueue = DispatchQueue(label: "com.some.concurrentQueue", attributes: .concurrent) concurrentQueue.async…
user9364391
2
votes
1 answer

How to pass block if current thread is same

I have write a class to handle DispatchQueues. I have write a static method to invoke main thread. I pass a completionHandler as an argument and current just accessing the main thread and call this completion handler inside the main thread block.…
Syed Qamar Abbas
  • 3,637
  • 1
  • 28
  • 52
2
votes
1 answer

How to stop Timer after few seconds

Here in myAPICall() method am calling another method I.e., COStatusAPI() for every 5 seconds upto 90 seconds. Here COStatusAPI() is an API call. i.e., Am hitting server for every 5 seconds.
 In response I’ll get COStatus as 1 or 0. If I get COStatus…
Bhanuteja
  • 771
  • 2
  • 8
  • 18
1 2
3
15 16