使用init从NSDictionary检索信息

时间:2018-10-03 17:22:24

标签: swift nsdictionary init

我正在尝试使用init从NSDictionary检索信息。我在super.init()行上收到错误消息“必须调用超类'UIViewController的指定初始化程序”

这是我的代码:

init(dictionary: NSDictionary) {
    let title = dictionary["title"] as? String
    let poster = dictionary["poster_path"] as! String
    let baseUrl = "http://image.tmdb.org/t/p/w500"
    let imageUrl = URL(string: baseUrl + poster)
    detailsTitle.text = title
    detailsImage.setImageWith(imageUrl!)
    super.init()
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")

}

}

我尝试了以下方法:

super.init(coder: )
super.int(coder: aDecoder)
super.init(dictionary: NSDictionary)
super.init(coder: NSCoder)
super.init(coder: aDecoder: NSCoder)
super.init(coder: dictionary: NSDictionary)

0 个答案:

没有答案
相关问题