one alloc, retainCount == 2

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

    There are 3 possible problems I see:

    1. When you synthesized the chart property, it was synthesized with a retain attribute
    2. You have called retain in a self-implemented getter method
    3. Whoever wrote the initializer method for BNPieChart or its superclass's designated initializer had a retain in the initializer.

    Have you seen the code for BNPieChart and its non-Cocoa superclasses? If you can, try to post the initializer code.

提交回复
热议问题