ReiVerdugo / SurveysList

A native iOS application on Swift to display a list of surveys
0 stars 0 forks source link

Advantage of creating color object every time? #7

Open jasonnam opened 5 years ago

jasonnam commented 5 years ago
class var red1: UIColor {
  return UIColor(red: 213.0/255.0, green: 17.0/255.0, blue: 17.0/255.0, alpha: 1.0)
}
ReiVerdugo commented 5 years ago

In case the app has a redesign or we need to build a similar app for another client it would be easier to change the colors used. Probably I should have used primaryColor instead of red1.

jasonnam commented 5 years ago

I mean why it is var and computed? In my opinion it is better to make it let and stored

class let red1 = UIColor(red: 213.0/255.0, green: 17.0/255.0, blue: 17.0/255.0, alpha: 1.0)
ReiVerdugo commented 5 years ago

Oh I see. Yes I think you're right. In some cases I was used to use class var so it could be overridden but in this case it wouldn't make sense. I can change to let instead. Thanks.