I am trying to create a "simulated" interaction with a server by showing an activity indicator when the user clicks the Save button. (the finished app will actually interact with the server) I set up an IBAction for the save button and I am calling the activityIndicator, animating it and then I have a pause. Finally, the activity indicator hides. Only problem, the activity indicator is not showing. If I comment out the NSThread.sleepForTimeInterval(4)
and the activityIndicatory.stopAnimating
, the activity indicatory shows. I have tried to move them out of the IBAction for the Save button but that caused the code to error. Here is the code:
@IBAction func saveDTrans(sender: UIBarButtonItem) {
activityIndicator.hidden = false
activityIndicator.startAnimating()
//pause code to let the activityIndicator show for a bit
NSThread.sleepForTimeInterval(4)
activityIndicator.stopAnimating()
activityIndicator.hidden = true
}