简体   繁体   中英

iOS reference relationship between subview and superview

In the iOS documentation, it seems that subview has a strong reference to superview:

@property(nonatomic, readonly) UIView *superview

The default for property is strong . As we all know, superview has a strong reference to subview, so is there a reference cycle between superview and subview?

Yes, there is a reference cycle. To get rid of a view, you have to call [theView removeFromSuperview] which breaks the cycle.

No, the default is assign . That's roughly the same as unsafe-unretained.

There won't be any reference cycle. When superview is deleted, it will delete all its children first before deleting itself. If you just want to delete current view, you can do it. Superview don't object.

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