Questions tagged [dispatch-async]

437 questions
1
vote
1 answer

Create UIDocument on the fly in UIActivityItemProvider

I am using Core Data to store my user's data. I want to offer a Share button in the UI to export the data wherever they wish. I made a class conforming to UIActivityItemSource. It is successful when it simply returns a Data object from…
Bob Peterson
  • 636
  • 7
  • 16
1
vote
1 answer

What is the difference between these two Dispatch Queues?

I have seen this code used around on the web let highQueue = DispatchQueue.global(qos: .userInteractive) let videoDataOutputQueue = DispatchQueue(label: "com.apple.sample.capturepipeline.video", attributes: [], target: highQueue) The second one…
Duck
  • 34,902
  • 47
  • 248
  • 470
1
vote
1 answer

What happens if I put Dispatch.main.async block inside Dispatch.global.async?

I have a case where I am saving data to Realm Database inside Dispatch.global in background thread then inside same thread I have called Dispatch.main.async to fetch data from Realm and update UITableView Data. The problem is I am getting less…
1
vote
1 answer

Nested DispatchGroup

I try use nested DispatchGroup, there is my code : class TranslateService { private let myGroup = DispatchGroup() func translateText(text:[String],closure:@escaping ((_ success:String?,_ error:Error?) -> Void)) { var…
ava
  • 1,148
  • 5
  • 15
  • 44
1
vote
1 answer

Waiting for two different REST/Network calls to complete

I am making a lot of calls using REST and decided to separate these connection calls into a separate object, to be called from my UI classes. Here is the function I am using, it will not wait for the requests to be complete. I am not sure what I…
BriOnH
  • 945
  • 7
  • 18
1
vote
2 answers

asyncAfter with no time seems delay - Swift

Eventually I have used asyncAfter feature in swift with no time, and it does some delay and seems different with normal code. Code with async: DispatchQueue.main.asyncAfter(deadline: .now() + 0.0 , execute: { self.updateUI() }) Normal…
Saranjith
  • 11,242
  • 5
  • 69
  • 122
1
vote
1 answer

Can we update UI from background Thread?

Hello iOS experts just to clear my concept I have a bit confusion about UI updation from Main Thread. Apple requirements are that all UI related stuff should be carried out in main Thread.So to test: Case1: I dispatch a task to a global dispatch…
1
vote
0 answers

NSTimer stop but unable to go to next page

I am using NSTimer to call a device to take photos every 24.5 second. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async( dispatch_get_main_queue(), ^{ _photoTimer = [NSTimer…
Satty
  • 157
  • 1
  • 1
  • 6
1
vote
1 answer

Display UIActivityIndicator while loading API data safely

I'm working on this app and have developed a full API for it. However, now that I've come to the front end part (the IOS app), I'm not sure how to load that data the right way. I have made this class to make requests a little bit easier, but I get…
user6914372
1
vote
2 answers

Initialising UIView in main thread from a background thread

In a global, async closure, I'd like to initialise a UIView on the main thread. I thought this code would possibly do it, but I get an Analyser warning: UIView.init(frame:) must by used from the main thread only. let view: UIView = { // Line with…
1
vote
2 answers

Why does DispatchQueue not respect QoS?

I'm trying to run multiple tasks on the main queue, some more urgent than others. I'm using DispatchQoS to do this: func enqueue(_ prio: Int) { let qos = DispatchQoS(qosClass: .userInteractive, relativePriority: prio) …
Kartick Vaddadi
  • 4,818
  • 6
  • 39
  • 55
1
vote
2 answers

Which method in react life cycle call after dispatch process and before render

I have a state that specify which component render(component A or B). This state is determined when my action dispatch specific type(for example GO_TO_B or GO_TO_A). Then I need to fetch some config from server to render component A. I want these…
1
vote
2 answers

Dispatch queue clear explanation

I know there are already a lot of posts about dispatch queues, async tasks etc. ,but I can't retrieve a useful explanation out of these posts, because there are too many distractions because of the extra code. I there someone who can give me a clear…
1
vote
1 answer

EXC_BAD_ACCESS when using dispatch_async

We have recently revised our threading mechanism in favour of using dispatch_async's in most places (after doing a lot of reading about NSOperation vs dispatch_async)*. Then our code started crashing with EXC_BAD_ACCESS in various parts of the code,…
1
vote
0 answers

Do Dispatch queues wait for asynch NSURLSession calls to return before executing next job in queue?

I am executing NSURLSession requests to fetch JSON objects from a cloud service, most of these are calls are synch and have no dependencies but in one instance I have a dependency to take into account, I have to ensure that 2 NSURLSessions are…
Matt Douhan
  • 2,053
  • 1
  • 21
  • 40