I'm making an app where I'm programmatically moving an image around the screen by reading a CGPoint from an array and setting the center of the image accordingly. In the most simple form it's like this:
for point in array {
image.center = point
sleep(1)
}
It happens after pressing a button so the for-loop is inside the @IBAction func ...
of the button.
The problem is that the screen isn't updating after an image.center
change, but only after the whole for-loop is done, so when the image is at the last point in the array. How do I force the view to update? Or what is the best way to deal with this in general?