What is the Swift 3 syntax for creating AWSTask with the result?

Before Swift 3, my code for creating AWSTask with the result was something like this:

let results = ["resultOne", "resultTwo"]
let task = AWSTask(result: results)

But using Swift 3, I get this error message from Xcode 8:

Cannot convert value of type '[String]' to expected type of argument '_?'

Has anyone else come across this? Thank!

+4
source share
1 answer

Just add as NSArrayas follows:

let results = ["resultOne", "resultTwo"] as NSArray
let task = AWSTask(result: results)

Because it resultsmust confirm the protocol AnyObjectwhen defining AWSTask:

open class AWSTask<ResultType : AnyObject> : NSObject {...}

In fast 2.2 it ["resultOne", "resultTwo"]automatically stands out NSArray,

swift 3.0 [String] NSArray.

:

https://github.com/apple/swift-evolution/blob/master/proposals/0072-eliminate-implicit-bridging-conversions.md

+5

Source: https://habr.com/ru/post/1654875/


All Articles