If I have this Objective-C class:
@interface Foo : NSObject
-(void)requestURL:(NSString *)url completion:(void (^)(NSData * _Nullable))completion;
@end
It automatically gets exposed to Swift so I can call it like this:
let foo = Foo()
let data = await foo.requestUrl("https://example.com")
Say I have this C++ class:
class Bar {
public:
Bar();
void requestUrl(NSString *url, void (^completion)(NSData * _Nullable));
} SWIFT_SHARED_REFERENCE(retainFunc, releaseFunc);
Right now in Swift with C++ interop enabled, I have to use the completion block:
let bar = Bar()
bar.requestUrl("https://example.com") { dta in
//handle response
}
Is it reasonable to hope that someday Swift’s C++ interop will automatically convert this to async like it does for Objective-C? Or better yet, is there a way to get that to work today?
let bar = Bar()
let data = await bar.requestUrl("https://example.com")
I’m hoping the conversion logic for the Objective-C methods lives in Swift and doesn’t depend on the Objective-C runtime…?