If I add an observer to observe the "highlighted" property of a UILabel, can I make a change to another UIView within the observation callback block? ie: Am I guaranteed that this callback block will always execute on the main thread?
Thanks!
If I add an observer to observe the "highlighted" property of a UILabel, can I make a change to another UIView within the observation callback block? ie: Am I guaranteed that this callback block will always execute on the main thread?
Thanks!
You will receive the observeValueForKeyPath:...
message on the thread that changes the property you're observing.
UIKit only supports changing a view's properties on the main thread. As long as you follow that rule, you will only be notified on the main thread.
If you need to change the label's highlighted
property from another thread, you should dispatch to the main thread to do it. For example, you can do this safely from any thread:
dispatch_async(dispatch_get_main_queue(), ^{
myLabel.highlighted = YES;
});