在iOS API 参考中,"receiver" 是什么意思?
In the iOS API Reference, what does "receiver" mean?
到目前为止,我已经能够相当一致地理解和使用 API 参考资料,但真正让我感到厌烦的一件事是,每次我 运行 进入这个术语时,我基本上必须忽略使用它的定义,并通过在代码中应用它来弄清楚所讨论的 method/property 是如何工作的。
所以有人可以为我澄清这件事吗?
当 iOS API 参考文献提到 "receiver"(并且经常这样做)时,该术语指的是什么?
这种方法描述的例子:
https://developer.apple.com/reference/uikit/uiview/1622442-convert
Converts a point from the receiver’s coordinate system to that of the specified view.
接收者是调用方法的对象。例如,在这段代码中:
let myView = UIView()
myView.convert(point, to: otherView)
convert(_:to:)
方法的接收者是myView
。
这个术语来自 SmallTalk 和 Objective-C,其中方法被称为 "messages" 你 "send" 对象,你的对象 "receive" 它们。
到目前为止,我已经能够相当一致地理解和使用 API 参考资料,但真正让我感到厌烦的一件事是,每次我 运行 进入这个术语时,我基本上必须忽略使用它的定义,并通过在代码中应用它来弄清楚所讨论的 method/property 是如何工作的。
所以有人可以为我澄清这件事吗?
当 iOS API 参考文献提到 "receiver"(并且经常这样做)时,该术语指的是什么?
这种方法描述的例子:
https://developer.apple.com/reference/uikit/uiview/1622442-convert
Converts a point from the receiver’s coordinate system to that of the specified view.
接收者是调用方法的对象。例如,在这段代码中:
let myView = UIView()
myView.convert(point, to: otherView)
convert(_:to:)
方法的接收者是myView
。
这个术语来自 SmallTalk 和 Objective-C,其中方法被称为 "messages" 你 "send" 对象,你的对象 "receive" 它们。