This repository has been archived by the owner on Mar 3, 2020. It is now read-only.
make it easier when a strong reference between controller and observe would create a retain loop #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm trying to solve #48
Observing
self
is frequently needed in our project. It will be nice if we don't need to callunobserveAll
prior todealloc
.The reason for the original problem is: A retain loop is created when we set
NSMapTable
's keys with theNSPointerFunctionsStrongMemory
option (whenself
observesself
), but it causes a crash when we setNSMapTable
's keys with theNSPointerFunctionsWeakMemory
option since there is no chance to remove thekeyPath
from the observer as a weak property is set to nil in dealloc.I tried to find a way to set the key option to
assign
, and I foundNSPointerFunctionsOpaqueMemory
in Apple's documentation:I have tested this and I'm sure this is what is needed.
Thanks a lot!