Mac/iOS Xcode -- how to lauch a asynchrounous thread by pressing a button, but not locking up the button

Just started Xcode today and I was able to create two buttons and a UILabel and load the "app" to my iPad. When I press a button the label display a text "Hello" and when I press another button, the label text changed to "how are you?".

While that's cool, I wanted to be able to let the Label change the text every few seconds by itself, after I press a button and stop the flashing by pressing another button.  How can I do this?   I was trying something like this:

    button_pressed_function {   // excuse me, for being a C++ programmer for many years

         I = 0
        while(I < 8)
                label.text = "hello";
                label.text = "what's up?";

Apparently it didn't work though the while-loop did run and it freezed the button before it exits. It freezed for about 48 = 8x6  seconds and just showed  "what's up" in the label, never change the text during the loop run. I know this is certainly not the right way, because 1) even if did flip the text, it locks the button (is there a method of UIlabel to
reader the text in the middle for the loop?)   2)  It didn't even change the text.

I guess there should be a function to dispatch another thread for the while_loop in the background and release the button-pressed function so the button can pop back up. Please help, and sample code will be very appreciated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Add [label setNeedsDisplay]; after label.text=...
It will update the GUI control on the screen.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apple OS

From novice to tech pro — start learning today.