嗨,我现在正在学习Swift,我的操作系统是Windows,使用的是Visual。我能用什么来代替现在不起作用的arc4random_uniform呢?我试着去import Foundation库,但仍然没有工作。谢谢。
*Int.random ()也不工作。
发布于 2022-05-01 17:57:58
相当于arc4random_uniform的Swift是Int.random(in:)。例如,考虑:
print("hello, world")
let value = Int.random(in: 0..<100)
print(value)此操作在Windows上运行,没有任何问题:
C:\...\>swiftc --version
compnerd.org Swift version 5.6.1 (swift-5.6.1-RELEASE)
Target: x86_64-unknown-windows-msvc
C:\...\>set SWIFTFLAGS=-sdk %SDKROOT% -I %SDKROOT%\usr\lib\swift -L %SDKROOT%\usr\lib\swift\windows
C:\...\>swiftc test.swift -emit-executable %SWIFTFLAGS% -o test.exe
Creating library test.lib and object test.exp
C:\...\>test
hello, world
42如果这不适用于您,我建议您检查您的Swift版本。它与安装在这里上的5.6.1安装在Windows 10上的这些指示一起工作。
https://stackoverflow.com/questions/72069911
复制相似问题