How to update a UI label from a non UI thread in iOS

前端 未结 5 1428
情深已故
情深已故 2021-02-05 07:17

I am new to iOS development, I have plain objective -c class \"MoneyTimer.m\" for running timer, from there i want to update the an UI label with the changing value of timer.

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-05 07:42

    Your question doesn't give much info or detail so it is hard to know exactly what you need to do (e.g. if there is a "thread" issue at all, etc.).

    At any rate, assuming your MoneyTimer instance has a reference to the current viewController you can use performSelectorOnMainThread.

    //

    - (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait;
    

提交回复
热议问题