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
|
- (void)addDelegate: (id)delegate
{
[delegates addItem: &delegate];
}
- (void)removeDelegate: (id)delegate
{
id *cArray = [delegates cArray];
size_t i, count = [delegates count];
for (i = 0; i < count; i++) {
if (cArray[i] == delegate) {
[delegates removeItemAtIndex: i];
return;
}
}
}
- (BOOL)broadcastSelector: (SEL)selector
withObject: (id)object
{
id *cArray = [delegates cArray];
size_t i, count = [delegates count];
BOOL handled = NO;
for (i = 0; i < count; i++) {
if (![cArray[i] respondsToSelector: selector])
continue;
BOOL (*imp)(id, SEL, id) = (BOOL(*)(id, SEL, id))
[cArray[i] methodForSelector: selector];
handled |= imp(cArray[i], selector, object);
}
return handled;
}
- (BOOL)broadcastSelector: (SEL)selector
withObject: (id)object1
withObject: (id)object2
{
id *cArray = [delegates cArray];
size_t i, count = [delegates count];
BOOL handled = NO;
for (i = 0; i < count; i++) {
if (![cArray[i] respondsToSelector: selector])
continue;
|
|
|
|
|
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
|
- (void)addDelegate: (id)delegate
{
[delegates addItem: &delegate];
}
- (void)removeDelegate: (id)delegate
{
id *cArray = [delegates items];
size_t i, count = [delegates count];
for (i = 0; i < count; i++) {
if (cArray[i] == delegate) {
[delegates removeItemAtIndex: i];
return;
}
}
}
- (BOOL)broadcastSelector: (SEL)selector
withObject: (id)object
{
id *cArray = [delegates items];
size_t i, count = [delegates count];
BOOL handled = NO;
for (i = 0; i < count; i++) {
if (![cArray[i] respondsToSelector: selector])
continue;
BOOL (*imp)(id, SEL, id) = (BOOL(*)(id, SEL, id))
[cArray[i] methodForSelector: selector];
handled |= imp(cArray[i], selector, object);
}
return handled;
}
- (BOOL)broadcastSelector: (SEL)selector
withObject: (id)object1
withObject: (id)object2
{
id *cArray = [delegates items];
size_t i, count = [delegates count];
BOOL handled = NO;
for (i = 0; i < count; i++) {
if (![cArray[i] respondsToSelector: selector])
continue;
|