Objective-C - Should we use strong, weak or assign for Class-type?

前端 未结 1 1477
醉话见心
醉话见心 2021-01-16 11:28

I know that we should use strong/weak for Obj-C objects properties/ivars. But I found that I can use strong for Class-type properties/ivars.

@property (nonat         


        
1条回答
  •  抹茶落季
    2021-01-16 12:07

    According to The Secret Life of Classes

    A class object is not an instance, but it is definitely a full-fledged object

    You don’t have to do anything to create a class object. One class object for every class your program defines is created for you automatically as the program starts up.

    Of course, you can use strong for an object.

    When is a class object released? - Simple answer is when program is finished.

    There is no reason to care about Retain Count of an object which will be never released while program is running. It means that doesn't matter if you use strong/weak/assign, this object is still not be destroyed until program is finished.

    So you can use whatever you want, they will give same result.

    0 讨论(0)
提交回复
热议问题