Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 我的应用程序在CGRectIntersectsRect上崩溃_Objective C_Ios_Cocoa Touch_Crash - Fatal编程技术网

Objective c 我的应用程序在CGRectIntersectsRect上崩溃

Objective c 我的应用程序在CGRectIntersectsRect上崩溃,objective-c,ios,cocoa-touch,crash,Objective C,Ios,Cocoa Touch,Crash,我的应用程序在CGRectIntersectsRect上崩溃,我不知道该怎么办。 这是我的密码: if(CGRectIntersectsRect(player.frame,enemy.frame)) { loseViewController *controller = [[loseViewController alloc] initWithNibName:@"loseView" bundle:nil];

我的应用程序在CGRectIntersectsRect上崩溃,我不知道该怎么办。
这是我的密码:

if(CGRectIntersectsRect(player.frame,enemy.frame)) 
{
    loseViewController *controller = [[loseViewController alloc] initWithNibName:@"loseView" bundle:nil];                                        

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:controller animated:NO];   
    [controller release];
}

扩展@Vince的评论(我不确定为什么它不是答案!)

如果你这样做,它会在哪里崩溃

CGRect playerRect = player.frame;
CGRect enemyRect = enemy.frame;
if (CGRectIntersectsRect(playerRect, enemyRect)) {
而不是

if(CGRectIntersectsRect(player.frame,enemy.frame)) {

这应该会告诉你哪个(或两者)对象被释放。

player
敌人
可能被释放,你能检查一下吗?正如@Vince所说,可能其中一个对象被释放了。尝试启用僵尸,这将有助于确定这一点。有关在Xcode 4中启用僵尸的详细信息,请参阅。除非
CGRectIntersectsRect
中有错误。好的,可能性很小,但值得先检查僵尸或您的代码。我个人更喜欢僵尸方法,因为我认为(通常)它应该在开发过程中始终处于启用状态。而且在
objc\u exception\u throw上有一个断点
!然后在第一行上放置一个断点并逐步执行-这应该会告诉您是
玩家
还是
敌人
。如果你看到CGRectIntersectsRect,那么告诉我们Rect是。我们应该设置断点,我的代码看起来正确吗?注释告诉我你还没有尝试我的问题。把断点放在我原始答案的第一行。