我正在尝试使用swift 5和Xcode 10.3安装SpinWheelControl Cocoapod:https://github.com/joshdhenry/SpinWheelControl。安装很好,但是当我运行时,编译器给出了一个错误:
"The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions"
在这一行代码中:

let nearestWedge: Int = Int(round(((currentRadians + (radiansPerWedge / 2)) + snappingPositionRadians) / radiansPerWedge))

如果可以的话,这种轮子对我真的很有用。
您是否能够使该框架与Swift 5一起运行,或者重构该行代码以便其运行?

谢谢!

最佳答案

尝试将单个long表达式分解为小表达式。

例如 :

let exp1 = currentRadians + (radiansPerWedge / 2)
let exp2 = (exp1 + snappingPositionRadians) / radiansPerWedge
let nearestWedge = Int(round(exp2))

10-08 12:11