
Swift-Collections ํจํค์ง(Commonly used data structures for Swift) ์ ์๋ deque ๋ผ๋ ์๋ฃ๊ตฌ์กฐ๋ฅผ ์ดํด๋ณด๊ฒ ์ต๋๋ค. deque๋ ํ์ด์ฌ์์ ์ค๋์ ๋ถํฐ ๋ง์ด ๋ด์๋ ์น๊ตฌ๋ผ.. ํ์ด์ฌ ๋ฌธ์๋ Swift ๋ฌธ์๋ฅผ ํจ๊ป ์ดํด๋ณผ๊ฒ์! [1] Deque ๋ ? - deque๋ "double-ended-queue" ์ ์ค์๋ง์ ๋๋ค. ๋ฐ์์ "deck" ์ด๋ผ๊ณ ํฉ๋๋ค. - ์์ชฝ ๋์์ ์ฝ์ , ์ญ์ ๊ฐ ๊ฐ๋ฅํ ํ์ ๋๋ค. (ํ์ด์ฌ ๋ฌธ์์์๋ 'Deques are a generalization of stacks and queues' ๋ผ๊ณ ๋งํฉ๋๋ค) - array ์ ๊ต์ฅํ ๋น์ทํฉ๋๋ค. deque์ array ๋ ๋ชจ๋ ordered, random-access, mutable, ra..

WWDC 2022 > Embrace Swift Generics ์ ๋์ค๋ ๋ด์ฉ์ ๋๋ค. Feed (์ฌ๋ฃ, ๋จน์ด) ๋ฅผ associatedtype์ผ๋ก ๊ฐ์ง๋ Animal ํ๋กํ ์ฝ์ ์์ ๋ก ์ฌ์ฉํฉ๋๋ค. [1] AS IS Farm์ feed๋ผ๋ ๋ฉ์๋๋ฅผ ๋ง๋ค๊ณ ์ถ์ ๋, ์๋ ๋๊ฐ์ง ์ค ํ๋์ ๋ฐฉ๋ฒ์ผ๋ก ์ฝ๋๋ฅผ ์์ฑํด์คฌ์ด์ผํ์ต๋๋ค. ๋ฉ์๋๊ฐ ์ข ๋ณต์กํด๋ณด์ ๋๋ค. [2] TO BE ํ์ง๋ง!! ์ด์ opaque type์ธ some์ ์ฌ์ฉํ์ฌ, ์๋์ ๊ฐ์ด ๊ฐ๋จํ ๋ฉ์๋๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค. Swift 5.7๋ถํฐ๋ some์ parameter type์๋ ์ธ ์ ์๊ธฐ ๋๋ฌธ์ ๋๋ค ๐ (์ด์ ์๋ ํ๋กํผํฐ ํ์ , ๋ฆฌํด ํ์ ์๋ง ์ธ ์ ์์์) [3] some ๊ณผ any (1) ํ์ง๋ง,, some์ ์ ์ฝ์ด ์๋๋ฐ,, ์๋์ ๊ฐ์ด..
[1] ์ฉ์ด์ ๋ฆฌ (์ถ์ฒ: ์ดํํฐ๋ธ ์ฝํ๋ฆฐ) ์ ํ ๋ฌธ์(Sequence and Collection)์ 'eager' ์ด๋ผ๋ ๋จ์ด๊ฐ ๋์ค๋ ๋ฐ ์ด๊ฒ์ ์ดํดํ๊ธฐ ์ํด ์ดํํฐ๋ธ ์ฝํ๋ฆฐ ์ฑ ๋ด์ฉ์ ๊ฐ์ ธ์์ต๋๋ค! โ๏ธ eager order (step-by-step) - ์์ ์ ์ฒด๋ฅผ ๋์์ผ๋ก ์ฐ์ฐ์ ์ฐจ๊ทผ์ฐจ๊ทผ ์ ์ฉํ๋ค. - ๊ฐ ๋จ๊ณ์์ ์ฐ์ฐ์ด ์ด๋ฃจ์ด์ ธ ์๋ก์ด ์ปฌ๋ ์ ์ ๋ง๋ค์ด๋ธ๋ค. โ๏ธ lazy order (element-by-element) - ์์ ํ๋ํ๋์ ์ง์ ํ ์ฐ์ฐ์ ํ๊บผ๋ฒ์ ์ ์ฉํ๋ค. - ์ต์ข ์ฐ์ฐ์ด ์ด๋ฃจ์ด์ง๊ธฐ ์ ๊น์ง๋ ๊ฐ ๋จ๊ณ์์ ์ฐ์ฐ์ด ์ผ์ด๋์ง ์๋๋ค. ==> ์ฌ์ ์ ์๋ฏธ๋ก lazy = ๊ฒ์ผ๋ฅธ, eager = ์ด๋ ฌํ(์ด์ฌ์ธ) ์ด๊ธฐ ๋๋ฌธ์ ์ ๋๋จ์ด๊ฐ ๊ฐ์ด ์ฐ์ด๋ ๊ฒ ๊ฐ์์! [ eager vs lazy ] ..
Swift Docs > Attribute ๋ฅผ ๋ณด๋ฉด, Swift์ inline ๊ด๋ จ attribute ๋ก inlinable๊ณผ usableFromInline ๊ฐ ์์ต๋๋ค. [1] inline ํ์ ์๋? ์ฐ์ ์ดํํฐ๋ธ ์ฝํ๋ฆฐ ์ฑ ๋ด์ฉ์ ํตํด inline ๊ฐ๋ ์ ๋จผ์ ์์๋ด ์๋ค! inline ํ์ ์์ ์ญํ ์ ์ปดํ์ผ ์์ ์ 'ํจ์๋ฅผ ํธ์ถํ๋ ๋ถ๋ถ'์ 'ํจ์์ ๋ณธ๋ฌธ' ์ผ๋ก ๋์ฒดํ๋ ๊ฒ์ ๋๋ค. ์ผ๋ฐ์ ์ธ ํจ์๋ฅผ ํธ์ถํ๋ฉด ํจ์ ๋ถ๋ฌธ์ผ๋ก ์ ํํ๊ณ , ๋ณธ๋ฌธ์ ๋ชจ๋ ๋ฌธ์ฅ์ ํธ์ถํ ๋ค์ ํจ์๋ฅผ ํธ์ถํ๋ ์์น๋ก ๋ค์ ์ ํํ๋ ๊ณผ์ ์ ๊ฑฐ์นฉ๋๋ค. ํ์ง๋ง inline ํ์ ์๋ฅผ ๋ถ์ฌ ํจ์๋ฅผ ๋ง๋๋ฉด, ์ด๋ฌํ ์ ํ๊ฐ ์ผ์ด๋์ง ์์ต๋๋ค. # ์ฅ์ ๋ชจ๋ ํจ์๋ inline ํ์ ์๋ฅผ ๋ถ์ด๋ฉด ์กฐ๊ธ ๋ ๋น ๋ฅด๊ฒ ๋์ํฉ๋๋ค. ํจ์ ํธ์ถ๊ณผ ๋ฆฌํด์ ์ํด ์ ..
Swift Docs > Advanced Operators > Operator Methods, Custom Operators ๋ด์ฉ์ ๊ธฐ๋ฐ์ผ๋ก ํ๊ณ ์์ต๋๋ค. [1] Operator Methods Class์ Structure์ existing operators ์ ๋ํด ๊ทธ๋ค ์์ ์ ๊ตฌํ์ ์ ๊ณตํ ์ ์์ต๋๋ค. ์ด๊ฒ์ 'existing operators ๋ฅผ overloading ํ๋ค' ๋ผ๊ณ ๋งํ ์ ์์ต๋๋ค. existing operators ๋ชฉ๋ก์ Operator Declarations ๋ฌธ์์์ ๋ณผ ์ ์์ต๋๋ค. ํ์ง๋ง ๋ชจ๋ operator์ overload ํ ์ ์๋ ๊ฒ์ ์๋๋๋ค. 1๏ธโฃ default assignment operator (=) 2๏ธโฃ ternary conditional operato..

Swift Docs์ - Advanced Operators > Result Builders - Attributes > resultBuilder ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ๋ ๋ด์ฉ์ ๋๋ค. [1] Result Builder ๋? A result builder is a type you define that adds syntax for creating nested data, like a list or tree, in a natural, declarative way. A result builder is a type that builds a nested data structure step by step. result builder ๋ ์ ์ธ์ ์ธ ๋ฐฉ์ (step by step์ผ๋ก ์ฝ๋๋ฅผ ์์ฑํ ์ ์๋ ๋ฐฉ์) ์ผ๋ก nested d..
10์ง์๊ฐ 2์ง์๋ก ์ด๋ป๊ฒ ํํ๋๋ ์ง ํ์ธํ๊ณ ์ถ์ ๋ ์ ์ฉํ String ์ด๋์ ๋ผ์ด์ ๊ฐ ์์ต๋๋ค. init(_:radix:uppercase:) ์ ๋๋ค. radix ๊ธฐ๋ณธ ๊ฐ์ด 10์ธ๋ฐ 2~36 ๊น์ง ์ํ๋ ๊ฐ์ ๋ฃ์ด์ฃผ๋ฉฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ ๋ 2์ง์๋ก ๋ณํํ๊ณ ์ถ์ด์ radix๋ฅผ 2๋ก ์ค์ ํด์ฃผ๊ณ ์ฌ์ฉํ๊ฒ ์ต๋๋ค. โ ์ฐธ๊ณ ๋ก String๋ฟ๋ง์๋๋ผ Int๋ radix๋ฅผ ๋ฐ์ ์ ์๋ ์ด๋์ ๋ผ์ด์ ๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค. (์ฐธ๊ณ : init(_:radix:)) # Positive 4๋ฅผ ์ด์ง์๋ก ์ถ๋ ฅํด๋ณผ๊น์? 8-bit unsigned integer ํ์ ์ธ UInt8์ ์ฌ์ฉํด์ฃผ์์ต๋๋ค. let positiveValue: UInt8 = 4 print(String(positiveValue, radix: 2)) // 1..
Swift Docs์ Implicitly Unwrapped Optionals ์ Unowned References and Implicitly Unwrapped Optional Properties ์ ๋์ค๋ ๋ด์ฉ์ ๊ธฐ๋ฐ์ผ๋ก ํ๊ณ ์์ต๋๋ค. [1] Implicitly Unwrapped Optional ์ด๋? '์๋ฌต์ ์ผ๋ก(์์์ ์ผ๋ก) ์ธ๋ํํ ์ต์ ๋' ์ด๋ผ๋ ์ฉ์ด๊ทธ๋๋ก ์ต์ ๋์ด์ง๋ง ์ธ๋ํํ์ง ์๊ณ ์ฌ์ฉํ ์ ์๋ ์ต์ ๋์ ๋งํฉ๋๋ค. Optional์ ๋ง๋ค ๋ question mark(๋ฌผ์ํ)๋ฅผ ์ฌ์ฉํ๋ค๋ฉด (ex. String?) Implicitly Unwrapped Optional์ ๋ง๋ค ๋๋ exclamation point(๋๋ํ) ๋ฅผ ์ฌ์ฉํด์ฃผ๋ฉด ๋ฉ๋๋ค. (ex. String!) ์๋์ ์์ ๋ optiona..
Swift Docs > Opaque Types ์ ๋์ค๋ ๋ด์ฉ์ ๋๋ค! Shape ๋ผ๋ ํ๋กํ ์ฝ์ด ์๋ค๊ณ ํด๋ด ์๋ค! protocol Shape { func draw() -> String } Triangle, Square์ฒ๋ผ ์ด ํ๋กํ ์ฝ์ ์ปจํํ๋ ํ์ ์ ๋ง๋ค ์ ์์ต๋๋ค. struct Triangle: Shape { var size: Int func draw() -> String { var result: [String] = [] for length in 1...size { result.append(String(repeating: "*", count: length)) } return result.joined(separator: "\n") } } let triangle = Triangle(size: 3) pr..
Swift Docs > Protocol > Protocol Composition ์ ์ฝ๋ค๊ฐ ์๋ก ์๊ฒ๋ ๋ด์ฉ! protocol composition ์ one class type ์ ํฌํจํ ์ ์๋ค๊ณ ํฉ๋๋ค ๐ฒ ์ด๋ required superclass๋ฅผ ๋ช ์ํ ๋, ์ฌ์ฉํ ์ ์์ต๋๋ค. In addition to its list of protocols, a protocol composition can also contain one class type, which you can use to specify a required superclass. protocol Named { var name: String { get } } class Location { var latitude: Double var longi..
- Total
- 867,868
- Today
- 438
- Yesterday
- 1,696
- Python Type Hint
- Flutter Spacer
- ๊ตฌ๊ธ Geocoding API
- ์ฅ๊ณ Custom Management Command
- METAL
- Sketch ๋๋ผ
- ํ๋ฌํฐ ์ฑ๊ธํค
- ipad multitasking
- Django FCM
- DRF APIException
- Django Heroku Scheduler
- Flutter ๋ก๋ฉ
- flutter build mode
- Django Firebase Cloud Messaging
- Flutter Clipboard
- github actions
- flutter dynamic link
- cocoapod
- drf custom error
- Dart Factory
- PencilKit
- ์ฅ๊ณ URL querystring
- ํ๋ฌํฐ ์ผ๋ฟ
- Flutter getter setter
- Flutter Text Gradient
- flutter deep link
- flutter ์ฑ ์ถ์
- Watch App for iOS App vs Watch App
- ribs
- SerializerMethodField