Tema
Tema

Reputation: 1368

Xcode Thread 1 : Is it always main UI thread?

Xcode shows threads in Debug navigator.

They are numbered: Thread 1, Thread 2, etc

I notice that I am always in Thread 1. Is it correct assumption that it is main UI thread? I use libs/SDK like Facebook and AFNetworking they have callbacks and delegates. But thread safety is not always properly documented.

Upvotes: 8

Views: 1925

Answers (1)

Chris Trahey
Chris Trahey

Reputation: 18290

I don't recall which, but in one of the WWDC videos (from 2011, I think), I heard an engineer mention that the UIKit internals assume thread 1 is UI.

So yes, it's not "simply" best practice, I think there are concrete technical dependencies.

As far as specific documentation, I don't readily find an "official" statement; but I think it's because it's even more foundational than that. For example, this kind of casual mention of the main thread's role is all over the place (taken from the iOS App Programming Guide (e.g. iOS 101)

The main thread is where your app handles touch events and other user input.

Upvotes: 8

Related Questions