Indrre / Fasting-App

0 stars 0 forks source link

Strings (remove all hard codings) #10

Open RichAppz opened 2 years ago

RichAppz commented 2 years ago

Get used to not hard coding strings in the code, same as colours and other constant files you have. Create string files:

    extension String {
        static let goodMorning: String = "Good Morning"
        static let goodAfternoon: String = "Good Afternoon"
        static let goodEvening: String = "Good Evening"
    }

    switch hour {
         case 0..<12 : timeOfTheDay = . goodMorning
         case 12..<18 : timeOfTheDay = . goodAfternoon
         case 18..<24 : timeOfTheDay = . goodEvening
         default: print("DEBUG: Hi")
    }
Indrre commented 2 years ago

Done