Skip to content

Decode Array of Model #2

Description

@macshodan

Hi,
first of all thanks for your post, it's really a great example of doing networking layers.
I'm struggling though to use it for returning array of objects conforming to Model protocols.
When I've used a similar approach (a send function with generics) I used the Decodable instead of Model when defining the send function, this will allow me for example to write calls like that:

Network.shared.send(request) { (result: Result<[Output], Error>) in

without any errors. Now even if the class Output conforms to the Model protocols I receive the following error:

Instance method 'send(_:completion)' requires that '[Output]' conforms to 'Model'

I can't understand how to make it happen since the protocol is only a wrapper for Codable.

Thanks again and merry Christmas.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions