pJes2
pJes2

Reputation: 623

Swift dynamic cast failure - AnyObject?! to String

I've just updated to Xcode 6 beta 6 and I have a following problem with my code which was working before

let reminderSubject = reminder["subject"]
println("reminderSubject: \(reminderSubject)")
let tempTuple = (reminderSubject as String)

reminderSubject is of type AnyObject?! when I try to downcast it to String it crashes with "Swift dynamic cast failure" message. The value printed by println is: Optional(Hey its Test!)

So the question is how to correctly cast AnyObject?! to String in Swift?

Upvotes: 1

Views: 703

Answers (1)

pJes2
pJes2

Reputation: 623

Ok I've done it with:

let tempTuple = ("\(reminderSubject!!)")

Upvotes: 1

Related Questions