How are classes loaded during user interaction in swift? : Very new to swift here. I am trying to make a simple to-do app.

When a user types in an task, i wanna try to add this task to a string array and increase a counter.

When I type in multiple tasks, my string array only holds the previously typed in task and my counter always is 1 (counter is based off number of items in the string array).

I'm assuming that every time i type in a new task, my class which deals with my string array and counter is reset to their initial values which is an empty string array and 0 respectively.

Any idea how to avoid this, or how classes are loaded when it comes to user interaction?

Sorry if im not being too clear, thanks.