【发布时间】:2017-02-09 09:43:09
【问题描述】:
以下代码:
func getCurrentMillis() -> Int64 {
return Int64(Date().timeIntervalSince1970 * 1000)
}
在 [32 位] iPhone 5 上崩溃并显示消息:
EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe)
我不明白为什么这个计算的结果应该适合Int64,还是我遗漏了什么?
Stacktrace 显示了这一点(TextProcessor.textDidChange() 调用 getCurrentMillis()):
应OOPer的要求,我添加了TextProcessor的相关代码:
var timeOfLastInput: Int64 = 0
...
if getCurrentMillis() - timeOfLastInput > 150 {
textMap.cursorPosition = nil
}
更新: 我已向 Apple 发送错误报告。
【问题讨论】:
-
如果你知道
Int64在32位设备上可用,为什么不显示TextProcessor.textDidChange()的代码。我可以向您保证,您的getCurrentMillis()在 32 位设备上运行良好。问题在于调用方。 -
Int64是在 32 位系统上可用。问题一定出在其他地方。 -
您确定崩溃是在 getCurrentMillis 函数中吗?我无法从堆栈回溯中看到。
-
@Martin R top of stacktrace 没有提到它,但似乎它崩溃了因为它,即当我将
Int64更改为TimeInterval时它工作正常。 -
timeOfLastInput的类型是什么?
标签: ios iphone swift crash 32-bit