Swift Cheat Sheet Formatted
Swift Cheat Sheet Formatted
class MyPointClass {
var x = 0.0
var y = 0.0
}
class MyPointClass { var ptA = MyPointClass()
} ptA.x = 25.0
var ptA = MyPointClass() ptA.y = 50.0
Stored Properties
class Distance {
var miles: Double = 0.0
var km: Double {
get {
return 1.60934 * mil
}
set (km) {
miles = km / 1.6093
class PointMath { }
lazy var someValue = 1.2345 }
} }
operties Computed Properties
class MyPointClass {
var x: Double = 0.0 {
willSet(newX) {
print("About to set to \(newX)")
}
didSet(oldX) {
print("Changed from \(oldX)")
} class MyPointClass {
} static var origin = (x: 0, y:
} }
vers Type Properties
struct Go {
var row: Int class Car {
mutating func move(row: Int) { class func speedLimit() ->
self.row += row return 120
} }
} }
ods in Structures Type Method