@@ -24,17 +24,14 @@ public enum DarwinNotificationCenter {
2424 /// - Parameter observer: The token returned by ``addObserver(name:queue:block:)``
2525 /// - Returns: `true` iff the given `observer` is valid
2626 public static func isValid( _ observer: ObserverToken ) -> Bool {
27- notify_is_valid_token ( observer)
27+ return notify_is_valid_token ( observer)
2828 }
2929
3030 /// Post a darwin notification that can be listened for from other processes.
3131 ///
3232 /// - Parameter name: The name of the notification to post.
3333 public static func postNotification( name: DarwinNotificationName ) {
34- owsAssertDebug ( name. isValid)
35- name. withCString { cName in
36- _ = notify_post ( cName)
37- }
34+ _ = notify_post ( name. rawValue)
3835 }
3936
4037 /// Add an observer for a darwin notification of the given name.
@@ -45,12 +42,8 @@ public enum DarwinNotificationCenter {
4542 /// removing the observer after receipt.
4643 /// - Returns: An ``ObserverToken`` that can be used to remove this observer.
4744 public static func addObserver( name: DarwinNotificationName , queue: DispatchQueue , block: @escaping ( ObserverToken ) -> Void ) -> ObserverToken {
48- owsAssertDebug ( name. isValid)
49-
5045 var observer = Self . invalidObserverToken
51- name. withCString { cName in
52- _ = notify_register_dispatch ( cName, & observer, queue, block)
53- }
46+ _ = notify_register_dispatch ( name. rawValue, & observer, queue, block)
5447 return observer
5548 }
5649
@@ -63,8 +56,7 @@ public enum DarwinNotificationCenter {
6356 owsFailDebug ( " Invalid observer token. " )
6457 return
6558 }
66-
67- notify_cancel ( observer)
59+ _ = notify_cancel ( observer)
6860 }
6961
7062 /// Retrieves the state for a given observer. This value can be set and read from
@@ -80,7 +72,7 @@ public enum DarwinNotificationCenter {
8072 }
8173
8274 var result : UInt64 = 0
83- notify_get_state ( observer, & result)
75+ _ = notify_get_state ( observer, & result)
8476 return result
8577 }
8678}
0 commit comments