前端之家收集整理的这篇文章主要介绍了
Swift学习笔记—— 类和结构体,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
class SomeClass {
}
struct SomeStructure {
}
struct Resolution{
var width = 0
var height = 0
}
class VideoMode {
var resolution = Resolution()
var interlaced:Bool?
var name:String?
}
let someResolution = Resolution(width: 10,height: 20)
let someVideoMode = VideoMode()
let hd = Resolution(width: 1920,height: 1080)
var cinema = hd
cinema.width = 2048
println("\(hd.width)")
let tenEighty = VideoMode()
tenEighty.resolution = hd
tenEighty.interlaced = true
tenEighty.name = "我们"
let alsoTenEighty = tenEighty
alsoTenEighty.name = "他们"
println("tenEighty.name is \(tenEighty.name) and alsoTenEighty.name is \(alsoTenEighty.name)")