Questions tagged [dispatch-async]
437 questions
1
vote
1 answer
Load local images into an array asynchronously on iOS
I need to load about 200 images in my bundle into an array in memory like this:
let arr = (0..<200).map({UIImage(named: "\($0).png")})
The only problem with this is it takes forever to do.. so I'd like to do it in the background and get a callback…

7ball
- 2,183
- 4
- 26
- 61
1
vote
1 answer
Do I need to use locks if the methods are already executed in a serial queue?
I have 2 method calls exposed in my library as follows:
-(void) createFile {
dispatch_async(serialQueue, ^{
[fileObj createFile:fileInfo completion:^(void){
//completion block C1
}];
});
}
-(void)…

ExceptionHandler
- 213
- 1
- 8
- 24
1
vote
1 answer
Forcing the order of execution using dispatch_sync
My library exposes 2 APIs as follows to:
-(void) createFile{
dispatch_sync(queueSerial, ^{ //B1
[fileObj createFileInfo:file completion:^(NSError *error){
//execute completion block C1
}];
});
}
-(void)…

ExceptionHandler
- 213
- 1
- 8
- 24
1
vote
2 answers
why is dispatch_async block blocking?
Inside viewDidAppear I'm putting this following code:
dispatch_async(dispatch_get_main_queue(), ^{
[NSThread sleepForTimeInterval:5.0f];
}
});
and this is blocking the UI. I was expecting this 5 seconds sleep to run in the…

wp42
- 158
- 10
1
vote
1 answer
Stop sound in AVAudioPlayer and shown AQDefaultDevice (173): skipping input stream Error Logs
I have used AVAudioPlayer and set the numberofloop to -1 because I want to play the audio in an infinite loop. At first it works well, but in the middle of playing sound track, I got the following error log continuously and my sound track was…

Nyein Ei Ei Tun
- 168
- 2
- 13
1
vote
4 answers
Swift 3.0: delay of less than a second
I'm trying to make a delay of less than a second. I found this code from the web. It doesn't however accept delays of less than a second. The Grand Dispatch Concept in Swift is a bit of a mystery to me. How should I modify this code to create a…

user594883
- 1,329
- 2
- 17
- 36
1
vote
0 answers
For Loop containing Async-Call
I have a problem with the following code not functioning...
func getThatImage() {
for imageurl in self.imageUrl {
self.group1.enter()
print("1:counter: \(counter)")
self.dbFunctions.downloadImage(urlPath: imageurl,…

MoneyIsAMotivation
- 79
- 1
- 9
1
vote
2 answers
Queues not following QoS priority
Problem: When following this tutorial, I assigned different QoS to the 2 queues. However, when I ran the code, the queues act as if they have the same priority. Further, the blue dots are printing before the red dots even though the red dots are…

14wml
- 4,048
- 11
- 49
- 97
1
vote
1 answer
Stop Dispatchqueue using NotificationCenter in swift 3
I have some task which I want to do asynchronously. So I am creating dispatchqueue in one class and doing some task.
//Adding Observer
NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "NotificationIdentifier"),…

Ganesh
- 89
- 3
- 14
1
vote
1 answer
Cannot convert value of type error in Swift
I'm pretty new to Swift, so I'm following a tutorial on how to make a pedometer app from this page: http://shrikar.com/ios-swift-development-step-counter-app-using-pedometer-data/
However, that was from a while ago, so I've been working on updating…

Ryan Powell
- 27
- 5
1
vote
1 answer
DispatchQueue.main.asyncAfter method freeze UI in a particular call
I'm calling the DispatchQueue.main.asyncAfter method after I modify a property of an object (I'm firing it with KVO). I'm only showing a confirm view for a second and then run a block which do another things on the UI (pops a viewcontroller). The…

sheinix
- 167
- 1
- 13
1
vote
1 answer
'MBProgressHUD needs to be accessed on the main thread.' - Swift 3
I am getting 'MBProgressHUD needs to be accessed on the main thread.' error on hiding MBProgressHUD once page is loaded with data from web service.
Please help me to solve this. Stuck on this issue since hours now.
My code is :
…

Mamta
- 921
- 1
- 10
- 28
1
vote
1 answer
how to load the Core Data in background thread
i have some big data in my Core Data store
how can i load this data in background thread?
func connectionCoreData() {
let fetchRequest = NSFetchRequest(entityName: "PersonalBase")
let sortDescriptor =…

Skie
- 91
- 1
- 2
- 13
1
vote
2 answers
Asynchronous swift 3
I need to make an asynchronous call so that the second method is only called after the first one is completed.Both methods are network calls. Something like this:
signIn()
getContacts()
I want to make sure that getContacts only gets called after…

JP Aquino
- 3,946
- 1
- 23
- 25
1
vote
0 answers
Perform animation while performing segue
From my initial View Controller, I want to be able to segue to another view controller. This second view controller, however, takes a few seconds to load, and I want to have my source view controller display an animation while it loads.
Performing…

Lahav
- 781
- 10
- 22