Swift中的布尔指针

oli*_*esF -1 boolean objective-c swift

给出以下方法:

- (void)doThingWith:(NSString *)string changeBoolean:(BOOL *)booleanPointer { // Do Something *booleanPointer = NO; }

我应该如何将其翻译为Swift?

mdh*_*mer 5

像这样的东西是等效的,但是我不确定您打算如何使用'NSString'变量,因此我省略了'inout'。

func doThingWith( string : String, inout changeBool : Bool ) {
    //Do Something
    changeBool = false
}
Run Code Online (Sandbox Code Playgroud)