Does “self.propery = [[SomeClass alloc] init];” leak memory?

前端 未结 4 1889
伪装坚强ぢ
伪装坚强ぢ 2021-01-26 18:07

Is it safe in Objective-C to write

self.propery = [[SomeClass alloc] init];

instead of

SomeClass *tmp = [[SomeClass alloc] init         


        
4条回答
  •  误落风尘
    2021-01-26 18:58

    It depends on how the property is defined. If it's defined with retain or copy then, yes, your first example will leak.

提交回复
热议问题