Questions tagged [dispatch-async]
437 questions
2
votes
0 answers
DispatchGroup notify() doesn't get called
I have to wait for the completion until the user touches the Try Again button to call the same function again. All works fine the first time but when I press it again, the notfy() method doesn't get called. Here is the playground class to simulate…

ios_dev
- 359
- 2
- 13
2
votes
1 answer
Completion Handler dispatch_async is giving error?
I have completion handler in following function
static func fetchFeatureApp(completionHandler:@escaping ([AppCategory1])->()){
let urlString="http://ebmacs.net/ubereats/Api/all_product?id=1"
let url = URL(string: urlString)!
…
user8298737
2
votes
6 answers
How to execute second dispatch_async when previous first dispatch_async is finished?
I would like to add a dispatch_async sequentially but I would like them not to be launched randomly.
I would like for example :
dispatch_async 1 begins...
dispatch_async 1 ends.
dispatch_async 2 begins...
dispatch_async 2 ends.
dispatch_async 3…

ΩlostA
- 2,501
- 5
- 27
- 63
2
votes
2 answers
ios 10+, Swift 3+ - Cannot dismiss UIAlertController from Singleton instance
I have created an overlay to run while I run an async data grab to the server so that users won't continue pressing buttons in the UI until the data grab is done. I have put the function into a global singleton class and I call it while passing in a…

Erik Grosskurth
- 3,762
- 5
- 29
- 44
2
votes
1 answer
Properly manage dispatch queue to reduce phone heating iOS
CUSTOM_VIEW CLASS:
I have made custom_view class which calculates value on itself and shows to user after every 1 sec. Calculation of values in custom_view based on properties/variable stored in custom_view instance.
VIEWCONTROLLER CLASS:
I…

nikdange_me
- 2,949
- 2
- 16
- 24
2
votes
1 answer
Long cycle blocks application
I hve following cycle in my app
var maxIterations: Int = 0
func calculatePoint(cn: Complex) -> Int {
let threshold: Double = 2
var z: Complex = .init(re: 0, im: 0)
var z2: Complex = .init(re: 0, im: 0)
var iteration: Int = 0
…

Dawy
- 770
- 6
- 23
2
votes
2 answers
Swift 2 to 3 Migration dispatch_get_global_queue
I have the following code that I've been trying to translate into swift 3 from swift 2. Here is what I have so far.
DispatchQueue.async(group: DispatchQueue.global(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),execute: {
…

Joseph Astrahan
- 8,659
- 12
- 83
- 154
2
votes
0 answers
Dispatch_Async Won't Work After Firebase Call
I am creating an iOS app in Swift that uses Firebase as the backend. The app gets images from Firebase storage using this code:
imageRef.downloadURLWithCompletion{ (URL, error) -> Void in
print("Firebase sent something back!")
…

Olivia Watkins
- 526
- 1
- 6
- 17
2
votes
2 answers
How to update UI from thread
My program "ThreadsNQueues" - see below - fills text lines with "A"s and "B"s concurrently on background threads. When a text line has been filled with 10 characters it will be appended to an output text buffer (it's a NSMutableString) and this…
user5924595
2
votes
1 answer
Parallel search with dispatch_async
I'm trying to implement a parallel-search algorithm. The concept is something like this:
Start with a candidate & test if it is the desired value
If not, generate more candidates and add them to the queue.
Repeat until reaching the desired…

Jenny
- 2,041
- 13
- 15
2
votes
1 answer
Swift 2.0: Schedule background task to upload failed product uploads
I am developing an app which uploads a product (JSON) to server. Now, every product object consists of many images. A product is only uploaded to server if all images associated with that product have already been uploaded. In case all images for…

dashbashrumble
- 251
- 1
- 5
- 19
2
votes
1 answer
How to get nested asynchronous calls resolved before completion block
Here's the setup. I have a method that has a completion block in which I want to return a list of Items. These Items are fetched from an API. I'd like to have each of the fetches happen asynchronously but ultimately return the Items all…

H K
- 1,215
- 2
- 16
- 29
2
votes
1 answer
Objective-C freezed GUI also with queue
I'm trying to understand queue in iOS; with this code
dispatch_queue_t coda_thread=dispatch_queue_create("coda_thread",NULL);
//UIPROGRESS VIEW
for(i=0;i<=10;i=i+1)
{
dispatch_async(coda_thread,
^{
NSLog(@"CODA_THREAD");
…

volperossa
- 1,339
- 20
- 33
2
votes
1 answer
Updating UI Dispatch_Async background download Swift
Im working on a folders/files application where users are able to download files to local disk. Whenever a user is downloading a file, I want to show a download bar that displays progress.
to do so, I've created a protocol that allows my download…

SKYnine
- 2,708
- 7
- 31
- 41
2
votes
0 answers
Unbalanced call to dispatch_group_leave() on CloudKit CompletionBlock
So I am building an iOS app working with CloudKit. A particular function calls for Products:
func getAllProducts(){
//empty object in Singleton Class
sharedStore.products.removeAllObjects()
var products = NSMutableArray()
//set up…

Joris416
- 4,751
- 5
- 32
- 59