Initialize variable using another variable's initialized value in Swift -
so wanna is:
let margin: cgfloat = 10 let width: cgfloat = 100 - margin // used self.margin but here's error i'm getting:
instance member 'margin' cannot used on type 'historyviewcontroller' what should do?
let margin: cgfloat = 10 var width: cgfloat { return 100 - self.margin } or
lazy var width: cgfloat = 100 - self.margin this because @ instance variable initialization time, instance doesn't exist yet. using lazy initialization or computed property fix this.
Comments
Post a Comment