๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

IOS๐ŸŽ/iOS+Swift15

[Swift] Optional์— ๋Œ€ํ•œ ๊ณ ์ฐฐ Swift๋Š” ์•ˆ์ „์„ฑ์„ ์ค‘์š”ํ•œ ์š”์†Œ ์ค‘ ํ•˜๋‚˜๋ผ๊ณ  ์ƒ๊ฐํ•˜๋Š” ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ๊ทธ ๋ฐ”ํƒ•์ด ๋˜๋Š” ๋ฌธ๋ฒ• ์ค‘ ํ•˜๋‚˜๊ฐ€ ๋ฐ”๋กœ ์˜ต์…”๋„(Optional)์ž…๋‹ˆ๋‹ค. ์ฒ˜์Œ ์˜ต์…”๋„์„ ๋ดค์„๋•Œ ๋‹ค๋ฅธ ์–ธ์–ด์—์„œ๋Š” ์ฐพ์•„๋ณผ ์ˆ˜ ์—†๋Š” Swift๋งŒ์˜ ๋…ํŠนํ•œ ๋ฌธ๋ฒ•์ด๋ผ๊ณ  ์ƒ๊ฐ ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ์–ผ๋งˆ์ „ ์˜ต์…”๋„์„ ๋žฉํ•‘ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ด๋Ÿฐ ๋žฉํ•‘ํ•˜๋Š” ๋ฐฉ์‹์ด ๊ท€์ฐฎ์„ ๋ฒ•(?)๋„ ํ•œ๋ฐ ์™œ ์˜ต์…”๋„์„ ์‚ฌ์šฉํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ์งˆ๋ฌธ์„ ๋ฐ›์•˜์Šต๋‹ˆ๋‹ค. ์˜ต์…”๋„์€ ์˜ต์…”๋„์ด์ง€ ์™œ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์ƒ๊ฐํ•ด๋ณธ์ ์ด ์—†์–ด์„œ nil๊ฐ’์ผ ๊ฒฝ์šฐ ๋ฉ”๋ชจ๋ฆฌ์— ์˜ฌ๋ผ๊ฐ€์ง€ ์•Š๋Š”๋‹ค๋ผ๋Š” ์—‰๋šฑํ•œ ๋Œ€๋‹ต์„ ํ•œ๊ฒŒ ์ฐธ ์•„์‰ฝ๋”๋ผ๊ตฌ์š” ..(nil๋„ ๋ฉ”๋ชจ๋ฆฌ์—์„œ ๋‹ค๋ฅธ ๊ฐ’๋“ค๊ณผ ๊ฐ™์ด ๊ฐ’์„ ๊ฐ€์ง„๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค ํ•˜ํ•˜) ๊ทธ๋Ÿฌ๋˜ ์ค‘ ์˜ต์…”๋„์— ๋Œ€ํ•ด ์ข‹์€ ๊ธ€์„ ์ฝ๊ฒŒ ๋˜์–ด ๋ฉด์ ‘๋•Œ ๋งˆ์ € ๋ชปํ•œ ์ƒ๊ฐ๊ณผ ๊ทธ ๋Œ€๋‹ต์„ ๋‹ค์‹œ ํ•ด๋ณด๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค !! Optional์ด๋ž€ ? ๊ฐ’์ด .. 2022. 4. 23.
[Swift] split, components ์ฐจ์ด (with: ์„ฑ๋Šฅ) ์ฝ”ํ…Œ ๋ฌธ์ œ๋ฅผ ํ’€๋‹ค๊ฐ€ ๋‚˜๋Š” ์™„์ „ ๋น„ํšจ์œจ์ ์œผ๋กœ ์งฐ์ง€๋งŒ ๐Ÿ˜ž ๋‹ค๋ฅธ ์‚ฌ๋žŒ ์ฝ”๋“œ ์ค‘ components()๋ฅผ ์“ด ์ฝ”๋“œ๊ฐ€ ์žˆ์–ด ์ด๊ฑด ๋ญ์ง€..? ๋ผ๋Š” ๊ถ๊ธˆ์ฆ์ด ๋“ค์—ˆ์–ด์š” ! split()ํ•จ์ˆ˜์™€ ๋น„์Šทํ•œ๊ฑฐ ๊ฐ™์€๋ฐ ์ฐจ์ด์ ์„ ์ž˜ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ์ •๋ฆฌํ•ด๋ณด๋ ค๊ตฌ ํ•ฉ๋‹ˆ๋‹ค !! split() ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋Œ€ํ•ด ์‚ดํŽด๋ด…์‹œ๋‹ค separator : ์ชผ๊ฐค ๋‹จ์œ„ maxSpilts : ์ตœ๋Œ€ ์–ผ๋งˆ๋‚˜ ์ชผ๊ฐค์ง€ // default : Int.max ()omittingEmptySubsequences : ๊ฒฐ๊ณผ ๊ฐ’์—์„œ ๋นˆ์‹œํ€€์Šค ํฌํ•จํ• ์ง€ false๋ผ๋ฉด ์ชผ๊ฐ  ๋ฐฐ์—ด์ด ๋นˆ ๋ฐฐ์—ด์ผ์ง€๋ผ๋„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. true๋ผ๋ฉด ๋นˆ๋ฐฐ์—ด์€ ์ƒ๋žตํ•˜๊ณ  ๋ฐ˜ํ™˜ํ•œ๋‹ค // default : true return๋˜๋Š” ํƒ€์ž… : [subString] Components() ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ spilt()๋ณด๋‹ค ๊ฐ„๋‹จํ•ด๋ณด์ž…๋‹ˆ.. 2022. 4. 14.
[Swift] Opaque Type์ด๋ž€ SwiftUI๋ฅผ ๋ณด๋ฉด body์— some ํ‚ค์›Œ๋“œ๊ฐ€ ๋ถ™์€๊ฑธ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฒŒ ๋ญ”์ง€ ๊ถ๊ธˆํ•ด์ ธ์„œ ์ฐพ์•„๋ณด๊ณ  ์ •๋ฆฌํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค ๐Ÿค” ์ฐธ๊ณ  ์ž๋ฃŒ : https://docs.swift.org/swift-book/LanguageGuide/OpaqueTypes.html Opaque Types — The Swift Programming Language (Swift 5.6) Opaque Types A function or method with an opaque return type hides its return value’s type information. Instead of providing a concrete type as the function’s return type, the return value is desc.. 2022. 4. 12.
[iOS] Swift Unit Test ์‚ดํŽด๋ณด๊ธฐ Unit Test๋ž€ ? ๋‹จ์œ„ ํ…Œ์ŠคํŠธ, ํŠน์ • ๊ธฐ๋Šฅ์ด ์˜๋„ํ•œ๋Œ€๋กœ ์ž˜ ์ž‘๋™๋˜๋Š”์ง€ ์ ๊ฒ€ํ•˜๊ธฐ ์œ„ํ•ด ์ž‘์„ฑํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ๋งํ•œ๋‹ค. ๋ฒ„๊ทธ์— ๋Œ€ํ•œ ๊ฐ€๋Šฅ์„ฑ์„ ๋‚ฎ์ถ”๊ณ  ์ฝ”๋“œ๋ฅผ ๊ฐœ์„ ํ•˜๊ธฐ ์œ„ํ•ด ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค. Xcode์—์„œ "Include Test"๋ฅผ ์„ ํƒํ•˜๋ฉด ํ”„๋กœ์ ํŠธ์ด๋ฆ„-Test, ํ”„๋กœ์ ํŠธ์ด๋ฆ„-UITest ๋‘๊ฐœ๊ฐ€ ๋งŒ๋“ค์–ด์ง„๋‹ค. ๋งŒ์•ฝ ์ฒ˜์Œ๋ถ€ํ„ฐ ํ…Œ์ŠคํŠธ ํ•  ์ƒ๊ฐ์ด ์—†์–ด "Include Test" ์ฒดํฌํ•˜์ง€ ์•Š๊ณ  ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค๋ฉด ? ์•„๋ž˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ Xcode Test Navigator ํƒญ์„ ํด๋ฆญํ•˜๊ณ  unit test target์„ ํด๋ฆญํ•˜๋ฉด ํŒŒ์ผ์ด ์ƒ์„ฑ๋œ๋‹ค. ์–ด์จŒ๋“  ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  ๋‚˜๋ฉด ์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™๋‹ค. XCTestCase๋ฅผ ์ƒ์† ๋ฐ›๊ณ  ์žˆ๋‹ค. ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค, ๋ฉ”์†Œ๋“œ๋ฅผ ์ •์˜ํ•˜๋Š” ํด๋ž˜์Šค๋กœ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ํด๋ž˜์Šค๋กœ ์ƒ๊ฐํ•˜๋ฉด ๋ ๊ฑฐ ๊ฐ™๋‹ค... 2022. 4. 7.
[Swift] Access Control (open, public, internal, fileprivate, private) Access Control ๋ง ๊ทธ๋Œ€๋กœ ์ฝ”๋“œ์˜ ์ ‘๊ทผ์„ ์ œ์–ดํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค. ๊ฐœ๋ณ„ ํƒ€์ž…(individual types)(ํด๋ž˜์Šค, ๊ตฌ์กฐ์ฒด ๋ฐ ์—ด๊ฑฐ) ๋ฟ๋งŒ์•„๋‹ˆ๋ผ, ํ•ด๋‹น ํƒ€์ž…์— ์†ํ•˜๋Š” ํ”„๋กœํผํ‹ฐ, ๋ฉ”์†Œ๋“œ, ์ด๋‹ˆ์…œ๋ผ์ด์ € ๋ฐ ์ฒจ์ž(subscripts)์— ๋Œ€ํ•ด ํŠน์ • ์ ‘๊ทผ ๋ ˆ๋ฒจ์„ ์ง€์ • ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ”„๋กœํ† ์ฝœ์€ ์ „์—ญ ์ƒ์ˆ˜, ๋ณ€์ˆ˜ ๋ฐ ํ•จ์ˆ˜์ฒ˜๋Ÿผ ํŠน์ • ์ปจํ…์ŠคํŠธ๋กœ ์ œํ•œ๋œ๋‹ค. ์ ‘๊ทผ ์ œ์–ด๋Š” modules๊ณผ source file ๋Œ€์ƒ์œผ๋กœ ์ ์šฉ๋œ๋‹ค. swift๋Š” ์—”ํ‹ฐํ‹ฐ์— ๋Œ€ํ•ด 5๊ฐ€์ง€ ์ ‘๊ทผ ์ œ์–ด ๋ ˆ๋ฒจ์„ ๊ฐ€์ง„๋‹ค. open, public ์ •์˜๋œ ๋ชจ๋“ˆ๋‚ด ๋ชจ๋“  ์†Œ์Šค ํŒŒ์ผ ๋‚ด์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. open ์ ‘๊ทผ์€ ํด๋ž˜์Šค ๋ฐ ํด๋ž˜์Šค ๋ฉค๋ฒ„์—๋งŒ ์ ์šฉ๋œ๋‹ค. struct, enum ๋“ฑ์˜ ํƒ€์ž…์€ Public์ด ๊ฐ€์žฅ ์ตœ์ƒ์œ„ ์ ‘๊ทผ ์ œ์–ด๋‹ค. ํด๋ž˜์Šค์™€ ํด๋ž˜์Šค ๋ฉค๋ฒ„์— .. 2022. 3. 29.
[Swift] CustomStringConvertible CustomStringConvertible ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•  ๋•Œ ์ปค์Šคํ…€ํ•˜๊ฒŒ ๋ณ€ํ™˜ํ• ์ˆ˜ ์žˆ๋Š” ํ”„๋กœํ† ์ฝœ์ด๋‹ค. struct Point { let x: Int, y: Int } let p = Point(x: 21, y: 30) print(p) // Prints "Point(x: 21, y: 30)" ๊ธฐ๋ณธ Point ๊ตฌ์กฐ์ฒด๋ฅผ ์ถœ๋ ฅํ• ๋•Œ ๊ธฐ๋ณธ ์ถœ๋ ฅ๊ฐ’์œผ๋กœ ๋‚˜์˜ค์ง€๋งŒ CustomStringConvertible ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์•„๋ž˜ description์„ ์ค€์ˆ˜ํ•ด์•ผ ํ•˜๋ฉฐ extension Point: CustomStringConvertible { var description: String { return "(\(x), \(y))" } } print(p) // Prints "(21, 30)" ์›ํ•˜๋Š” ์ถœ๋ ฅ๊ฐ’์œผ๋กœ ๋ณ€ํ˜•ํ•˜์—ฌ ์ถœ๋ ฅ.. 2022. 3. 7.
[iOS/swift] ์œ ์šฉํ•œ ์‚ฌ์ดํŠธ ์ •๋ฆฌ ๋ชจ์Œ.zip ์•„๋‹ˆ ๋งค๋ฒˆ ํ•„์š”ํ•œ ๊ธฐ๋Šฅ์„ ๊ตฌ๊ธ€์— ์ณ์„œ ๊นƒํ—ˆ๋ธŒ์— ์ •๋ฆฌ๋œ ํ”„๋ ˆ์ž„์›Œํฌ, ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋งŒ ์‚ฌ์šฉํ–ˆ์—ˆ๋Š”๋ฐ ์ด๋Ÿฐ๊ฑธ ๋ชจ์•„๋†“๋Š” ์‚ฌ์ดํŠธ๊ฐ€ ์žˆ๋‹ค๋Š” ์‚ฌ์‹ค์„ ์ฒจ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค .. ์‹ ์„ธ๊ณ„๋‹ค!!! ๊ทธ๋ž˜์„œ ์•ž์œผ๋กœ ์ฐธ๊ณ ํ•  ์‚ฌ์ดํŠธ ๊ธฐ์–ตํ•ด ๋‘๊ธฐ ์œ„ํ•ด ์ด๊ณณ์— ๋‹ค ์ •๋ฆฌํ•ด๋‘๋ คํ•œ๋‹ค ์ถ”ํ›„์— ๊ณ„์† ์—…๋ฐ์ดํŠธ ํ•  ์˜ˆ์ • !! Cocoa controls - www.cocoacontrols.com/ Custom Controls for iOS, iPadOS, macOS, tvOS, and watchOS - Cocoa Controls Is this hosted on GitHub? If this control is hosted on GitHub, paste the address below, otherwise click "Not Hosted on GitHub". Gi.. 2021. 7. 3.
[iOS] Codable - Encodable & Decodable ํ”„๋กœํ† ์ฝœ json์„ ํŒŒ์‹ฑํ•˜๋Š” ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜์ด๋‹ค. ๋‹ค๋ฅธ ํ•˜๋‚˜๋Š” ๋‹ค์Œ ๊ธ€์—์„œ ์•Œ์•„๋ณด๊ฒ ๋‹ค. (๋งŽ๊ด€๋ถ€) Codable ์ด๋ž€? -> ์ž์‹ ์„ ๋ณ€ํ™˜ํ•˜๊ฑฐ๋‚˜ ์™ธ๋ถ€ ํ‘œํ˜„(ex> json)์œผ๋กœ ๋ณ€ํ™˜ํ• ์ˆ˜ ์žˆ๋Š” ํƒ€์ž… ๋ณดํ†ต์€ json์œผ๋กœ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค! ๊ทธ๋ž˜์„œ ์•„๋ž˜ ์˜ˆ์‹œ๋„ json ํƒ€์ž…์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์‚ดํŽด๋ณผ ๊ฒƒ์ด๋‹ค. Encodable๊ณผ Decodable์„ ํ†ตํ‹€์€ ๊ฒƒ typealias๋Š” ๋ญ์ง€ ?? * typealias - ๊ธฐ์กด ์„ ์–ธ๋œ ๋ฐ์ดํ„ฐ ํƒ€์ž…์— ๋ณ„์นญ์„ ์‚ฌ์šฉํ•จ์œผ๋กœ์„œ ์ฝ”๋“œ๋ฅผ ๋” ์ฝ๊ธฐ ์‰ฝ๋„๋ก ๋งŒ๋“œ๋Š” ๋ฌธ๋ฒ• ์˜ˆ๋ฅผ ๋“ค์–ด์„œ typealias Name: String ์ด๋ผ ํ–ˆ์„ ๋•Œ let name: Name = "ํ™๊ธธ๋™" == let name: String = "ํ™๊ธธ๋™" ๊ธฐ์กด ํƒ€์ž… String์˜ ๋ณ„๋ช…์„ Name์œผ๋กœ ํ–ˆ์„๋•Œ ์•„ํ•˜ String .. 2021. 5. 31.
[iOS] View Controller ์ƒ๋ช…์ฃผ๊ธฐ ๋ทฐ ์ปจํŠธ๋กค๋Ÿฌ๋Š” ๋ฐ์ดํ„ฐ ๊ฐ์ฒด์™€ ๋ทฐ ์‚ฌ์ด์˜ ์ค‘๊ฐœ์ž์ด๋‹ค. โ— method viewDidLoad() - ๋ทฐ๋ฅผ ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋“œ ํ•œ ํ›„ ์ˆ˜ํ–‰, ๋ทฐ์˜ ์ดˆ๊ธฐํ™” ์ž‘์—… viewWillAppear() - will : ํ™”๋ฉด์— ํ‘œ์‹œ๋˜๊ธฐ ์ง์ „ ํ˜ธ์ถœ - ๋ทฐ๊ฐ€ ํ™”๋ฉด์— ๋‚˜ํƒ€๋‚  ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์„œ๋“œ viewDidAppear() - did : ํ™”๋ฉด์ด ํ‘œ์‹œ๋œ ์งํ›„ ํ˜ธ์ถœ viewWillDisappear() - ๋ทฐ๊ฐ€ ํ™”๋ฉด์—์„œ ์‚ฌ๋ผ์งˆ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์„œ๋“œ viewDidDisappear() - ๋ทฐ๊ฐ€ ํ™”๋ฉด์—์„œ ์™„์ „ํžˆ ์‚ฌ๋ผ์กŒ์„ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์„œ๋“œ โ—์ƒ๋ช… ์ฃผ๊ธฐ(life cycle) viewDidLoad ↓ viewWillAppear ↓ viewDidAppear ↓ viewWillDisappear ↓ viewDidDisappear ↓ viewDidUnload.. 2021. 5. 3.
[iOS] Layout ์ •๋ฆฌ layout Frame ๊ธฐ๋ฐ˜ ๋ชจ๋“  ๋ทฐ์˜ ์œ„์น˜๋ฅผ ์„ค์ •ํ•ด์ฃผ๋Š” ๋ฐฉ์‹, ๊ฐ€์žฅ ์œ ์—ฐํ•˜๊ณ  ๋น ๋ฅธ ์„ฑ๋Šฅ์„ ๋ณด์ธ๋‹ค. auto layout ๊ธฐ๋ฐ˜ View๋“ค ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ์ด์šฉํ•˜์—ฌ View์˜ ์œ„์น˜์™€ ํฌ๊ธฐ๋ฅผ ๋™์ ์œผ๋กœ ๊ณ„์‚ฐํ•˜๋Š” Layout System ์™ธ๋ถ€ ๋ณ€๊ฒฝ : super view์˜ ํฌ๊ธฐ๋‚˜ ๋ชจ์–‘์ด ๋ณ€๊ฒฝ๋ ๋•Œ (ex> ํšŒ์ „, ๋ถ„ํ•  ๋ทฐ) ๋‚ด๋ถ€ ๋ณ€๊ฒฝ : ์ธํ„ฐํŽ˜์ด์Šค ๋ทฐ์˜ ํฌ๊ธฐ๋‚˜ ์„ค์ •์ด ๋ณ€๊ฒฝ๋ ๋•Œ ๋ฐœ์ƒ ์Šคํ† ๋ฆฌ ๋ณด๋“œ์ƒ layout์— ๋Œ€ํ•ด ์‚ดํŽด๋ณด์ž Attrubuote ์ข…๋ฅ˜์—๋Š” ์ด๋ ‡๊ฒŒ 4๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค. layout์˜ ๊ณ„์‚ฐ๋˜๋Š” ์„ ํ˜• ๋ฐฉ์ •์‹ ์€ ์ด๋Ÿฌํ•˜๋‹ค ๊ทธ๋ž˜์„œ ๋งค๋ฒˆ ์Šคํ† ๋ฆฌ ๋ณด๋“œ ์™ผ์ชฝ์— ์ด๋Ÿฌํ•œ ๋ฐฉ์ •์‹์„ ๋ณผ ์ˆ˜ ์žˆ๋Š”๋ฐ ์ด๊ฒƒ์ด ๋ฐ”๋กœ ๊ทธ๊ฒƒ์ด๋‹ค !! ๊ทธ๋Ÿฌ๋ฉด safeArea์™€ view๋Š” ๋ญ๊ฐ€ ๋‹ค๋ฅผ๊ฑธ๊นŒ๋‚˜ ์• ํ”Œ์€ safeArea๋ฐ–์— ui ๋ฐฐ์น˜์‹œํ‚ค์ง€ ๋ง๊ฒƒ์„ ๊ถŒ๊ณ ํ–ˆ.. 2021. 4. 27.
[iOS] UIScene, UIWindowScene, UISceneSession SceneDelegate.swift class SceneDelegate: UIResponder, UIWindowSceneDelegate { ... } SceneDelegate๊ฐ€ ์ƒ์†๋ฐ›๋Š” UIWindowSceneDelegate์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์‚ดํŽด๋ณด๊ณ ์ž ํ•œ๋‹ค. ์šฐ์„  ๊ธฐ๋ณธ์ ์ธ UI ๊ตฌ์กฐ๋Š” ์ด๋ ‡๊ฒŒ ๋˜์–ด ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋” ์ž์„ธํžˆ ์‚ดํŽด๋ณด๋ฉด ..! ์ด๋ ‡๊ฒŒ UIWindow์™€ UIScreen ์‚ฌ์ด์— ๋ฌด์–ธ๊ฐ€๊ฐ€ ์žˆ๋‹ค! ์ด์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์‚ดํŽด๋ณด์ž UIScene (๋’ค์— ์‚ดํŽด๋ณผ UIWindowScene๊ณผ UISceneSession์ด UIScene์„ ์ƒ์†๋ฐ›๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ถ€ํ„ฐ ์‚ดํŽด๋ณผ ๊ฒƒ์ด๋‹ค.) ์•ฑ ui์˜ ํ•˜๋‚˜ instance ๋˜๋Š” ๋ณต์‚ฌ๋ณธ์„ ์˜๋ฏธํ•œ๋‹ค ์ผ๋ฐ˜์ ์œผ๋กœ UIKit์€ UIScene ๊ฐ์ฒด ๋Œ€์‹  UIWindowScene ๊ฐ์ฒด๋ฅผ.. 2021. 4. 16.
[Swift] Closure์— ๋Œ€ํ•ด ์•Œ์•„๋ด…์‹œ๋‹ค. ์˜ค๋Š˜์€ ๊ทธ๋™์•ˆ ๋งŽ์ด ์“ฐ์˜€์ง€๋งŒ ๊ทธ๋ƒฅ ์ง€๋‚˜์นœ closure์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ณ ์ž ํ•œ๋‹ค. ์ƒ๋žต๋œ ํ‘œํ˜„์ด ๋งŽ์•„์„œ ์ด๊ฒŒ ํ•จ์ˆ˜์ธ๊ฐ€? ํ•˜๊ณ  ์˜๋ฌธ์ด ๋“ค๋•Œ๋„ ๋งŽ๊ณ  swift/IOS ์ดˆ๋ณด ์ผ๋•Œ๋Š” ๋งŽ์ด ํ—ท๊ฐˆ๋ฆฌ๋Š” ๊ฐœ๋…์ธ๊ฑฐ ๊ฐ™๋‹ค. ๊ณต์‹ ๋ฌธ์„œ(swift-closure)์™€ ํ•จ๊ป˜ ์ •๋ฆฌํ•˜๋‹ค๋ณด๋ฉด ์ด์ œ ์œ ์šฉํ•˜๊ฒŒ ์ž˜ ์“ฐ๊ฒ ์ง€ !! Closure๋ž€? ์ต๋ช… ํ•จ์ˆ˜ func์œผ๋กœ ์„ ์–ธํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ ํ•จ์ˆ˜๋ฅผ ๋ณ€์ˆ˜์— ์„ ์–ธํ•˜๋Š” ํ˜•ํƒœ ๊ณต์‹ ๋ฌธ์„œ์—๋Š” ํด๋กœ์ €๋Š” ์–ด๋–ค ์ƒ์ˆ˜๋‚˜ ๋ณ€์ˆ˜์˜ ์ฐธ์กฐ๋ฅผ ์บก์ณ(capture)ํ•ด ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ผ๊ณ  ์ •์˜ํ•ด๋‘์—ˆ๋‹ค. ์ด์— ๋Œ€ํ•ด ์•„๋ž˜์—์„œ ์ž์„ธํ•˜๊ฒŒ ์‚ดํŽด๋ณด์ž ํด๋กœ์ €๊ฐ€ ๊ฐ€์ง€๋Š” ํ˜•ํƒœ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด 3๊ฐ€์ง€๋‹ค ์ „์—ญ ํ•จ์ˆ˜ : ์ด๋ฆ„ O, ์บก์ณ X ์ค‘์ฒฉ ํ•จ์ˆ˜ : ์ด๋ฆ„ O, ์บก์ณ O ํด๋กœ์ € ํ‘œํ˜„ : ์ด๋ฆ„ X, ๊ฒฝ๋Ÿ‰ํ™”๋œ ๋ฌธ๋ฒ•์œผ๋กœ ๊ด€๋ จ๋œ ๋ฌธ๋งฅ(Context.. 2021. 4. 16.
[iOS] Notification๊ณผ NotificationCenter NotificationCenter๋Š” ์ค‘์•™์ง‘๊ถŒ์ ์ด๋‹ค! ๋ชจ๋“  ๋ทฐ์˜ ํ–‰๋™๋“ค์„ ๊ฐ์‹œํ•˜๊ณ  ๊ทธ์— ํ•ด๋‹นํ•˜๋Š” ์ •๋ณด๋ฅผ ์ˆ˜์‹ ํ•ด ๊ด€๋ฆฌํ•˜๋Š” ๊ณณ์ด๋‹ค. ์—ฌ๋Ÿฌ notification์ด ๋ชจ์—ฌ ์žˆ๋Š”๋ฐ ๊ฐ viewController์— ํŒŒ๊ฒฌ๋˜์–ด ๊ฐ์‹œํ•˜๋Š” ์นœ๊ตฌ๊ฐ€ Observer์ด๊ณ  NotificationCenter์— Observer๋“ค์ด ๋“ฑ๋ก๋˜์–ด ์žˆ๋‹ค. Observer์™€ Notification Center ๊ทธ๋ฆฌ๊ณ  notification์˜ ๊ด€๊ณ„๋ฅผ ๊ฐ์ž ์ด๋ฆ„์˜ ๋œป์„ ์ž˜ ์ƒ๊ฐํ•ด๋ณด๋ฉฐ ์ดํ•ดํ•ด๋ณด์ž Notification ๋“ฑ๋ก๋œ ๋ชจ๋“  observers์— NotificationCenter๋ฅผ ํ†ตํ•ด ์ •๋ณด๋ฅผ ์ „๋‹ฌํ•˜๊ธฐ ์œ„ํ•œ ๊ตฌ์กฐ์ฒด var name : Notification.name //์•Œ๋ฆผ ์‹๋ณ„ ํƒœ๊ทธ var object: ๋ฐœ์†ก์ž๊ฐ€ ์˜ต์ €๋ฒ„์—๊ฒŒ ๋ณด๋‚ด๋ ค๊ณ  ํ•˜๋Š” ๊ฐ์ฒด... 2021. 4. 16.
[Swift] Property - stored, computed, type / Observer swift ์–ธ์–ด์˜ ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ๋ฌธ๋ฒ•์ธ property์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์Šค์œ„ํ”„ํŠธ์˜ property๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด 3๊ฐ€์ง€๋กœ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. stored Property (์ €์žฅ ํ”„๋กœํผํ‹ฐ) computed property (์—ฐ์‚ฐ ํ”„๋กœํผํ‹ฐ) type property (ํƒ€์ž… ํ”„๋กœํผํ‹ฐ) ๊ธฐ๋ณธ ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ ์ •๋ฆฌํ•˜์˜€์Šต๋‹ˆ๋‹ค. https://docs.swift.org/swift-book/LanguageGuide/Properties.html Properties — The Swift Programming Language (Swift 5.7) Properties Properties associate values with a particular class, structure, or enumeration. S.. 2021. 4. 13.
[iOS] iOS13์ดํ›„์˜ AppDelegate์™€ SceneDelegate iOS 12 ์ด์ „์˜ appDelegate์˜ ์—ญํ•  1. ํ•˜๋‚˜์˜ ์•ฑ์— ํ•˜๋‚˜์˜ window๊ฐ€ ์กด์žฌ! iOS 13 ์ดํ›„์˜ appDelegate์™€ scenceDelegate์˜ ์—ญํ•  1. window ๊ฐœ๋…์ด scene์œผ๋กœ ๋Œ€์ฒด๋˜๊ณ  ํ•˜๋‚˜์˜ ์•ฑ์— ์—ฌ๋Ÿฌ scene์„ ๊ฐ€์งˆ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ๋‹ค. 2. UILifecycle์„ ๋”์ด์ƒ ApplDelegate์—์„œ ๊ด€๋ฆฌํ•˜์ง€ ์•Š๋Š”๋‹ค. 3. AppDelegate์— Session Lifecycle ์—ญํ• ์ด ์ถ”๊ฐ€๋˜์—ˆ๋‹ค. Scene Session์ด ์ƒ์„ฑ(created)๋˜๊ฑฐ๋‚˜ ์‚ญ์ œ(discarded)๋ ๋•Œ Appdelegate์— ์•Œ๋ฆฌ๋Š” ๋ฉ”์†Œ๋“œ(Scene Session)๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ๋‹ค. Scene Session์€ ์•ฑ์—์„œ ์ƒ์„ฑํ•œ ๋ชจ๋“  scene์˜ ์ •๋ณด๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค. Scene์ด๋ž€? ๊ธฐ์กด์˜ window ๊ฐœ๋…์—.. 2021. 4. 7.