简体   繁体   English

iOS上的SceneKit:使用Swift编写的计时功能崩溃

[英]SceneKit on iOS: Crash with timing function written in Swift

I'm trying to write a custom timingFunction for a SCNAction in a Swift project. 我正在尝试为Swift项目中的SCNAction编写自定义timingFunction SCNAction It is supposed to have the signature (Float) -> Float and return a value between 0.0 and 1.0. 它应该具有签名(Float) -> Float并返回介于0.0和1.0之间的值。 But whatever value I return, the app will always crash with a EXC_BAD_ACCESS saying "error: memory read failed for 0xd0000000" when the action is run. 但是无论我返回什么值,运行操作时,应用程序始终会崩溃,并显示EXC_BAD_ACCESS错误:“错误:0xd0000000的内存读取失败”。

This is the most basic function I could come up with to demonstrate the problem: 这是我用来说明问题的最基本功能:

var action = SCNAction.moveByX(0, y: 100, z: 0, duration: 1)
action.timingFunction = { time in
    return time
}
someSCNNode.runAction(action)

The same code in Objective-C works just fine. Objective-C中的相同代码也可以正常工作。

I've tested this with iOS 8.0.1, 8.0.2 and 8.1b2 with several devices and simulators. 我已经在多个设备和模拟器的iOS 8.0.1、8.0.2和8.1b2上对此进行了测试。 Am I doing something wrong here or is this a Swift bug? 我是在这里做错什么,还是Swift的错误?

Looks like a bug — it works on the shipping OS X Yosemite release. 看起来像个错误-在OS X Yosemite发行版中有效。 File a report with Apple and they'll probably notify you when the fix makes it into iOS. 向Apple 提交报告 ,当此修复程序将其纳入iOS时,他们可能会通知您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM