This is a type covert issue. for example:
Cannot assign value of type ‘AnyObject’ to type ‘CAAnimationDelegate?’
if let delegate: AnyObject = completionDelegate {
rotateAnimation.delegate = delegate
}
Solution 1: if you are sure the your is type of HereIsTheTypeName , you can make a force cast like this:
rotateAnimation.delegate = delegate as! HereIsTheTypeName
(rotateAnimation.delegate = delegate as! CAAnimationDelegate
)
Solution2: use flatMap and an individual optional cast of each object if you are using array like this:
stringArray = tempStringArray.flatMap{ $0 as? String }
flatMap reference:
https://developer.apple.com/reference/swift/sequence/1641503-flatmap
Official exmaple:
let possibleNumbers = [“1”, “2”, “three”, “///4///”, “5”]
let mapped: [Int?] = numbers.map { str in Int(str) }
// [1, 2, nil, nil, 5]
let flatMapped: [Int] = numbers.flatMap { str in Int(str) }
// [1, 2, 5]