OGeek|极客世界-中国程序员成长平台

标题: iphone - @property setter 中的泄漏 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:15
标题: iphone - @property setter 中的泄漏

我有一个自定义 UIView,我将它作为 subview 添加到整个应用程序的多个位置。我通过设置一个属性向 View 发送一个 NSMutable 数组,它会显示一个注释图。除了我的应用程序中的一个 View 外,这很好用。我在包含图表的每个 View 的 viewDidLoad 部分中使用此代码。

endNoteDisplay =[[NoteDisplay alloc] initWithFrame:CGRectMake(0,0,320,180)];
endNoteDisplay.tag = 100;
endNoteDisplay.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed"Note_Bkg.png"]];
NSMutableArray *tmpNts = [[NSMutableArray alloc] initWithObjects: @"C", @"E", @"G", @"A",nil];
endNoteDisplay.noteSpread = tmpNts;
[tmpNts release];
[self.view addSubview:endNoteDisplay];
[endNoteDisplay release];

谁能告诉我为什么会产生泄漏?我的 NoteDisplay 中的 noteSpread 属性设置为 nonatomic retain



Best Answer-推荐答案


NoteDisplay中的-dealloc方法是否释放noteSpread属性?

关于iphone - @property setter 中的泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7489283/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4