칼로리, 지방, 탄수화물 및 단백질을 보유하는 사용자 지정 Struct 클래스가 있습니다.STRUCT Array to UserDefaults
사용자 변수
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)]
에 I가 넣어 데이터를 입력 할 때마다 이제도 모두 저장 배열을 만들었다. 그런 다음 모든 값을 배열에 저장 한 다음이를 UserDefaults에 저장해야합니다.
그럼 내가 전화 후 [0]라고 할 수있는 사용자 기본 설정 전화 배열을 호출하고 각 칼로리, 탄수화물이 필요합니다 ... 뭔가를 thelog.calories // theology.carbs 등