Before Swift 3, my code for creating an AWSTask with a result was something like this:
let results = ["resultOne", "resultTwo"]
let task = AWSTask(result: results)
But using Swift 3, I'm getting this error message from Xcode 8:
Cannot convert value of type '[String]' to expected argument type '_?'
Has anyone else come across this? Thanks so much!
Simply add as NSArray
like this:
let results = ["resultOne", "resultTwo"] as NSArray
let task = AWSTask(result: results)
Because results
must confirm to Protocol AnyObject
when define AWSTask:
open class AWSTask<ResultType : AnyObject> : NSObject {...}
In swift 2.2 ["resultOne", "resultTwo"]
is auto brige to NSArray
,
But in swift 3.0 you have to brige [String]
to NSArray
manually.
This is the explanation: