I a struct model named User.. with the following code
struct User {
let userId: Double
}
extension User {
init(json: JSON) {
self.userId = json["userId"].double!
}
}
And have normal class with generic like the following
class LoginTask<User>: Operation {
var userName: String
var password: String
init(username: String, password: String) {
self.userName = username
self.password = password
}
var request: Request {
return UserRequests.login(username: self.userName, password: self.password)
}
func exeute(in dispatcher: Dispatcher, completed: (User) -> Void) {
do {
do {
try dispatcher.execute(request: self.request, completion: { (response, error) in
if error == nil {
let user = User(json: response)
}
})
} catch {
}
}
}
}
Operation is a protocol is having associatedtype named Output
now on line
let user = User(json: response)
it gives error
Non-nominal type 'User' does not support explicit initialization
I tried to make User.Type .. but may be I don't fully understand the concept or the error.