unsafe-unretained

Is there way to check a `unowned` (actually `unowned(safe)`) reference has been deinited?

好久不见. 提交于 2019-12-06 00:34:22
问题 Is there any way to check an unowned(safe) Swift reference for "availability"? So, I am looking for a hypothetical function like isReferenceAccessible in this example: func someMethod() { someAsyncOperation(parameters) { [unowned(safe) self] in guard isReferenceAccessible(self) else { return } self.someAnotherMethod() } } Disclaimer: This question not about weak references! I am aware of how strong , unowned and weak references work. And I don't want to use weak references (because it can be

Is there way to check a `unowned` (actually `unowned(safe)`) reference has been deinited?

孤街浪徒 提交于 2019-12-04 06:48:23
Is there any way to check an unowned(safe) Swift reference for "availability"? So, I am looking for a hypothetical function like isReferenceAccessible in this example: func someMethod() { someAsyncOperation(parameters) { [unowned(safe) self] in guard isReferenceAccessible(self) else { return } self.someAnotherMethod() } } Disclaimer: This question not about weak references! I am aware of how strong , unowned and weak references work. And I don't want to use weak references (because it can be slow, and mutable). I know that unowned(safe) references still be allocated even if it is already