I have a question regarding the need of using [weak self] in closures and HTTP requests.
As example we have a HTTP request who triggers a closure on completion:
func saveBla() {
blaManager.saveBla(bla) { error in
self.pay5euro()
}
}
My questions is: Do I need to use a weak reference here or not? First of all I don't want to lose the response from the api call, after moving to an other page. Beside of that I don't want to create a retain cycle with a memory leak?
func saveBla() {
blaManager.saveBla(bla) { [weak self] error in
guard let strongSelf = self else { return }
strongSelf.pay5euro()
}
}
Is it really needed to use a [weak self] in this situation?