更新时间:2023-08-20 09:38:10
你可能会释放一个对象太多次了(例如,调用alloc一次并释放两次)。要找出答案,请查看此问题中的技巧:如何找到malloc的原因double free错误?
You are probably releasing an object too many times (for example, calling alloc once and release twice). To find out where, take a look at the techniques in this question: How to find the cause of a malloc "double free" error?
我个人喜欢 NSZombieEnabled
方法。
另一个提示是,在释放它们之后将变量设置为nil。
Another tip, is to set your variables to nil after you release them.
例如: [bla release]; bla = nil;
这确保您在发布 nil $ c $后不会意外释放它们两次c>什么都不做。
This makes sure you will not accidentally release them twice since releasing nil
does nothing.