๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Swift17 - assert/guard assert(_:_:file:line:) func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line) Use this function for internal sanity checks that are active during testing but do not impact performance of shipping code. assert ํ•จ์ˆ˜ assert(_:_:file:line:) ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. assert ํ•จ์ˆ˜๋Š” ๋””๋ฒ„๊น… ๋ชจ๋“œ์—์„œ๋งŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค. ๋ฐฐํฌํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ๋Š” ์ œ์™ธ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ์ƒํ–ˆ๋˜ ์กฐ๊ฑด์˜ ๊ฒ€.. 2021. 2. 10.
Swift16 - ํƒ€์ž…์บ์ŠคํŒ… Type Casting Type casting is a way to check the type of an instance, or to treat that instance as a different superclass or subclass from somewhere else in its own class hierarchy. ํƒ€์ž…์บ์ŠคํŒ…? - ์ธ์Šคํ„ด์Šค์˜ ํƒ€์ž…์„ ํ™•์ธ ํ•˜๋Š” ์šฉ๋„ - ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ๋ถ€๋ชจ ํด๋ž˜์Šค์˜ ํƒ€์ž…์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธ ํ•˜๋Š” ์šฉ๋„ - ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์ž์‹ ํด๋ž˜์Šค์˜ ํƒ€์ž…์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธ ํ•˜๋Š” ์šฉ๋„ - is, as๋ฅผ ์‚ฌ์šฉ * ์Šค์œ„ํ”„ํŠธ์˜ ํ˜•๋ณ€ํ™˜ != ํƒ€์ž…์บ์ŠคํŒ… ex) let intVal: Int = 7 let doubleVal : Double = Double(intVal) >.. 2021. 2. 10.
Swift15 - Nil-Coalescing Operator Nil-Coalescing Operator The nil-coalescing operator (a ?? b) unwraps an optional a if it contains a value, or returns a default value b if a is nil. The expression a is always of an optional type. The expression b must match the type that is stored inside a. nil ๋ณ‘ํ•ฉ ์—ฐ์‚ฐ์ž๋ž€ - Optional ?? Value - ์˜ต์…”๋„ ๊ฐ’์ด nil์ด ์•„๋‹ˆ๋ฉด ํ•ด๋‹น ๊ฐ’ ๋ฐ˜ํ™˜, ์˜ต์…”๋„ ๊ฐ’์ด nil์ด๋ฉด ์˜ค๋ฅธ์ชฝ ๊ฐ’ ๋ฐ˜ํ™˜ var optionalVal1: String? = nil var optionalVal2: String? .. 2021. 2. 3.
Swift14 - Optional Chaining Optional Chaining Optional chaining is a process for querying and calling properties, methods, and subscripts on an optional that might currently be nil. If the optional contains a value, the property, method, or subscript call succeeds; if the optional is nil, the property, method, or subscript call returns nil. Multiple queries can be chained together, and the entire chain fails gracefully if .. 2021. 2. 3.
Swift13 - Initialization & Deinitialization Initialization Initialization is the process of preparing an instance of a class, structure, or enumeration for use. This process involves setting an initial value for each stored property on that instance and performing any other setup or initialization that is required before the new instance is ready for use. Setting Initial Values for Stored Properties Classes and structures must set all of .. 2021. 2. 2.
Swift12 - ์ƒ์† Inheritance A class can inherit methods, properties, and other characteristics from another class. When one class inherits from another, the inheriting class is known as a subclass, and the class it inherits from is known as its superclass. ์Šค์œ„ํ”„ํŠธ ์ƒ์† - ํด๋ž˜์Šค, ํ”„๋กœํ† ์ฝœ์€ ์ƒ์†์ด ๊ฐ€๋Šฅํ•˜์ง€๋งŒ ์—ด๊ฑฐํ˜•, ๊ตฌ์กฐ์ฒด๋Š” ์ƒ์†์ด ๋ถˆ๊ฐ€๋Šฅ - ์Šค์œ„ํ”„ํŠธ์˜ ํด๋ž˜์Šค๋Š” ๋‹จ์ผ์ƒ์†์œผ๋กœ, ๋‹ค์ค‘์ƒ์†์„ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. - final ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์žฌ์ •์˜(override)๋ฅผ ๋ฐฉ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. - static ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด ํƒ€์ž… ๋ฉ”์„œ๋“œ๋ฅผ.. 2021. 2. 2.