问题
Everything good until, I've downloaded the new version of Xcode 6.3 and Swift 1.2.
But when I compile my app again, a lots of error came out. I've dealt with most of them but there is a specific error that I couldn't figure it out the solutions
The error is "AnyObject? is not convertible to String?"
Before updating Xcode this was absolutely fine :
let firstName = self.currentUser["firstName"] as? String
回答1:
i've figured out the solution
let firstName = self.currentUser?["firstName"] as? String
if let firstname = firstName {
// Continue
} else {
// Handling the error.
}
来源:https://stackoverflow.com/questions/29543470/how-to-cast-anyobject-to-string-in-swift-1-2