如何解决这个弃用问题 "abs is deprecated: Please use the `abs(_)` free function"
How to solve this deprecation issue "abs is deprecated: Please use the `abs(_)` free function"
我有一个 Swift 文件,我在其中导入了 Foundation 和 CoreGraphics,但是在我调用 abs(x)
的地方,其中 x
是 CGFloat
,我得到了这个警告:
abs is deprecated: Please use the abs(_)
free function
我应该使用什么功能?
谢谢
这似乎是 a compiler bug,如果您在 static
上下文中使用 abs(x)
。
根据评论,您可以使用以下方法解决警告:
Swift.abs(x)
我有一个 Swift 文件,我在其中导入了 Foundation 和 CoreGraphics,但是在我调用 abs(x)
的地方,其中 x
是 CGFloat
,我得到了这个警告:
abs is deprecated: Please use the
abs(_)
free function
我应该使用什么功能?
谢谢
这似乎是 a compiler bug,如果您在 static
上下文中使用 abs(x)
。
根据评论,您可以使用以下方法解决警告:
Swift.abs(x)