gpt4 book ai didi

iphone - 一次分配,retainCount == 2

转载 作者:行者123 更新时间:2023-12-03 19:31:12 25 4
gpt4 key购买 nike

我有以下代码:

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

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

终端显示:

[Session started at 2011-03-28 11:09:46 +0200.]
2011-03-28 11:09:51.008 Finance[35111:207] 0

2011-03-28 11:09:51.010 Finance[35111:207] 2

据我所知,retainCount 应该等于 1,而不是 2。

最佳答案

您将图表属性定义为保留或复制,因此:

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

+1 在分配时保留 ([BNPieChart alloc])
+1 赋值时保留 (self.chart = )

关于iphone - 一次分配,retainCount == 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5456848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com