ObjFW
Loading...
Searching...
No Matches
OFNotificationCenter.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This file is part of ObjFW. It may be distributed under the terms of the
7 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8 * the packaging of this file.
9 *
10 * Alternatively, it may be distributed under the terms of the GNU General
11 * Public License, either version 2 or 3, which can be found in the file
12 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13 * file.
14 */
15
16#import "OFObject.h"
17#import "OFNotification.h"
18
19OF_ASSUME_NONNULL_BEGIN
20
21@class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
22#ifdef OF_HAVE_THREADS
23@class OFMutex;
24#endif
25
26#ifdef OF_HAVE_BLOCKS
32typedef void (^OFNotificationCenterBlock)(OFNotification *notification);
33#endif
34
41#ifndef OF_NOTIFICATION_CENTER_M
42OF_SUBCLASSING_RESTRICTED
43#endif
45{
46#ifdef OF_HAVE_THREADS
47 OFMutex *_mutex;
48#endif
50}
51
52#ifdef OF_HAVE_CLASS_PROPERTIES
53@property (class, readonly, nonatomic) OFNotificationCenter *defaultCenter;
54#endif
55
59+ (OFNotificationCenter *)defaultCenter;
60
73- (void)addObserver: (id)observer
74 selector: (SEL)selector
75 name: (OFNotificationName)name
76 object: (nullable id)object;
77
87- (void)removeObserver: (id)observer
88 selector: (SEL)selector
89 name: (OFNotificationName)name
90 object: (nullable id)object;
91
92#ifdef OF_HAVE_BLOCKS
105- (id)addObserverForName: (OFNotificationName)name
106 object: (nullable id)object
107 usingBlock: (OFNotificationCenterBlock)block;
108
115- (void)removeObserver: (id)observer;
116#endif
117
123- (void)postNotification: (OFNotification *)notification;
124
131- (void)postNotificationName: (OFNotificationName)name
132 object: (nullable id)object;
133
142- (void)postNotificationName: (OFNotificationName)name
143 object: (nullable id)object
144 userInfo: (nullable OFDictionary *)userInfo;
145@end
146
147OF_ASSUME_NONNULL_END
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:38
An abstract class for storing objects in a dictionary.
Definition OFDictionary.h:80
An abstract class for storing and changing objects in a dictionary.
Definition OFMutableDictionary.h:44
A class for creating mutual exclusions.
Definition OFMutex.h:34
A class to send and register for notifications.
Definition OFNotificationCenter.h:45
A class to represent a notification for or from OFNotificationCenter.
Definition OFNotification.h:38
The root class for all other classes inside ObjFW.
Definition OFObject.h:688