Extensions - Computed properties
extension Notification.Name {
static let noti1 = Notification.Name("Noti")
}
extension UIColor {
static let myBackgroundColor = UIColor.red
static let myLabelColor = UIColor.gray
}
extension String {
var localized: String {
var result = Bundle.main.localizedString(forKey: self, value: nil, table: nil)
if result == self {
result = Bundle.main.localizedString(forKey: self, value: nil, table: "Invoice")
}
return result
}
var capital: String {
return self.uppercased()
}
}
//MARK: Computed Properties
extension Int {
var sq: Int {
return self * self
}
}
class ClassA: NSObject {
var property:Int? {
willSet(newProperty){
print("property - willSet called - value - \(newProperty!)")
}
didSet{
print("property - didSet called")
}
}
}
Comments
Post a Comment