قالب وردپرس درنا توس
Home / IOS Development / PASSING DATA BETWEEN VIEW CONTROLLERS: iOS Programming

PASSING DATA BETWEEN VIEW CONTROLLERS: iOS Programming



Hello guys,

I hope you are well. So I experienced some problem when sending data through the view controllers. So the intuitive way I decided to approach this problem was by creating a model that has the main data I keep changing. Now in the view controls, the user input causes these variables to change. Now, as I move from one view controller to the next, the variables are reset.

The way I created my model was something like this:

import foundation

class dataOfUser {

public static was shared = dataOfUser ()

was money: Double

was usedMoney: Double

was properties Acquired: Double

was counts: Int

init () {

counter = 0

money = 0

PropertiesAquired = 0 [19659002] usedMoney = 0

}

}

Each time I would change any variable from my code, I would do so using the shared object, but again when I move from one view controller to the next, the variables are reset to the default value.


Source link