32 lines
746 B
Plaintext
32 lines
746 B
Plaintext
Classes should only hold ``++weak++`` references to delegate fields with ``++class++`` type. Otherwise, the owning class will have a ``++strong++`` reference to its delegate, and vice versa, and the OS won't be able to deallocate either of them..
|
|
|
|
|
|
Note that this only applies to non-computed delegate fields in classes, and not to fields in ``++struct++``s and ``++enum++``s.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
class MyClass {
|
|
var delegate: ConventionDelegate? // Noncompliant
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
class MyClass {
|
|
weak var delegate: ConventionDelegate?
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|