103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
}
#endif
- (void)dealloc
{
[_name release];
[_observer release];
#ifdef OF_HAVE_BLOCKS
[_block release];
#endif
[_object release];
[super dealloc];
}
- (bool)isEqual: (OFNotificationCenterHandle *)handle
{
if (![handle isKindOfClass: [OFNotificationCenterHandle class]])
|
>
<
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
}
#endif
- (void)dealloc
{
[_name release];
[_observer release];
[_object release];
#ifdef OF_HAVE_BLOCKS
[_block release];
#endif
[super dealloc];
}
- (bool)isEqual: (OFNotificationCenterHandle *)handle
{
if (![handle isKindOfClass: [OFNotificationCenterHandle class]])
|
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
return [handle autorelease];
}
#endif
- (void)removeObserver: (OFNotificationCenterHandle *)handle
{
if (![handle isKindOfClass: [OFNotificationCenterHandle class]])
@throw [OFInvalidArgumentException exception];
#ifdef OF_HAVE_THREADS
[_mutex lock];
@try {
#endif
OFNotificationName name = [[handle->_name copy] autorelease];
OFMutableSet *handlesForName = [_handles objectForKey: name];
[handlesForName removeObject: handle];
if (handlesForName.count == 0)
[_handles removeObjectForKey: name];
#ifdef OF_HAVE_THREADS
} @finally {
[_mutex unlock];
}
#endif
}
- (void)removeObserver: (id)observer
selector: (SEL)selector
name: (OFNotificationName)name
object: (id)object
{
|
>
>
>
>
|
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
return [handle autorelease];
}
#endif
- (void)removeObserver: (OFNotificationCenterHandle *)handle
{
void *pool = objc_autoreleasePoolPush();
if (![handle isKindOfClass: [OFNotificationCenterHandle class]])
@throw [OFInvalidArgumentException exception];
#ifdef OF_HAVE_THREADS
[_mutex lock];
@try {
#endif
OFNotificationName name = [[handle->_name copy] autorelease];
OFMutableSet *handlesForName = [_handles objectForKey: name];
[handlesForName removeObject: handle];
if (handlesForName.count == 0)
[_handles removeObjectForKey: name];
#ifdef OF_HAVE_THREADS
} @finally {
[_mutex unlock];
}
#endif
objc_autoreleasePoolPop(pool);
}
- (void)removeObserver: (id)observer
selector: (SEL)selector
name: (OFNotificationName)name
object: (id)object
{
|
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
callback(handle->_observer, handle->_selector,
notification);
#ifdef OF_HAVE_BLOCKS
}
#endif
}
objc_autoreleasePoolPop(pool);
}
@end
@implementation OFDefaultNotificationCenter
- (instancetype)autorelease
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
callback(handle->_observer, handle->_selector,
notification);
#ifdef OF_HAVE_BLOCKS
}
#endif
}
objc_autoreleasePoolPop(pool);
}
- (void)postNotificationName: (OFNotificationName)name
object: (nullable id)object
{
[self postNotificationName: name object: object userInfo: nil];
}
- (void)postNotificationName: (OFNotificationName)name
object: (nullable id)object
userInfo: (nullable OFDictionary *)userInfo
{
void *pool = objc_autoreleasePoolPush();
[self postNotification:
[OFNotification notificationWithName: name
object: object
userInfo: userInfo]];
objc_autoreleasePoolPop(pool);
}
@end
@implementation OFDefaultNotificationCenter
- (instancetype)autorelease
|