mirror of https://github.com/oxen-io/session-ios
parent
1382270c66
commit
35a2470cb7
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// We often use notifications as way to publish events.
|
||||
//
|
||||
// We never need these events to be received synchronously,
|
||||
// so we should always send them asynchronously to avoid any
|
||||
// possible risk of deadlock. These methods also ensure that
|
||||
// the notifications are always fired on the main thread.
|
||||
@interface NSNotificationCenter (OWS)
|
||||
|
||||
- (void)postNotificationNameAsync:(NSNotificationName)name object:(nullable id)object;
|
||||
- (void)postNotificationNameAsync:(NSNotificationName)name
|
||||
object:(nullable id)object
|
||||
userInfo:(nullable NSDictionary *)userInfo;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSNotificationCenter+OWS.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation NSNotificationCenter (OWS)
|
||||
|
||||
- (void)postNotificationNameAsync:(NSNotificationName)name object:(nullable id)object
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self postNotificationName:name object:object];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)postNotificationNameAsync:(NSNotificationName)name
|
||||
object:(nullable id)object
|
||||
userInfo:(nullable NSDictionary *)userInfo
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self postNotificationName:name object:object userInfo:userInfo];
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
Loading…
Reference in New Issue