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