What is the strong property attribute

前端 未结 3 2144
终归单人心
终归单人心 2020-12-12 20:27

I am using the Xcode beta for developers, and am noticing some subtle differences. Among them is a new attribute for declared properties.

@property(strong)IB         


        
3条回答
  •  时光说笑
    2020-12-12 20:46

    A strong reference is a reference to an object that stops it from being deallocated. In other words it creates a owner relationship. Whereas previously you would do this:

    **// Non-ARC Compliant Declaration
    @property(retain) NSObject *obj;**
    

    Under ARC we do the following to ensure a class instance takes an ownership interest a referenced object (i.e. so it cannot be deallocated until the owner is).

    **// ARC Compliant Declaration
    @property(strong) NSObject *obj;**
    

提交回复
热议问题