I have this code:
enum ApiConstans {
static let BaseUrl = "http://myname.pl"
static let iosPath = "/pub/ios/"
static let jsonPath = "json.php"
static var fullPath: String { return BaseUrl + iosPath + jsonPath }
}
struct Connect {
enum Result<T> {
case succes(T)
case error(String)
}
func getJsonFromServer(parameters: String) -> Result<String> {
let fullUrlString = ApiConstans.fullPath + parameters
guard let url = URL(string: fullUrlString) else {
return .error("Error 100: Problem with url")
}
URLSession.shared.dataTask(with: url) { (data, response, error) in
guard error == nil else {
return .error("Error 100: Problem with url")
}
guard let data = data else {
return .error("Error 101: Problem with url")
}
debugPrint("R> \(fullUrlString)")
return .succes(data)
}
}
func checkUsersLogin(login: String?, password: String?) -> Result<String> {
getJsonFromServer(parameters: "?action=LOGOWANIE&login=\(login!)&password=\(password!)")
}
}
I have problem with errors in all return: Type 'Void' has no member 'error' and Type 'Void' has no member 'succes'
could I ask you to repair this code?