How to get notified when a zeroing weak reference

2020-02-24 12:56发布

Is there a mechanism which would allow an object to know that a zeroing weak reference turned nil?

For example I have a property

@property (nonatomic, weak) MyClass *theObject;

when theObject deallocates and the property turns nil I want to get notified. But how? Does the zeroing weak reference system use the setter to set the property to nil when the object goes away?

7条回答
淡お忘
2楼-- · 2020-02-24 13:31

If you care when an object goes away, you shouldn't be using a weak reference. What are you trying to do?

查看更多
登录 后发表回答