Reputation: 5172
I'd like to ask you how can I rewrite this piece of objective-c code to swift:
__weak typeof(self) this = self;
Thank you
Upvotes: 0
Views: 109
Reputation: 4854
You should use Capture list in your closure. You can choose between using [weak self] or [unowned self]. The difference is that in unowned self you must be 100% sure the object is never nil. Example:
var myClosure = {
[unowned self] in
print(self.description)
}
Upvotes: 1