The .success initializer expects an argument, in this case of type ZPConfigsResponse<T>. But you’re passing in configs, ie. C:
let configs = try decoder.decode(C.self, from: data)
C doesn’t appear to be compatible with ZPConfigsResponse<T>, hence the error. Did I get it right? The code is hard to read, it would be nice to simplify it somehow.
I change the typealias BaseCompletion to: public typealias BaseCompletion<T: Codable> = (_ result: CoreLibResult<T>) -> ()
It can remove the above error but got another error when calling the method:
public typealias ConfigCompletion = (CoreLibResult<ZPConfigsResponse<String>>) -> ()
public func getRemoteConfigValue(for configName: String, userid: String, accessToken: String, callBack: @escaping ConfigCompletion) {
self.remoteConfigService?.getValueForKey(configName, userID: userid, accessToken: accessToken, defaultParams: remoteConfigParams?.getDefaultParams().toString, responseHandler: ConfigCompletion)//Error:Cannot convert value of type 'ZPRemoteConfigManager.ConfigCompletion.Type' (aka '((CoreLibResult<ZPConfigsResponse<String>>) -> ()).Type') to expected argument type 'CorelibResponseHandlerProtocol?'
}
The error is: Cannot convert value of type 'ZPRemoteConfigManager.ConfigCompletion.Type' (aka '((CoreLibResult<ZPConfigsResponse<String>>) -> ()).Type') to expected argument type 'CorelibResponseHandlerProtocol?'
Sorry for complicated code of generic type. Because I don't want to duplicate code, so I try to use generic. Edit: Sorry, my mistake. The right code must be: