I'm trying to essentially do an valid check on a String in Swift, however I'm getting an error Conditional downcast from 'String' to 'String' always succeeds.
zipCode is created:
var zipCode = String()
Checking for a valid string at a later time:
if let code = zipCode as? String {
println("valid")
}
Can someone help me understand what I'm doing wrong?
zipCodeis a kind ofStringin every moment, why do you want to downcast it toString, if you already know it is aString? the compiler has been just intelligent enough to warn you not to do such pointless task. if you want to work optional, that would make sense, but your OP has not mentioned anything about any optionals.