开发者

Line of code causes crash in instruments but not in Xcode

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];
}

This causes a crash when ran in instruments but not in Xcode. I narrowed the problem down, it happens when this line of code is in a loop... NSMutableArray *blocks = 开发者_如何转开发[self getBlocksForX: thePoint.x]; the method returns a NSMutableArray, I store it in blocks each time the loop is executed then at the end of the loop I release it. What would be causing instruments to crash?


since you never alloc, copy, or retain blocks you should not be releasing it.

It may help for errors like this to run the static analyzer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜