Is ACAccount Safe?

Can I use one ACAccount instance between threads? In particular, I would like to create several TWRequest objects that are used by different instances of NSOperationQueue . Those TWRequest objects will have one ACAccount instance. It is safe?

Thanks.

+6
source share
1 answer

I'm going to say no. Firstly, ACAccount does not appear in Apple "Thread Safe" . Secondly, I see no explicit mention of thread safety in the link for any of these classes. Thirdly, I see that TWRequest seems to be built on NSURLConnection , which is intended to be used in a startup loop (usually in the main thread). I see nothing to indicate that these classes are safe to use from multiple threads simultaneously. In the best case scenario, you should use a stream restriction approach (i.e., each stream extracts / creates its own copies of these objects and should not transfer them between threads.)

Since TWRequest is designed to work / runloop-based, I see no reason why you would need to do this stuff in the background thread, FWIW.

So yes. I would say no.

+3
source

Source: https://habr.com/ru/post/902882/


All Articles