I'm learning about weak vs strong and still don't fully grasp it. How can I declare weak response in the following function so I don't have a retained cycle?
AF.request(url, method: .get).validate().responseData { [weak self] response in
guard let data = response.data else {
completionHandler(.failure(.apiFailed))
return
}
do {
let decodedData = try JSONDecoder().decode(T.self, from: data)
DispatchQueue.main.async {
completionHandler(.success(decodedData))
}
} catch {
completionHandler(.failure(.corruptedData))
return
}
}
Right now I have an xcode warning saying:
Variable 'self' was written to, but never read
How can I read it using weak?