Reputation: 53481
I have a function that returns AnyObject?
func aFunction(param:String) -> AnyObject?
How do I cast it to a String? and String
Upvotes: 4
Views: 3432
Reputation: 51911
Try this:
if let result = aFunction("test") as? String {
// Here, `result` is String
println(result)
}
Upvotes: 8