I created a playground in Xcode 6.3 (6D570) and input these following code:
我在Xcode 6.3(6D570)中创建了一个游乐场并输入以下代码:
import UIKit
var randum_num = arc4random_uniform(13) + 1
String(format: "card%i", arguments: randum_num)
And I got this error:
我收到了这个错误:
cannot find an initializer for type 'String' that accepts an argument list of type '(format: String, argument: UInt32
Sorry I'm complete new in Swift, thanks for any advices!
对不起,我是Swift的新手,感谢任何建议!
P.S. I'm following this tutorial: link
附:我正在学习本教程:链接
1 个解决方案
#1
13
You just have to omit "arguments:". Try like this:
你只需要省略“参数:”。试试这样:
let randum_num = arc4random_uniform(13) + 1
String(format: "card%i", randum_num)
or simply
或简单地说
String(format: "card%i", arc4random_uniform(13) + 1)
#1
13
You just have to omit "arguments:". Try like this:
你只需要省略“参数:”。试试这样:
let randum_num = arc4random_uniform(13) + 1
String(format: "card%i", randum_num)
or simply
或简单地说
String(format: "card%i", arc4random_uniform(13) + 1)