I always like to use [weak self]
, to prevent any potential memory leakage.
I was wondering, is 2nd [weak self]
required, in a closure inside another closure? For instance
2 [weak self]
func takePhoto() {
AVCaptureDevice.requestAccess(for: AVMediaType.video) { [weak self] response in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
Or, it is redundant to do so for the above case, and single [weak self]
will be sufficient?
Single [weak self]
func takePhoto() {
AVCaptureDevice.requestAccess(for: AVMediaType.video) { [weak self] response in
DispatchQueue.main.async {
guard let self = self else { return }
May I know, which one is the most accurate approach?