条件所限,只能在WINDOWS上学习SWIFT的基本语法。
还有,有swift for windows 1.9帮忙,
看书没那么燥。。。。
struct Resolution {
var width = 0
var height = 0
}
class VideoMode {
var resolution = Resolution()
var interlaced = false
var frameRate = 0.0
var name: String?
}
let someResolution = Resolution(width: 640, height: 480)
let someVideoMode = VideoMode()
print("The width of someResolution is \(someResolution.width)")
someVideoMode.resolution.width = 1280
print("The width of someVedioMode is \(someVideoMode.resolution.width)")
let hd = Resolution(width: 1920, height: 1080)
var cinema = hd
cinema.width = 2048
print("cienma is now \(cinema.width) pixels wide")
print("hd is still \(hd.width) pixels width")
enum CompassPoint {
case North, South, East, West
}
var currentDirection = CompassPoint.West
let rememberedDirection = currentDirection
currentDirection = .East
if rememberedDirection == .West {
print("The remembered direction is still .West")
}
let tenEighty = VideoMode()
tenEighty.resolution = hd
tenEighty.interlaced = true
tenEighty.name = "1080i"
tenEighty.frameRate = 25.0
let alsoTenEighty = tenEighty
alsoTenEighty.frameRate = 30.0
print("The frameRate property of tenEighty is now \(tenEighty.frameRate)")