|
| 1 | +/* |
| 2 | + Copyright (C) 2014 Quentin Mathe |
| 3 | +
|
| 4 | + Date: July 2014 |
| 5 | + License: MIT (see COPYING) |
| 6 | + */ |
| 7 | + |
| 8 | +#import <Foundation/Foundation.h> |
| 9 | + |
| 10 | +NS_ASSUME_NONNULL_BEGIN |
| 11 | + |
| 12 | +/** |
| 13 | + * @group Utilities |
| 14 | + * @abstract Distributed notification center compatible with sandboxing. |
| 15 | + * |
| 16 | + * When sandboxing is enabled, posting a distributed notification results |
| 17 | + * in a normal notification. |
| 18 | + * |
| 19 | + * For non-sandboxed applications on macOS, we use |
| 20 | + * NSDistributedNotificationCenter to keep multiple store instances (using the |
| 21 | + * same UUID) in sync, accross processes and inside the current process. For |
| 22 | + * sandboxed applications on iOS or macOS, this is the same, except we don't |
| 23 | + * support the 'accross processes' case. |
| 24 | + * |
| 25 | + * We cannot ignore distributed notifications in a sandboxed app, because we |
| 26 | + * support keeping in sync two editing contexts backed by two distinct stores |
| 27 | + * objects with the same UUID. |
| 28 | + * |
| 29 | + * See also COSQLiteStore and COUndoTrackStore. |
| 30 | + **/ |
| 31 | +@interface CODistributedNotificationCenter : NSObject |
| 32 | +/** |
| 33 | + * Returns the default distributed notification center. |
| 34 | + */ |
| 35 | ++ (CODistributedNotificationCenter *)defaultCenter; |
| 36 | +/** |
| 37 | + * Adds an observer for the given selector, notification name and object identifier. |
| 38 | + */ |
| 39 | +- (void)addObserver: (id)observer |
| 40 | + selector: (SEL)aSelector |
| 41 | + name: (nullable NSNotificationName)aName |
| 42 | + object: (nullable NSString *)anObject; |
| 43 | +/** |
| 44 | + * Removes an observer. |
| 45 | + */ |
| 46 | +- (void)removeObserver: (id)observer; |
| 47 | +/** |
| 48 | + * Posts a notification with the given sender and info. |
| 49 | + * |
| 50 | + * deliverImmediately is ignored, and considered as YES all the time. |
| 51 | + */ |
| 52 | +- (void)postNotificationName: (nullable NSNotificationName)aName |
| 53 | + object: (nullable NSString *)aSender |
| 54 | + userInfo: (nullable NSDictionary *)userInfo |
| 55 | + deliverImmediately: (BOOL)deliverImmediately; |
| 56 | +@end |
| 57 | + |
| 58 | +NS_ASSUME_NONNULL_END |
0 commit comments