gpt4 book ai didi

ios - 错误 : Cannot subscript a value of type 'inout [Agenda]' (aka 'inout Array' )

转载 作者:可可西里 更新时间:2023-10-31 23:56:26 25 4
gpt4 key购买 nike

我正在制作一个应用程序,当您按下一个表示紧急的按钮时,会有一个标签显示“紧急”。就在我实现与按钮的用户交互之前,我有一个数组(如下所示),其中一些对象具有 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 的类,我在其中声明了 subjectdeadlineurgent.

这是我是否显示“紧急”的代码:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com