Potato
์•ˆ๋…•ํ•˜์„ธ์š”, ๊ฐ์žก๋‹ˆ๋‹ค?๐Ÿฅ” ^___^ ๐Ÿ˜บ github ๋ฐ”๋กœ๊ฐ€๊ธฐ ๐Ÿ‘‰๐Ÿป

Swift/UIKit

[UIKit] init(coder: NSCoder), fetalError

๊ฐ์ž ๐Ÿฅ” 2022. 7. 10. 14:49
๋ฐ˜์‘ํ˜•

๐ŸŸฃ ์˜ˆ์‹œ ์ฝ”๋“œ

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

 

๐ŸŸฃ ์•ž์—์„œ ๋ฐฐ์šด ๋‚ด์šฉ ์ •๋ฆฌ

https://didu-story.tistory.com/288

 

[UIKit] init(frame: ), init(coder: ) ์ด๋‹ˆ์…œ๋ผ์ด์ €

UIKit์„ ์‚ฌ์šฉํ•ด์„œ ์•ฑ์„ ๋งŒ๋“ค ๋•Œ ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ํ•„์ˆ˜์ ์œผ๋กœ ์ ์–ด์•ผ๋งŒ ํ•œ๋‹ค. ๊ณผ์—ฐ ์ด ์ฝ”๋“œ๊ฐ€ ์˜๋ฏธํ•˜๋Š”๊ฒŒ ๋ญ๊ณ  ์™œ ์ ์–ด์•ผํ• ๊นŒ? ๐ŸŸฃ ์˜ˆ์‹œ์ฝ”๋“œ init(frame: CGRect, data: Data) { self.data = data super.init(frame: f..

didu-story.tistory.com

override init(frame: CGRect) // view๋ฅผ ๋งŒ๋“ค ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค.
required init?(coder: NSCoder) // ์Šคํ† ๋ฆฌ ๋ณด๋“œ์— ์ƒ์„ฑ๋  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค.

 

๐ŸŸฃ fetalError

๐ŸŸช ๊ณต์‹๋ฌธ์„œ

https://developer.apple.com/documentation/swift/fatalerror(_:file:line:)

 

Apple Developer Documentation

 

developer.apple.com

์ง€์ •๋œ ๋ฉ”์‹œ์ง€๋ฅผ ๋ฌด์กฐ๊ฑด ์ธ์‡„ํ•˜๊ณ  ์‹คํ–‰์„ ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค. ๋ผ๊ณ  ์ •์˜๋˜์–ด์žˆ๋‹ค. ์˜ค!๊ฐ„๋‹จ์“ฐ

 

๐ŸŸช ์ฝ”๋“œ๋กœ ์‚ดํŽด๋ณด์ž.

String = String(), file: StaticString = #file, line: UInt = #line) -> Never

Never์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. ์ด ์˜๋ฏธ๋Š” ํ˜ธ์ถœ์ด ๋˜๋ฉด ๋” ์ด์ƒ ์•ฑ์ด ์ง„ํ–‰๋˜์ง€ ์•Š๋Š”๋‹ค๋Š” ๋œป์ด๋‹ค. ์ฆ‰ ๊ฐœ๋ฐœ์ž๊ฐ€ ์ธ์ง€ ํ•˜์ง€ ๋ชปํ•˜๋Š” ์ƒํ™ฉ์—์„œ ์˜ˆ์™ธ์ฒ˜๋ฆฌ๋ฅผ ์ด ํ•จ์ˆ˜๋กœ ํ•œ๋‹ค๋ฉด, ์‹คํ–‰ ๋˜์—ˆ์„ ๋•Œ ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ๋ถ€๋ถ„์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋Ÿผ ์ด์ œ ์˜ˆ์‹œ์ฝ”๋“œ๋ฅผ ํ•ด์„ํ•ด๋ณด๋ฉด, fetalError๋ฅผ init(coder: )์—์„œ ์‚ฌ์šฉํ•˜๋ฉด ์Šคํ† ๋ฆฌ๋ณด๋“œ๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ์ œ๋Œ€๋กœ ์ด๋ฃจ์–ด์ง€์ง€ ์•Š๋Š”๋‹ค๋ฉด, ๋ฐ”๋กœ ์•ฑ ์‹คํ–‰์„ ์ค‘์ง€์‹œํ‚ค๊ณ  ์–ด๋””์„œ ์—๋Ÿฌ๊ฐ€ ๋‚ซ๋Š”์ง€ ์ฐพ์„ ์ˆ˜ ์žˆ๊ฒŒ๋œ๋‹ค…!

 


 

๐Ÿ“– Reference

https://dev200ok.blogspot.com/2020/06/swift-fatalerror.html

 

[swift] fatalerror์— ๋Œ€ํ•ด ์ฒ˜์Œ ์•Œ์•„๋ณด์•˜๋‹ค

Devlog ์™€ TIL ์ž…๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ์„ ํ•˜๋ฉด์„œ ์•Œ๊ฒŒ๋œ ๋‚ด์šฉ์„ ๋‹ค๋ฃจ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

dev200ok.blogspot.com

 

๋ฐ˜์‘ํ˜•