DMop
DMop

Reputation: 483

Expression Type 'Set<NSObject>' is ambiguous without more Context

I recently switched to Swift 3 and I got an error with the following line that I didn't get in swift 2. The layerClient call refers to the layerkit api, but the error seems to deal more with typing than the api. The error itself is "Expression Type 'Set' is ambiguous without more ".

layerClient.autodownloadMIMETypes = Set<NSObject>(arrayLiteral: "image/png")

Upvotes: 0

Views: 240

Answers (1)

Craig Siemens
Craig Siemens

Reputation: 13296

I assume you're using this framework.

You don't need the <NSObject> when creating the Set. It can figure out with type it contains by the parameter you pass to the init method. Also autodownloadMIMETypes type in swift would be Set<String> which wouldnt match Set<NSObject>. This should work.

layerClient.autodownloadMIMETypes = Set(arrayLiteral: "image/png")

Also, since Set conforms to the ExpressibleByArrayLiteral protocol, you should be able to just create it like an array.

layerClient.autodownloadMIMETypes = ["image/png"]

Upvotes: 2

Related Questions