In Apple's Documentation for NSObject, what is

2019-02-27 03:14发布

问题:

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?

回答1:

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".