Tuesday, May 12, 2015

String to Bool in Swift

To convert String to Bool in Swift, add following extension

extension String {
    func toBool() -> Bool{
        if self == "false" {
            return false
        }else{
            return true
        }
    } 

No comments:

Post a Comment