How is retain setter implemented with @synthesize?

前端 未结 6 971
逝去的感伤
逝去的感伤 2020-12-10 19:01

I have the following in the header:

@property (nonatomic, retain) UIView *overlay;

And in the implementation:

@synthesize o         


        
6条回答
  •  天涯浪人
    2020-12-10 19:43

    Using the retain attribute specifies that retain should be invoked on the new object, and the previous value is sent a release.

    So in your second code block, the retain count of the object would become 2, since you no longer release it, and the setter is retaining it. This is unlikely to be what you want.

提交回复
热议问题