iphone - What do we mean by an Object "sending messages" and how do protocols help an object advertise the messages it supports? -


What do we mean by "sending a message" to an object and how the protocol supports a message in a message helps to? Does anyone have an example?

It is helpful to think about objects, - For other things), make decisions, and perform actions (together, and on other objects).

Within this concept, call "foo" method when calling x, which is a very programming-thing to say, we can talk to each other We can say that "x sends a message to foo y, or, more specifically," the text field x states that its textFieldDidChange: "or" x asks what happens to its framiston calibration level "or any statement about people It can easily be about fictional items.

(The reason for the term "message" is not entirely ideological: it is brought from Smaltak, one of the original languages ​​of Objective-C. This is a historical reason.)

< P> The protocols are like a job description, just as a person can wear the title of a person, janitor, or engineer, or director or receptionist, the same things that fulfill those tasks may be in accordance with the protocols by those names; Announcing That these objects are asking for messages or ask them, some aspects of their work

In real cocoa and cocoa touch use, the protocol usually describes a set of functions (then not in the programming sense) that the object can provide any other object, such as data sources Receive data, or a set of information that can answer the object, such as an applicationDidFinishLaunching: , applicationWillTerminate: etc. of an app representative.

Sometimes a protocol can be even more common, such as a broader version of a super-class - a real world analogy of many different types of vendors, and an example of a cocoa, Many different classes are objects that answer validation messages. In some frameworks, you can create an abstract class for this, but the protocol only lets you do the same thing (declare that a bunch of identical but different objects have some properties / abilities in commonality) without writing dummy implementations.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -