在Apple的NSObject文档中,“接收器"的概念是什么? [英] In Apple's Documentation for NSObject, what is the idea of the "receiver"?

查看:64
本文介绍了在Apple的NSObject文档中,“接收器"的概念是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Swift中的面向对象编程,我发现一个很好的起点是NSObject,因为所有对象都继承自该基类.在NSObject的实例?

I'm researching Object-Oriented Programming in Swift and I figured a great place to start would be NSObject, since all objects inherit from this base class. In Apple's documentation for NSObject, there are areas that refer to a "receiver". Does "receiver" mean an instance of NSObject?

推荐答案

它是指Objective-c的向对象发送消息"的范例.在那个世界中,方法"并不是真正的方法,只是对象在说:嘿,如果有人向我发送此消息(与该方法名称匹配的字符串),我会响应."即该对象是消息的接收者".所以是的,在您提到的文档中,NSObject是接收者,您看到的方法中有消息".

It refers to Objective-c's paradigm of "sending messages" to objects. In that world, a "method" isn't REALLY a method, it's just the object saying, "Hey, if someone sends me this message (a string that matches that method name), I'll respond to it." i.e. that object is the "receiver" for the message. So yes, in the documentation you mention, NSObject is the receiver and the methods you see there are the "messages".

这篇关于在Apple的NSObject文档中,“接收器"的概念是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆