Created
March 7, 2022 01:30
-
-
Save lhoward/c0df244cc737b7e772f1f5866cafe52f to your computer and use it in GitHub Desktop.
SCDynamicStoreCreateWithHandler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <SystemConfiguration/SystemConfiguration.h> | |
| #include "SCExtras.h" | |
| static void | |
| __SCDynamicStoreBlockCallBack(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) | |
| { | |
| void (^block)(SCDynamicStoreRef store, CFArrayRef changedKeys) = info; | |
| block(store, changedKeys); | |
| } | |
| SCDynamicStoreRef | |
| SCDynamicStoreCreateWithHandler(CFAllocatorRef allocator, | |
| CFStringRef name, | |
| void (^block)(SCDynamicStoreRef store, CFArrayRef changedKeys)) | |
| { | |
| SCDynamicStoreContext storeContext = { | |
| .version = 0, | |
| .info = block, | |
| .retain = (const void * __nonnull (* __nullable)(const void *))_Block_copy, | |
| .release = _Block_release, | |
| .copyDescription = NULL | |
| }; | |
| return SCDynamicStoreCreate(allocator, name, __SCDynamicStoreBlockCallBack, &storeContext); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef SCExtras_h | |
| #define SCExtras_h | |
| #include <SystemConfiguration/SystemConfiguration.h> | |
| CF_IMPLICIT_BRIDGING_ENABLED | |
| CF_ASSUME_NONNULL_BEGIN | |
| _Nullable SCDynamicStoreRef | |
| SCDynamicStoreCreateWithHandler(_Nullable CFAllocatorRef allocator, | |
| _Nonnull CFStringRef name, | |
| void (^_Nonnull block)(_Nonnull SCDynamicStoreRef store, _Nonnull CFArrayRef changedKeys)); | |
| CF_ASSUME_NONNULL_END | |
| CF_IMPLICIT_BRIDGING_DISABLED | |
| #endif /* SCExtras_h */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment