one alloc, retainCount == 2

前端 未结 5 1756
情话喂你
情话喂你 2020-12-19 20:12

I have a following code:

NSLog(@\"%d\", [chart retainCount]);

self.chart = [[BNPieChart alloc] initWithFrame:self.view.frame];
NSLog(@\"%d\", [chart retainC         


        
5条回答
  •  清歌不尽
    2020-12-19 20:29

    You chart property defined as retain or copy, so:

    self.chart = [[BNPieChart alloc] initWithFrame:self.view.frame];
    

    +1 retain at alloc ([BNPieChart alloc])
    +1 retain at assignment (self.chart = )

提交回复
热议问题