Linked Questions

181 votes
5 answers
169k views

I have been using DispatchQueue.main.async for a long time to perform UI related operations.

 Swift provides both DispatchQueue.main.async and DispatchQueue.main.sync, and both are performed on the ...
Aman.Samghani's user avatar
168 votes
5 answers
66k views

I often find these terms being used in context of concurrent programming . Are they the same thing or different ?
Inquisitive's user avatar
  • 7,966
124 votes
6 answers
76k views

Can anyone explain for what is NSRunLoop? so as I know NSRunLoop is a something connected with NSThread right? So assume I create a Thread like NSThread* th=[[NSThread alloc] initWithTarget:self ...
taffarel's user avatar
  • 4,043
72 votes
14 answers
170k views

I got this error: Thread 1:EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) How can I solve this? The code works normally, but in the calculator when I click the only equal button, it gives ...
legolas's user avatar
  • 745
59 votes
7 answers
89k views

For the longest time I thought asynchronous was synonymous to running something on a background thread, while synchronous meant on the main thread (blocking UI updates and interactions). I understand ...
Doug Smith's user avatar
  • 29.5k
70 votes
6 answers
33k views

I'm familiar with using AsyncTask in Android: create a subclass, call execute on an instance of the subclass and onPostExecute is called on the UI thread or main thread. What's the equivalent in iOS?
SundayMonday's user avatar
  • 19.9k
23 votes
2 answers
15k views

I have and Application which has a singleton that stores information across the whole app. However, this is creating some data race issues when using the singleton from different threads. Here there ...
nikano's user avatar
  • 1,248
16 votes
5 answers
6k views

I often come across the key terms "thread safe" and wonder what it means. For example, in Firebase or Realm, some objects are considered "Thread Safe". What exactly does it mean for something to be ...
Ali Mir's user avatar
  • 575
25 votes
1 answer
19k views

In Swift, I used this kind of pattern sometimes. DispatchQueue.global().async { // do stuff in background, concurrent thread DispatchQueue.main.sync { // update UI } } The ...
Ryan's user avatar
  • 4,904
3 votes
3 answers
2k views

why do this piece of code causes crash ? DispatchQueue.main.sync { // Operation To Perform } why we have to write this way :- DispatchQueue.global().async(execute: { print("test") ...
user avatar
0 votes
1 answer
642 views

Here I've a query about Difference between Threads Difference Between DispatchQueue.global().sync , DispatchQueue.global().async, DispatchQueue.main.sync and DispatchQueue.main.sync Here's some ...
steveSarsawa's user avatar
  • 1,722