I want
func foo(inout stop: Bool) -> Void {
// ...
}
use in my Objective-C part. But it is never generated in Module-Swift.h header. If
You can't use an inout
parameter when bridging with Objective-C, but you can do something similar if you use an UnsafeMutablePointer
(T
would be Bool
in your case). It would look something like this:
@objc func foo(stop: UnsafeMutablePointer) -> Void {
if stop != nil {
// Use the .pointee property to get or set the actual value stop points to
stop.pointee = true
}
}
TestClass.swift:
public class TestClass: NSObject {
@objc func foo(stop: UnsafeMutablePointer) -> Void {
stop.pointee = true
}
}
Objective-C:
TestClass *test = [[TestClass alloc] init];
BOOL stop = false;
[test foo:&stop];
// stop is YES here