does addSubview increment retain count?

前端 未结 3 1009
情歌与酒
情歌与酒 2020-12-18 06:30

I\'ve tested it and it looks like it does. So my question is, does it ALWAYS increment the retain count.

So everytime I do something like this:

UIVie         


        
3条回答
  •  渐次进展
    2020-12-18 06:46

    Do not use -retainCount.

    The absolute retain count of an object is meaningless.

    You should call release exactly same number of times that you caused the object to be retained. No less (unless you like leaks) and, certainly, no more (unless you like crashes).

    See the Memory Management Guidelines for full details.

    If you +new/+alloc/-retain/-copy (NARC) an object, you need to balance the retain with a release (or autoerelease). End of story. The absolute retain count, especially the absolute retain count of an instance of a class that is subclassed from a framework class and/or passed into framework code, is an implementation detail and quite likely to not be what you think it should be.

提交回复
热议问题