Swift 2.2 breaks optionals/unwrapping optionals

Viewed 314

Swift 2.2 has broken almost all my code. Even this simple string assigning to label doesn't work anymore:

cell.categoryName.text = peopleArray![indexPath.row]["Name"] as? String

The error says "Downcast from 'String?!' to 'String' only unwraps optionals, did you mean to use '!!'?"

What changes do I have to do now.

EDIT:

More Problems:

if (dict["data"]!["DataDetails"] as! NSArray).count == 0 {
}

Due to this I am getting a segmentation fault and the error shows this: warning: cast from 'String?!' to unrelated type 'NSArray' always fails

UPDATE:

I was using NSDictionaries, NSArrays in my classes that seems to cause the problem. Changing all the literals from Obj-C to swift made the code work properly. So, I will also recommend other developers to prefer swift literals.

1 Answers
Related