我在 Xcode 6.3 (6D570) 中创建了一个 Playground 并输入以下代码:
import UIKit
var randum_num = arc4random_uniform(13) + 1
String(format: "card%i", arguments: randum_num)
我得到了这个错误:
cannot find an initializer for type 'String' that accepts an argument list of type '(format: String, argument: UInt32
抱歉,我是 Swift 的新手,感谢您的任何建议!
附言我正在学习本教程:link
最佳答案
你只需要省略“arguments:”。像这样尝试:
let randum_num = arc4random_uniform(13) + 1
String(format: "card%i", randum_num)
或者只是
String(format: "card%i", arc4random_uniform(13) + 1)
关于xcode - 找不到类型为 'String' 的初始值设定项,它接受类型为“(格式 : String, 参数:UInt32,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29724932/