【发布时间】:2017-07-31 19:02:54
【问题描述】:
仪器显示这些代码行导致内存泄漏,我做错了什么?
required init(data: JSON) {
self.type = data["type"].stringValue
self.name = data["name"].stringValue
self.numberOfRestaraunts = data["length"].intValue
self.isFavourited = data["isFavourited"].boolValue
self.image = URL(string: data["img"].stringValue)! //<- this
self.id = data["id"].stringValue
self.headerImage = URL(string: data["header"].stringValue)! //<- this
if data["colorSchema"].stringValue == "Dark" {
self.colorTheme = .dark
} else {
self.colorTheme = .light
}
self.color = data["color"].stringValue
self.metaScore = data["metaScore"].intValue
self.typeMetaScore = data["typeMetaScore"].int ?? 0
}
它实际上表明,泄漏是NSURL 类。
编辑:截图:
【问题讨论】:
-
仪器显示什么样的泄漏?
-
@Eendje 添加了截图
标签: ios swift memory-leaks instruments