我需要帮助解除我的 NSMutableArray 的自定义对象。我需要保留数组,所以我在 .h 中添加了一个属性,并在 .m 文件中的 dealloc 中释放它。当我将对象添加到数组时,我执行以下操作:
myarray = [[NSMutableArray alloc] init];
[myarray addObject:[[mycustomObject alloc]initWithObject:obj1]];
[myarray addObject:[[mycustomObject alloc]initWithObject:obj2]];
现在,我不知道如何释放 mycustomobject。如果我执行以下操作:
[myarray addObject:[[[mycustomObject alloc]initWithObject:obj1] autorelease]];
稍后访问数组时遇到问题。请指教。