Objective-C Memory Question

后端 未结 6 630
感动是毒
感动是毒 2021-01-23 07:45

Is it a leak if I have a view controller and allocate the view like this:

self.view = [[UIView alloc] initWithFrame:frame];

Do I need to do som

6条回答
  •  礼貌的吻别
    2021-01-23 08:25

    In objective c, we need to maintain retain count of an object as zero after its purpose. So here in your code you must release the object. Then it will not create any leakage problems.

    The second one you specified is the right way. It is not a compulsory , it is the way to express how effective our code is.

提交回复
热议问题