one alloc, retainCount == 2

前端 未结 5 1753
情话喂你
情话喂你 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:40

    Due to self in the statement its retain count is 2 as property of the chart is declared as retain Remove self from the statement

    change

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

    to

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

提交回复
热议问题