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
|
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
|
+
-
-
+
+
+
-
-
+
+
+
+
+
-
-
+
+
+
-
-
+
+
+
+
+
-
-
+
+
+
|
size_t i, count = [_delegates count];
for (i = 0; i < count; i++) {
if (items[i] != delegate)
continue;
[_delegates removeItemAtIndex: i];
if (i <= handlerIndex)
handlerIndex--;
if (i <= _handlerIndex)
_handlerIndex--;
return;
}
}
- (BOOL)broadcastSelector: (SEL)selector
withObject: (id)object
{
size_t count = [_delegates count];
id *items = [_delegates items];
BOOL handled = NO;
for (handlerIndex = 0; handlerIndex < count; handlerIndex++) {
id responder = items[handlerIndex];
for (_handlerIndex = 0; _handlerIndex < count; _handlerIndex++) {
id responder = items[_handlerIndex];
if (![responder respondsToSelector: selector])
continue;
BOOL (*imp)(id, SEL, id) = (BOOL(*)(id, SEL, id))
[responder methodForSelector: selector];
handled |= imp(responder, selector, object);
/*
// Update count and items, since the handler might have
// changed them.
* Update count and items, since the handler might have changed
* them.
*/
count = [_delegates count];
items = [_delegates items];
}
return handled;
}
- (BOOL)broadcastSelector: (SEL)selector
withObject: (id)object1
withObject: (id)object2
{
size_t count = [_delegates count];
id *items = [_delegates items];
BOOL handled = NO;
for (handlerIndex = 0; handlerIndex < count; handlerIndex++) {
id responder = items[handlerIndex];
for (_handlerIndex = 0; _handlerIndex < count; _handlerIndex++) {
id responder = items[_handlerIndex];
if (![responder respondsToSelector: selector])
continue;
BOOL (*imp)(id, SEL, id, id) = (BOOL(*)(id, SEL, id, id))
[responder methodForSelector: selector];
handled |= imp(responder, selector, object1, object2);
/*
// Update count and items, since the handler might have
// changed them.
* Update count and items, since the handler might have changed
* them.
*/
count = [_delegates count];
items = [_delegates items];
}
return handled;
}
@end
|