So as of now, I have been able to use Environment objects for relatively simple things, such as User Profile and User Goals, where we only have one set of values for these Environment objects. However, I am fairly confused on how I could implement an Array of Environment Objects. For example I want to create a Environment Objects called AddedFoods, which has 4 attributes (takes 4 paramaters):
name
totalCals
totalProtein
totalFat
totalCarns
And I want this environment to be able to take a large quantity of these objects, so obviously it must be some sort of array, but I have no clue how to implement this in Swift as I am relatively new. Any help would be greatly appreciated!
UPDATE: This is what I have for my other environment objects which aren't an array:
import Foundation
class UserInfoModel: ObservableObject {
struct UserInfo: Identifiable {
var id = UUID()
var firstName: String
var height: Double
var weight: Double
var gender: String
var age: Double
var activityLevel: String
var BMR: Double
}
struct DailyCalorieGoals: Identifiable{
var id = UUID()
var calorieGoal: Double
var fatGoal: Double
var proteinGoal: Double
var carbGoal: Double
}
struct CurrentCalorieProgress: Identifiable{
var id = UUID()
var calorieProgress: Int
var fatProgress: Int
var carbProgress: Int
}
@Published var personUserInfo = UserInfo.init(firstName: "", height: 0, weight: 0, gender: "", age: 0, activityLevel: "", BMR: 0)
@Published var personDailyCalorieGoals = DailyCalorieGoals.init(calorieGoal: 2400, fatGoal: 40, proteinGoal: 0, carbGoal: 0)
@Published var personCurrentCalorieProgress = CurrentCalorieProgress.init(calorieProgress: 0, fatProgress: 0, carbProgress: 0)
}