NSTimer and executing selector in main thread

Is it possible to run a selector that is called by nstimer in the main thread?

NSTimer is created in its thread.

My structure is that a thread calls a method with nstimer, nstimer calls a method that performs some updates, but I need these updates to be executed in the main thread. What is the solution? Add another method and say performOnMainThread?

+3
source share
1 answer

Yes, from your timer program, just call the performOnMainThread function. From the docs:

. , , - . NSRunLoop Threading . , , .

:

, invalidate. ; invalidate ,

+4

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


All Articles