0% found this document useful (0 votes)
55 views1 page

Swift Cheat Sheet Formatted

This document is a cheat sheet for Swift programming, focusing on object-oriented programming concepts. It covers classes, stored properties, computed properties, type properties, and type methods with examples. Key classes and structures like MyPointClass, Distance, and Car are illustrated to demonstrate these concepts.

Uploaded by

DARK DUCK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views1 page

Swift Cheat Sheet Formatted

This document is a cheat sheet for Swift programming, focusing on object-oriented programming concepts. It covers classes, stored properties, computed properties, type properties, and type methods with examples. Key classes and structures like MyPointClass, Distance, and Car are illustrated to demonstrate these concepts.

Uploaded by

DARK DUCK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Swift Cheat Sheet (Object-Oriented Programming)

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy