I have a custom Struct class to hold calories, fats, carbs, and protein.
Each Time a user enters the data I put it into a variable
var theArray : NSMutableArray = []
struct CFCPstruct {
let calories : Int!
let fats : Int!
let carbs : Int!
let protein: Int!
init(Calories: Int, Fats: Int, Carbs: Int, Protein: Int) {
self.calories = Calories
self.fats = Fats
self.carbs = Carbs
self.protein = Protein
}
}
let addLog = [CFCPstruct(Calories: totalCalories, Fats: totalFats, Carbs: totalCarbs, Protein: totalProtein)]
Now I also created an array to store everything. I then need to store all the values into array, which then store that to UserDefaults.
Then I will need to call the user defaults call array[0] lets say and then call each calorie, carb, ... something like thelog.calories // theology.carbs etc