[go: up one dir, main page]

Menu

[9a0086]: / man / man3 / Message.3  Maximize  Restore  History

Download this file

169 lines (160 with data), 2.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
.TH "Message" 3 "May 18, 2025"
.SH Message
.PP
.B
Inherits from:
Object
.PP
.B
Maturity Index:
Experimental
.SH Class Description
.PP
Message instances are used for forwarding Objective-C messages\&. When an object doesn\&'t respond to a message, the
.B
doesNotUnderstand:
method is invoked, with an argument that is an instance of this class :
.RS 3
- doesNotUnderstand:msg
.br
{
.br
[msg sentTo:someObject];
.br
return self;
.br
}
.br
.br
.RE
.PP
The user may override
.B
-doesNotUnderstand:
to send a
.B
sentTo:
message, which will forward the message to
.I
someObject
\&. If
.I
someObject
doesn\&'t respond to the message, it will receive a
.B
doesNotUnderstand:
message, and so on\&.
.PP
.B
Note:
To forward class (factory) methods, override the class method
.B
+doesNotUnderstand:
\&.
.PP
Also see Object\&'s
.B
doesNotUnderstand:
method for more details\&.
.SH Method types
.PP
.B
Creating Messages
.RS 3
.br
* selector:dispatch:args:
.RE
.PP
.B
Querying Messages
.RS 3
.br
* selector
.RE
.PP
.B
Sending Messages
.RS 3
.br
* sentTo:
.RE
.SH Methods
.PP
selector:dispatch:args:
.RS 1
+
.B
selector
:(SEL)
.I
s
.B
dispatch
:(ARGIMP)
.I
d
.B
args
:(void *)
.I
a
.RE
.PP
Creates a Message instance with the indicated selector name and pointer to argument structure\&. The argument structure for a message consists of return value of the method (if not void), followed by the arguments of the method :
.RS 3
struct {
.br
int ret;
.br
int a;
.br
double d;
.br
}
.br
.RE
.PP
The above structure corresponds to a method such as (int)foo:(int)a bar:(double)d\&.
.PP
The
.I
dispatch
argument is a (compiler generated) function that decodes the arguments from the argument structure, and dispatches the messages\&.
.PP
selector
.RS 1
- (
SEL
)
.B
selector
.RE
.PP
Returns the selector for this message\&.
.PP
sentTo:
.RS 1
-
.B
sentTo
:
.I
receiver
.RE
.PP
Forwards the message to
.I
receiver
(if it\&'s not
.B
nil
) and returns the message itself (
.I
self
), not the return value of the message that was forwarded to
.I
receiver
\&. The latter return value is associated to the Message instance, so that it can be returned to the sender of the message that caused a
.B
doesNotUnderstand:
message to be sent\&.