0x00 Lesson
You’ve made it to the end of the seventh part of this series, so let’s summarize:
- You can create your own types using
structures
, which can have their own properties and methods. - You can use
stored
properties or usecomputed
properties to calculate values on the fly. - If you want to change a property inside a method, you must mark it as
mutating
. Initializers
are special methods that create structs. You get a memberwise initializer by default, but if you create your own you must give all properties a value.- Use the
self
constant to refer to the current instance of a struct inside a method. - The
lazy
keyword tells Swift to create properties only when they are first used. - You can share properties and methods across all instances of a struct using the
static
keyword. Access control
lets you restrict what code can use properties and methods.
0x01 我的小作品
欢迎体验我的作品之一:小汉字-XHanzi
汉字书写入门,常用汉字 3800
个,二级字表 2200
个
App Store
搜索即可~