• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

코드블럭 에러 질문

18.11.15 12:06 작성 조회수 102

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'

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

답변 1

답변을 작성해보세요.

1

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