简体   繁体   中英

Does adding a KVO observer to self cause a memory leak?

In a nsobject you have a property "keyPath" you want to observe itself and you use

[self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:nil];

Does the above line cause a retain cycle?

I present this question because I wanted to know if it was a viable alternative to rewriting a bunch of setter functions.

From the docs :

Neither the receiver, nor anObserver, are retained.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM