Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 找不到类型为';字符串';接受类型为';(格式:字符串,参数:UInt32)_Xcode_Swift_Syntax Error - Fatal编程技术网

Xcode 找不到类型为';字符串';接受类型为';(格式:字符串,参数:UInt32)

Xcode 找不到类型为';字符串';接受类型为';(格式:字符串,参数:UInt32),xcode,swift,syntax-error,Xcode,Swift,Syntax Error,我在Xcode 6.3(6D570)中创建了一个游乐场,并输入以下代码: 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: Stri

我在Xcode 6.3(6D570)中创建了一个游乐场,并输入以下代码:

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,谢谢你的建议

另外,我正在学习本教程:

您只需省略“参数:”。尝试如下:

let randum_num = arc4random_uniform(13) + 1
String(format: "card%i",  randum_num)
或者干脆

String(format: "card%i",  arc4random_uniform(13) + 1)