有什么重要的东西我必须用吗?在我的macOS应用程序中,我正在尝试:
let hello = "Hello"
let emptyRange = hello.firstRange(of: "")这是迅速发展建议0357的一个例子,根据:swift.org 5.7发行说明,该示例包含在Frame5.7中。
我已经确认我使用的是快速5.7,通过运行:
xcrun swift -version在代码中
#if swift(>=5.7)
print("on swift>=5.7")
#endif当我试图编译上面的emptyRange代码时,我遇到的错误是:
Value of type 'String' has no member 'firstRange'从这个例子看来,它应该是有效的--任何关于我所缺少的东西的提示都会被感激。
发布于 2022-09-14 01:08:33
在Xcode iOS项目中,您的代码对我很好;例如:
let result = "hello".firstRange(of: "")它按预期编译和运行。问题似乎是,这个方法还没有应用到您的macOS中。如果您查看标题,您将看到:
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)我推断您没有运行macOS 13。
https://stackoverflow.com/questions/73710302
复制相似问题