Swift3.0 - 对象的标识

2018-09-14 14:54:56 浏览数 (1)

  • 怎么获取类的标识
代码语言:javascript复制
class Student { 
}
let x = Student()
let y = x
print(ObjectIdentifier(x) == ObjectIdentifier(y))
print(x === y)
let z = Student()
print(ObjectIdentifier(x) == ObjectIdentifier(z))
print(x === z)

创建对象的时候,会给对象分配一个独一无二的标识

0 人点赞