您现在的位置是:首页 > 文章详情

在windows上操练swift语言:类和结构体

日期:2018-04-22点击:477

条件所限,只能在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)")

07c571c3ab06237c58ff62d171a9bffd9024f0ee
原文链接:https://yq.aliyun.com/articles/583888
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章