What is the new syntax for dispatch_once
in Swift after the changes made in language version 3? The old version was as follows.
var token: dispa
You can still use it if you add a bridging header:
typedef dispatch_once_t mxcl_dispatch_once_t;
void mxcl_dispatch_once(mxcl_dispatch_once_t *predicate, dispatch_block_t block);
Then in a .m
somewhere:
void mxcl_dispatch_once(mxcl_dispatch_once_t *predicate, dispatch_block_t block) {
dispatch_once(predicate, block);
}
You should now be able to use mxcl_dispatch_once
from Swift.
Mostly you should use what Apple suggest instead, but I had some legitimate uses where I needed to dispatch_once
with a single token in two functions and there is not covered by what Apple provide instead.