如图为啥,为啥显示是这不科学呢,我觉得应该显示科学才对,莫非label和myLabel是绑定在一起的?
怪我咯2017-04-17 17:55:47
The class in Swift is a reference type, which is actually a pointer. label and myLabel point to a memory address, so they change the same thing
It’s just that the pointer myLabel cannot change the address it points to
You can try myLabel == = label to determine whether the addresses are the same
PHP中文网2017-04-17 17:55:47
label
和 myLabel
引用的是同一个对象,label.text = “xx”
和 myLabel.text = “yy”
都是设置那个对象的 text
Properties.
天蓬老师2017-04-17 17:55:47
In Swift, all transfers of value types are copies, and all transfers of reference types are addresses
ringa_lee2017-04-17 17:55:47
Thank you to the three great people above.
struct and enum are value types (pass by copy value) class instance objects are reference types (pass pointer)