/**
结构体常量和类常量的存储属性
*/
struct Person {
var name: String
var age: Int
}
// 结构体常量对象,它本身是一个常量,其次它对应的对象不可以被修改
let p = Person.init(name: "zhangsan",age: 10)
// 不能修改了吧
// p.name = "lisi"
// p.age = 10
let p1 = Person.init(name: "lisi",age: 1)
// 这个地方就不能修改了
// p = p1
class People {
var name: String = "zhangsan"
var age: Int = 10
}
// 类 常量对象,它本身是一个常量,其次它对应的对象可以通过它来进行修改
let people = People.init()
people.name = "lisi"
people.age = 10
let people1: People = People.init()
// people = people1
/**
结构体或者枚举:值
类:引用
*/
原文链接:https://www.f2er.com/swift/322420.html