use*_*282 3 xcode breakpoints ios cadisplaylink swift
每次玩游戏时都不会发生这种情况,也许每5或10次播放一次.当游戏结束时,我从运行循环中移除我的CADisplayLink(我用它来设置游戏区域的动画,有点像Flappy Bird中的管道).然而,在少数情况下,它崩溃了.该行旁边有:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x10)
Run Code Online (Sandbox Code Playgroud)
这是代码:
func endGame(r : String) {
UIView.animateWithDuration(0.4, delay: 0.2, options: .CurveLinear, animations: {
self.scoreLabel.alpha = 0
}, completion: {
(finished: Bool) in
self.scoreLabel.removeFromSuperview()
});
self.view.userInteractionEnabled = false
reason = r
println("Game Over!!!")
//Crashes on this line
blockUpdateDisplayLink.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSRunLoopCommonModes)
shiftDisplayLink.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSRunLoopCommonModes)
scoreTimer.invalidate()
UIView.animateWithDuration(0.0001, delay: 0.7, options: .CurveLinear, animations: {
}, completion: {
(finished: Bool) in
self.performSegueWithIdentifier("Game Over", sender: self)
});
}
Run Code Online (Sandbox Code Playgroud)
如果我注释掉第一个CADisplayLink部分,那么无论如何它都会在第二个部分崩溃.
这是堆栈跟踪:

它与上面的"线程1"错误相同.
到底是怎么回事??
| 归档时间: |
|
| 查看次数: |
1148 次 |
| 最近记录: |