BOOL continueLoop;
CGPoint thePoint;
while(continueLoop != NO)
{
continueLoop = NO;
thePoint = [self generateRandomLocation];
NSMutableArray *blocks = [self getBlocksForX:thePoint.x];
for(BlueBlock *block in blocks)
{
if(block.getBlockLocationY == thePoint.y)
{
continueLoop = YES;
}
}
[blocks release];
}
在仪器中运行而不在Xcode中运行时会导致崩溃。我缩小了范围,当这行代码处于循环中时会发生... NSMutableArray * blocks = [self getBlocksForX:thePoint.x];该方法返回一个NSMutableArray,每次执行循环时,我都将其存储在块中,然后在循环结束时释放它。什么会导致仪器崩溃?
最佳答案
由于您从不alloc
,copy
或retain
块,因此不应释放它。
运行静态分析器可能有助于解决此类错误。
关于objective-c - 代码行会导致仪器崩溃,但不会导致Xcode崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1787274/