How to convert Swift Bool? -> String?

String(Bool) is the easiest way.

var myBool = true
var boolAsString = String(myBool)

let trueString = String(true) //"true"
let trueBool = Bool("true")   //true
let falseBool = Bool("false") //false
let nilBool = Bool("foo")     //nil

let b1: Bool? = true
let b2: Bool? = false
let b3: Bool? = nil

print(b1?.description ?? "none") // "true"
print(b2?.description ?? "none") // "false"
print(b3?.description ?? "none") // "none"

or you can define 'one liner' which works with both Bool and Bool? as a function

func BoolToString(b: Bool?)->String { return b?.description ?? "<None>"}

Tags:

Casting

Swift