swift 编译器显示预期的声明错误? [英] swift compiler shows Expected declaration error?

查看:62
本文介绍了swift 编译器显示预期的声明错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当这段代码写在AllListViewController中并运行时,编译器显示Expected Declaration错误:

When this code is written in AllListViewController and run, the compiler shows the Expected Declaration error:

for list in lists{
    let item = ChecklistItems()
    item.text = "Item for (list.name))"
    list.items.append(item)
}       

推荐答案

我认为您在类中的代码位置错误,例如 这个问题.

I think you have the code in the wrong place in the class same like this question.

因此将其移动到任何函数或 viewDidLoad 方法中.

so move it to any function or in viewDidLoad method.

希望它会有所帮助.

这篇关于swift 编译器显示预期的声明错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆