我想在迅速循环,但我有问题
我尝试了循环,但是为什么只显示检查的循环?和测试,tick不会出现
override func viewDidLoad()
{
super.viewDidLoad()
doSomething()
label()
}
@IBOutlet weak var subTitle: UILabel!
let text = ["test", "check", "checked"]
func label(){
for name in text {
print(subTitle.text = (name))
}
}
I tried loop but why does it only show checked ones? and test, the tick does not appear
override func viewDidLoad()
{
super.viewDidLoad()
doSomething()
label()
}
@IBOutlet weak var subTitle: UILabel!
let text = ["test", "check", "checked"]
func label(){
for name in text {
print(subTitle.text = (name))
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码和问题都没有意义。
您的
label()
函数中的打印语句甚至不应编译:该怎么办?打印语句将将输出记录到调试控制台。但是,express
subtitle.text =(name)
看起来不像合法的swift。您是否试图判断标签字段的内容是否包含数组中的一个字符串?如果是这样,您需要使用==
(比较)不是=
(分配。)尝试:
Neither your code nor your question make much sense.
The print statement in your
label()
function should not even compile:What is that supposed to do? The print statement will log output to the debug console. however, the expression
subTitle.text = (name)
does not look like legal swift. Are you trying to tell if the contents of your label field contains one of the strings in your array? If so, you need to use==
(comparison) not=
(assignment.)Try: