对于添加到glossTerms 的每个对象(除了第一个对象),我都会遇到内存泄漏。泄漏被描述为具有“A +1 保留计数(拥有引用)” - 我搜索了 Internet 并找到了几个线程,其中提到在对象分配中使用“复制”。我试过这个,但我一定没有正确实现它,因为我仍然有内存泄漏。
- (void)createTermData {
NSMutableArray *glossTerms=[[NSMutableArray alloc] init];
[glossTerms addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Approximate",@"term",
@"Test",@"definition",@"Test2",@"example",nil]];
[glossTerms addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Arithmetic Mean",@"term",
@"Test",@"definition",@"Test2",@"example",nil]];
termData=[[NSMutableArray alloc] initWithObjects:
glossTerms,nil];
[glossTerms release];
如果你们中的任何人能够对此有所了解,我将不胜感激。
谢谢