在swift中绑定一个class的方法和变量叫什么?
What is it called when you bind a method and variable of a class in swift?
我正在学习一本关于编程约束的教程,然后决定阅读 Apple 的编程指南。我在 Apple 的指南中看到了以下代码行,它在一行代码中使用了一个方法和一个变量:
// Pin the leading edge of myView to the margin's leading edge
myView.leadingAnchor.constraint(equalTo: margins.leadingAnchor).isActive = true
我不知道可以用这种方式压缩代码。有这个术语吗?
抱歉听起来像菜鸟,但我想知道。
这是正常的。如果你阅读 constraint(equalTo:)
方法的 documentation,你会发现它 returns 是一个 NSLayoutConstraint
类型的对象,你可以像使用任何其他对象一样使用它 ==> 你可以以正常方式使用它的属性和方法。
这个概念叫做Chaining,它只与Swift无关。
我正在学习一本关于编程约束的教程,然后决定阅读 Apple 的编程指南。我在 Apple 的指南中看到了以下代码行,它在一行代码中使用了一个方法和一个变量:
// Pin the leading edge of myView to the margin's leading edge
myView.leadingAnchor.constraint(equalTo: margins.leadingAnchor).isActive = true
我不知道可以用这种方式压缩代码。有这个术语吗?
抱歉听起来像菜鸟,但我想知道。
这是正常的。如果你阅读 constraint(equalTo:)
方法的 documentation,你会发现它 returns 是一个 NSLayoutConstraint
类型的对象,你可以像使用任何其他对象一样使用它 ==> 你可以以正常方式使用它的属性和方法。
这个概念叫做Chaining,它只与Swift无关。