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

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

问题描述

当此代码用 AllListViewController 编写并运行时,编译器会显示预期声明错误:

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天全站免登陆