Convert AnyObject? to string

Do I have a function that returns AnyObject?

func aFunction(param:String) -> AnyObject?

How do I pass it to a string? and String

+4
source share
1 answer

Try the following:

if let result = aFunction("test") as? String {
    // Here, `result` is String
    println(result)
}
+8
source

All Articles