如何从Swift调用dispatch_基准

如何从Swift调用dispatch_基准,c,swift,cocoa,grand-central-dispatch,C,Swift,Cocoa,Grand Central Dispatch,dispatch\u benchmark()是GCD中未导出的函数。但是,您可以通过在代码中声明,在目标C中调用它: uint64_t dispatch_benchmark(size_t count, void (^block)(void)); 我怎样才能做到这一点是Swift?只需将声明放入您的桥接标题中: @import Foundation; uint64_t dispatch_benchmark(size_t count, void (^block)(void)); 这将使该功能在

dispatch\u benchmark()
GCD
中未导出的函数。但是,您可以通过在代码中声明,在
目标C
中调用它:

uint64_t dispatch_benchmark(size_t count, void (^block)(void));

我怎样才能做到这一点是
Swift

只需将声明放入您的桥接标题中:

@import Foundation;

uint64_t dispatch_benchmark(size_t count, void (^block)(void));
这将使该功能在Swift中自动可用