작성
·
198
0
extension Question { static var all: [Question] = {
guard let dataAsset: NSDataAsset = NSDataAsset(name: "Questions") else {
return []
}
let jsonDecoder: JSONDecoder = JSONDecoder()
do {
return try jsonDecoder.decode([Question].self, from: dataAsset.data)
} catch {
return []
}
}()
}
위 코드에서
Initializer for conditional binding must have Optional type, not '<<error type>>'Use of undeclared type 'NSDataAsset'
위와 같은 에러가 발생합니다.!!