Here is the GitHub repository which contains the iOS app files and also a MacOS Command Line Tool file.
Purpose of the app: Calculate yearly income based on established pay scales and multiple promotions in future years.
The Command Line Tool code was the test bed and works great. It produces the following print:
Years since hired: 3
Department(s) for Year 3: Sanitation
Earnings for Year 3: 19200
Age: 57
Years since hired: 4
Department(s) for Year 4: Sanitation
Earnings for Year 4: 23040
Age: 58
Years since hired: 5
Department(s) for Year 5: Sales
Earnings for Year 5: 46080
Age: 59
Years since hired: 6
Department(s) for Year 6: Sales,Management
Earnings for Year 6: 59520
Age: 60
Years since hired: 7
Department(s) for Year 7: Management
Earnings for Year 7: 72960
Age: 61
Years since hired: 8
Department(s) for Year 8: Senior Management
Earnings for Year 8: 96000
Age: 62
Years since hired: 9
Department(s) for Year 9: Senior Management
Earnings for Year 9: 99840
Age: 63
Years since hired: 10
Department(s) for Year 10: Senior Management
Earnings for Year 10: 103680
Age: 64
Years since hired: 11
Department(s) for Year 11: Senior Management
Earnings for Year 11: 53760
Age: 65
I am attempting to transition from this Command Line Tool code to a iOS app. I want the above print content (year group, department, earnings and age) to be displayed in the iOS app ResultsView
. The current ResultsView
displays notional sample data in a desirable ScrollView format.
In order to replace the notional sample data array with actual app user-input data, I expect a new array of year group, department, earnings and age must be generated within the EmployeeViewModel
in accordance with the following information:
@Published var userData: Employee =
Employee("Charlotte Grote",
birthdate: DateComponents(calendar: .current, year: 1965, month: 7, day: 20).date!,
hiredate: DateComponents(calendar: .current, year: 2021, month: 12, day: 28).date!,
yearGroup: 1,
retirementAge: 65,
department: .other("Sanitation"),
monthlyHoursWorked: 160,
planningToPromote1: true,
planningToPromote2: true,
planningToPromote3: true,
planningToPromote4: true,
promotion1Date: DateComponents(calendar: .current, year: 2023, month: 12, day: 28).date!,
promotion2Date: DateComponents(calendar: .current, year: 2025, month: 6, day: 28).date!,
promotion3Date: DateComponents(calendar: .current, year: 2026, month: 12, day: 28).date!,
promotion4Date: DateComponents(calendar: .current, year: 2027, month: 12, day: 28).date!,
secondDepartment: .other("Hospitality"),
thirdDepartment: .other("Sales"),
fourthDepartment: .other("Management"),
fifthDepartment: .other("Senior Management"),
regularPayRateIncreases: true,
regularPayRateIncreasePercentage: 4,
regularPayRateIncreaseYearInterval: 4)
var firstDeptMonths: Int { Calendar.current.dateComponents([.month], from: userData.hiredate, to: userData.promotion1Date).month! }
var secondDeptMonths: Int { Calendar.current.dateComponents([.month], from: userData.promotion1Date, to: userData.promotion2Date).month! }
var thirdDeptMonths: Int { Calendar.current.dateComponents([.month], from: userData.promotion2Date, to: userData.promotion3Date).month! }
var retireDate: Date { Calendar.current.date(byAdding: .year, value: userData.retirementAge, to: userData.birthdate)! }
var fourthDeptMonths: Int { Calendar.current.dateComponents([.month], from: userData.promotion3Date, to: retireDate).month! }
Once an array of the years since hired, income, departments and age is compiled, I should be able to interate through the array with a ForEach to replace the sample data in the ResultsView
.
Can you assist in creating a new userData array?