我有这个简单的Swift3代码,如果抱怨[Channel]
其中:如何修复无法转换类型的值...预期参数类型INOUT _
var channels = [Channel]()
....
for (_, json) in json["entities"] {
let channel = Channel(json: json)
self.channels += [channel]
^Cannot convert value of type [Channel] to expected argument type inout _
}
这是通道类:
class Channel {
var uuid: String
var title: String?
var isPublic: Bool
init(uuid: String) {
self.uuid = uuid
self.title = ""
self.isPublic = false
}
init?(json: JSON) {
self.uuid = json["uuid"].stringValue
self.title = json["title"].stringValue
self.isPublic = json["public"].boolValue
}
}
有些帖子指出该消息可能与闭包有关,但我在这里看不到闭包。
如何修复这个错误在一个简单的for循环?
嘛,有什么错误? ... – Alexander
用完整准确的错误信息更新您的问题并指出导致错误的行。 – rmaddy