You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because this fetch is async, when weakSelf.fetcherCompletion calls, the temporary scope in which fetcherCompletion is assigned has gone. fetcherCompletion become a bad memory.
Are you seeing a demonstrable issue with this code?
My understanding is that the weakSelf takes care of the issue that you're describing. When fetcherCompletion is deallocated along with its containing object, weakSelf will be set to nil and the function call will be a no-op.
It looks like this issue has somehow re-manifested itself. Even with the copy attribute, I'm getting EXC_BAD_ACCESS on this exact line.
EDIT: This can be avoided by using .observe() instead of .enqueue(). It should still be properly fixed, but I hope this suggestion helps anyone desperately searching for a fix like I was.
Activity
paulb777 commentedon Aug 18, 2018
@ToFind1991 Sorry for the delayed response.
Are you seeing a demonstrable issue with this code?
My understanding is that the
weakSelftakes care of the issue that you're describing. When fetcherCompletion is deallocated along with its containing object,weakSelfwill be set to nil and the function call will be a no-op.morganchen12 commentedon Aug 19, 2018
To clarify the object being deallocated here isn't self, it's the
fetcherCompletionclosure. This should becopyand notassign.paulb777 commentedon Aug 19, 2018
This stackoverflow answer seems to indicate that while
copyis recommended for documentation, it's not functionally necessary when built with ARC.morganchen12 commentedon Aug 19, 2018
strongwill do too, butassignis hazardous since it doesn't provide any guarantees for ownership or deallocation.Minimal fix for #1565
Minimal fix for #1565 (#1747)
Minimal fix for #1565 (#1747)
andrewehab commentedon Jul 4, 2019
BlakeBoxberger commentedon Aug 20, 2019
It looks like this issue has somehow re-manifested itself. Even with the
copyattribute, I'm getting EXC_BAD_ACCESS on this exact line.EDIT: This can be avoided by using
.observe()instead of.enqueue(). It should still be properly fixed, but I hope this suggestion helps anyone desperately searching for a fix like I was.