ios - DispatchQueue not working in while loop -


screen capture of frozen screen

edit: once restarted computer , tried simulator agian terminal displayed message, terminal has detected system running low on swap space. scrollback buffers may automatically timmed conserve swap space. not sure make of message.

prior posting question wanted ask method display 3 successive images. settled on

dispatchqueue.main.asyncafter(deadline: .now() + 3) {     self.icon1.ishidden = false }   // display image after 3 sec 

i used method of delaying the execution of code showing , hiding images changing length of delay.

this works fine when "start" button pressed when tried create while loop, simulator freezes when press start button

here code:

@ibaction func start(_ sender: any) {     var x = int(0)      repeat {         dispatchqueue.main.asyncafter(deadline: .now() + stepperval.value/4) {             self.icon1.ishidden = false         }          // stepperval current value of uistepper          dispatchqueue.main.asyncafter(deadline: .now() + stepperval.value/4*2) {             self.icon2.ishidden = false         }          dispatchqueue.main.asyncafter(deadline: .now() + stepperval.value/4*3) {             self.icon3.ishidden = false         }          dispatchqueue.main.asyncafter(deadline: .now() + stepperval.value) {             self.icon1.ishidden = true             self.icon2.ishidden = true             self.icon3.ishidden = true              self.direction.ishidden = false             self.direction.image = self.derection[int(arc4random_uniform(4))]         }          dispatchqueue.main.asyncafter(deadline: .now() + stepperval.value*2) {             self.direction.ishidden = true              x = x+1         }     } while x < int(4) //loop 4 times } 

once start button pressed icon1,2,3 supposed appear eatch image after certian inteval, hide once again followed image 'direction' appearing. loop 4 times.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -