最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

找不到类型“字符串"的初始值设定项,它接受类型为“(格式:字符串,参数:UInt32)的参数列表

网站源码admin63浏览0评论
本文介绍了找不到类型“字符串"的初始值设定项,它接受类型为“(格式:字符串,参数:UInt32)的参数列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

I created a playground in Xcode 6.3 (6D570) and input these following code:

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 的新手,感谢您的建议!

Sorry I'm complete new in Swift, thanks for any advices!

附言我正在关注本教程:link

P.S. I'm following this tutorial: link

推荐答案

您只需省略参数:".试试这个:

You just have to omit "arguments:". Try like this:

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

或者干脆

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

这篇关于找不到类型“字符串"的初始值设定项,它接受类型为“(格式:字符串,参数:UInt32)的参数列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

发布评论

评论列表(0)

  1. 暂无评论