A method sampleMethod()
is called from a closure with weak reference of self (self?.sampleMethod()
), within the same class. What will be the context of self which is now used in sampleMethod()
?
Will it be a weak self or a strong one?
Asked
Active
Viewed 50 times
1 Answers
1
Since method sampleMethod()
invoked successfully, it will use strong self
reference inside it body by default.
You may think about this line
self?.sampleMethod()
like this
if let s = self {
s.dynamicType.sampleMethod(s)()
}
where you just passing strong reference to instance to related class method

Yury
- 6,044
- 3
- 19
- 41