2

I'm using Apple's Page Control sample and my UIScrollview isn't smooth when scrolling. I'm thinking about using GCD. I believe that all my code is thread safe, except for my last line which is [self.scrollView addSubview:myView].

The docs that I read all mentions that UIKit is not thread safe, but the examples given are always related to setting values such as self.myLabel.text = @"some text".

Is addSubview thread safe?

user604352
  • 63
  • 4

3 Answers3

2

All interface manipulation should be done in main thread! In other case you'll probably would gain painful headache.

Serhii Mamontov
  • 4,942
  • 22
  • 26
1

You should call all UIKit methods on the main thread, this includes -[UIView addSubview:].

Community
  • 1
  • 1
0

It is my understanding that this would not be thread-safe. To my knowledge, the only thing you can do with UIKit that is thread-safe is creating instances of UIImage (but not adding them to a view).

dtuckernet
  • 7,817
  • 5
  • 39
  • 54