-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We also link to this documentation from the property setters themselves. This is a common point of confusion, see: - #585 - #606 - https://matrix.to/#/!SrJvHgAPHenBakQHSz:matrix.org/$OsgLE1-VtAZ5f383z_UoEpDyS7xDUk67xveA_zWvyZA?via=matrix.org
- Loading branch information
Showing
4 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Weak properties | ||
|
||
Delegates in Cocoa are often stored as [`rc::Weak`] properties, to avoid reference cycles when the delegate also wants to store the object it is the delegate of. | ||
|
||
This can be a bit confusing sometimes if you create a delegate, set it on an object, and then expect your delegate methods to be called later on (which they in reality won't since the delegate will have been deallocated). | ||
|
||
In practice, you will have to store your delegate objects somewhere else, for example in your top-level application delegate. | ||
|
||
See Apple's [documentation on weak references][mem-weak] for a few more details. | ||
|
||
[`rc::Weak`]: crate::rc::Weak | ||
[mem-weak]: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html#//apple_ref/doc/uid/TP40004447-1000810 |