gpt4 book ai didi

ios - 无法将类型 'String?.Type' 的值转换为预期参数类型 'String?'

转载 作者:行者123 更新时间:2023-11-30 11:37:20 24 4
gpt4 key购买 nike

我收到标题中声明 var updater 的错误。

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let destination = segue.destination as? ProductViewController,
let index = tableViewProducts.indexPathForSelectedRow?.row {

// Check whether postData array count is greater than index
let updaterId = postData.count > index ? postData[index] : ""

// Initialize "productsList" instance and assign the id value and sent this object to next view controller
var updater = productsList(id: String?, p_name: String?, image: String?, audio: String?)
updater.id = updaterId
destination.updater = updater

这是我的产品列表 VC:

导入基础

class productsList {

let id: String?
let p_name: String?
let image: String?
let audio: String?

init(id: String?, p_name: String?, image: String?, audio: String?) {
self.id = id
self.p_name = p_name
self.image = image
self.audio = audio
}

}

最佳答案

使用这个

var updater = productsList(id: updaterId, p_name: nil, image: nil, audio: nil)

而不是

var updater = productsList(id: String?, p_name: String?, image: String?, audio: String?)

关于ios - 无法将类型 'String?.Type' 的值转换为预期参数类型 'String?',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49605870/

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