作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在制作一个应用程序,当您按下一个表示紧急的按钮时,会有一个标签显示“紧急”。就在我实现与按钮的用户交互之前,我有一个数组(如下所示),其中一些对象具有 urgent = true
,但有些对象具有 urgent = false
,所以我可以从我的代码开始。
MainTableViewController.swift
中的数组:
var content:[Agenda] = [
Agenda(subject: "Read this article", deadline: "1-2 days", urgent: false),
Agenda(subject: "Respond to this email", deadline: "ASAP", urgent: true),
Agenda(subject: "Add this to diary", deadline: "When at home", urgent: true),
Agenda(subject: "Listen to this song", deadline: "When finished working", urgent: false),
Agenda(subject: "Check out this holiday destination", deadline: "At the weekend", urgent: false),
Agenda(subject: "Download this podcast", deadline: "1-4 days", urgent: false),
Agenda(subject: "Update notes", deadline: "When at home", urgent: true)
]
然后,我有一个名为 Agenda.swift
的类,我在其中声明了 subject
、deadline
和 urgent
.
这是我是否显示“紧急”的代码:
if content[indexPath.row].urgent = true {
cell.urgentLabel.text = "URGENT"
} else {
cell.urgentLabel.text = ""
}
在第一行,我收到以下错误:
Cannot subscript a value of type 'inout [Agenda]' (aka 'inout Array')
最佳答案
这是经典的赋值运算符 (=
) 与等式运算符 (==
) 的混淆。
关于ios - 错误 : Cannot subscript a value of type 'inout [Agenda]' (aka 'inout Array<Agenda>' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35818524/
我是一名优秀的程序员,十分优秀!