Reset value on button click

is there any way to restart a program on a button click where variable value are changed to its original value


for ex i have create an array with 10 different string

but with a button click i am removing 1 value in a every click so whent array value come to 0 i want to click another restart button so array value and any other value are back to original


Thank you

I understand you want to reset data as they were at start of the program.


A simple way to do this :

- write a func that set these initial values :

func setInitialValues() { }


You may call this function at the end of didFinishLaunching if you want.


- in the IBAction of the button, test the counter ; if 0, call setInitialValues


@IBAction func buttonClicked(sender : UIButton) {
// Do usual stuff
// remove one string from stringArray
     let counter = stringArray.count
     if counter == 0 {
          setInitialValues()
     }
}
Reset value on button click
 
 
Q