강의

멘토링

커뮤니티

Inflearn Community Q&A

alstlr31288931's profile image
alstlr31288931

asked

Yagom's iOS Programming

Working with Examples - Writing Model Code

코드블럭 에러 질문

Written on

·

207

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'

위와 같은 에러가 발생합니다.!!

iosswift

Answer 1

1

alstlr31288931님의 프로필 이미지
alstlr31288931
Questioner

해결 했습니다 ~ import UIKit 을 안해줬었군요 ㅎㅎ

alstlr31288931's profile image
alstlr31288931

asked

Ask a question