i new swift development , struggling while trying tutorials (i know, step step, apparently must have messed somewhere along line , can't figure out life of why isn't working. not @ debugging , lack solid understanding of foundation of language. if point me in right direction appreciate it.
i've tried commenting things out try , "bare bones" possible while still being able "conform" pretty stuck @ moment.
here code:
error received on class:
final class forecastapiclient : apiclient { let configuration: nsurlsessionconfiguration lazy var session : nsurlsession = { return nsurlsession(configuration: self.configuration) }() private let token : string init(config: nsurlsessionconfiguration, apikey: string){ self.configuration = config self.token = apikey } convenience init(apikey: string){ self.init(config: nsurlsessionconfiguration.defaultsessionconfiguration(), apikey: apikey) } func fetchcurrentweather(coordinate: coordinate, completion : apiresult<currentweather> -> void){ let request = forecast.current(token: self.token, coordinate: coordinate).request } }
trying conform protocol:
protocol apiclient{ var configuration : nsurlsessionconfiguration { } var session : nsurlsession { } init(withconfig: nsurlsessionconfiguration) func jsontaskwithrequest(request: nsurlrequest, completion: jsontaskcompletion) -> jsontask func fetch<t>(request: nsurlrequest, parse: json -> t?, completion: apiresult<t> -> void) }
sorry if answered.. searched , read through other posts, still wasn't able figure out.
thanks in advance!
it looks class isn't implementing 2 of methods protocol:
func jsontaskwithrequest(request: nsurlrequest, completion: jsontaskcompletion) -> jsontask
and
func fetch<t>(request: nsurlrequest, parse: json -> t?, completion: apiresult<t> -> void)
also, class has initializer signature:
init(config: nsurlsessionconfiguration, apikey: string)
when protocol requires:
init(withconfig: nsurlsessionconfiguration)