Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run two actions at the same time

Tags:

objective-c

I am having a logical problem. I don't know how to run 2 things at the same time.

What I want to do:

When the user dismiss a button(UIAlertView), an action will be performed. This action takes min. 2 minutes. This is quite long, so I would like to ADD a progressbar to tell the user the progress.

I know how to create a ProgressView/Bar, but I don't know how to combine the Progressbar with NSTask.

I run an NSTask and during this I want to load a progress view :)

Can anyone help me? :)

Thank you.

I tried this using while (nstask and such) but the while/for statements are for boolean only :) Is there a boolean method for NSTask? like (task hasFinished) or something?

like image 963
Janosch Hübner Avatar asked Jul 11 '26 18:07

Janosch Hübner


1 Answers

All code that interacts with the user interface must run on the main thread to guarantee stability, all other things however may be run on a separate thread.

To run a background task simply use:

[self performSelectorInBackground:<#(SEL)#> withObject:<#(id)#>];
like image 103
Nirma Avatar answered Jul 13 '26 12:07

Nirma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!