IOS

ยท๐ŸŒฑ SeSAC
BaseViewController ์‚ฌ์‹ค ์ด์ „์—๋„ BaseViewController๋ฅผ ๋งŒ๋“ค์–ด์„œ ์„œ๋ธŒํด๋ž˜์‹ฑํ•˜๋Š” ์ž‘์—…์„ ํ•ด์™”์—ˆ๋Š”๋ฐ ์–ด๋Š ์ˆœ๊ฐ„ ํ”„๋กœํ† ์ฝœ์„ ์“ฐ๋Š” ๊ฒŒ ์ข‹๋‹ค๋Š” ์ฃผ๋ณ€ ๋ง์ด ๋งŽ์ด ๋“ค๋ ธ๋‹ค. ๊ทธ๋ž˜์„œ ๊ทธ๋Ÿฐ๊ฐ€๋ผ๋Š” ์ƒ๊ฐ์„ ๋‚˜๋„ ๋ฉ๋‹ฌ์•„ ํ–ˆ์—ˆ๋Š”๋ฐ, ์ƒ์†์„ ํ•˜๋Š” ๊ตฌ์กฐ๊ฐ€ ๋ฌด์ž‘์ • ๋‚˜์˜๋‹ค๋Š” ์ƒ๊ฐ์„ ํ•˜๋Š” ๊ฒƒ์ด ์˜คํžˆ๋ ค ์ž˜๋ชป๋˜์ง€ ์•Š์•˜๋‚˜๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค. ์–ด์ฐจํ”ผ ์ƒ์†์€ ํ•˜๋‚˜์˜ ํด๋ž˜์Šค๋งŒ ํ•  ์ˆ˜ ์žˆ๊ณ , ๋ชจ๋“  ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ๊ณตํ†ต์ ์œผ๋กœ ์“ฐ์—ฌ์•ผ ํ•˜๋Š” ๋‚ด์šฉ์ด๋ผ๋ฉด ํ•˜๋‚˜์˜ BaseViewController๋กœ ์ƒ์†๋ฐ›์•„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๋” ๋‚ซ์ง€ ์•Š๋‚˜ ์ƒ๊ฐ์ด ๋“ ๋‹ค. ๊ฐœ์ธ์ ์œผ๋กœ ๊ทธ ์™ธ์ ์ธ ๊ฒƒ๋“ค์„ ํ”„๋กœํ† ์ฝœ๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ๋” ๋งž๋Š” ๊ฒƒ ๊ฐ™๋‹ค. ์ƒ์†๊ณผ ํ•ฉ์„ฑ์„ ์ ์ ˆํžˆ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๊ฐ€์žฅ ์ ์ ˆํ•œ ๊ฒƒ ๊ฐ™์€๋ฐ ๊ทธ ์ •๋„๋ฅผ ์ฐพ๊ธฐ๊ฐ€ ์ •๋ง ์–ด๋ ค์šด ๊ฒƒ ๊ฐ™๋‹ค. BaseView..
ยท๐ŸŒฑ SeSAC
ํƒ€์ž… ํ™•์ธ type(of: x) type(of: value) ํ˜• ๋ณ€ํ™˜ - ํƒ€์ž… ๋ณ€ํ™˜ ์ดˆ๊ธฐํ™” ๊ตฌ๋ฌธ ์‚ฌ์šฉ ์ด๋‹ˆ์…œ๋ผ์ด์ € ๊ตฌ๋ฌธ์„ ํ†ตํ•ด์„œ ์ƒˆ๋กญ๊ฒŒ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ let value = String(a) ํƒ€์ž… ํ™•์ธ ์—ฐ์‚ฐ์ž is ์–ด๋–ค ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค ํƒ€์ž…์ธ์ง€, ์–ด๋–ค ๋ฐ์ดํ„ฐ ํƒ€์ž…์ธ์ง€ ํ™•์ธํ•  ๋•Œ ์‚ฌ์šฉ class Mobile { let name: String var introduce: String { return "\(name) ์ž…๋‹ˆ๋‹ค." } init(name: String) { self.name = name } } class Apple: Mobile { let wwdc = "WWDC22" } class Google: Mobile {} mobile is Mobile mobile is Apple mobile is G..
ยท๐ŸŽ iOS & Swift
PageViewController ์ด์Šˆ PageViewController๋ฅผ ์ฒ˜์Œ ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ด์Šˆ๋ฅผ ๋งŒ๋‚  ์ˆ˜ ์žˆ๋‹ค. ํ•ด์„์„ ์กฐ๊ธˆ๋งŒ ํ•ด๋ณด๋ฉด ์‰ฝ๊ฒŒ ๋ฌธ์ œ๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋‹ค. Issue Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The number of view controllers provided (3) doesn't match the number required (1) for the requested transition' View Controller๊ฐ€ ํ•„์š” ์ด์ƒ์œผ๋กœ ํ• ๋‹น๋˜์—ˆ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. 1๊ฐœ๋งŒ ํ•„์š”ํ•œ๋ฐ 3๊ฐœ๋‚˜ ๋„ฃ์—ˆ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ๐Ÿ˜… ๊ธฐ์กด ์ฝ”๋“œ // PageViewController.swift impo..
ยท๐ŸŽ iOS & Swift
๋“ค์–ด๊ฐ€๋ฉฐ UIImage๋Š” Decodable๊ณผ Encodable์„ ๋”ฐ๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•œ ๋งˆ๋””๋กœ UIImage๋Š” Codable ํ”„๋กœํ† ์ฝœ์„ ๋”ฐ๋ฅด์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ ๋ชจ๋ธ ๊ตฌ์กฐ๋ฅผ ์งค ๋•Œ ์ฃผ์˜ํ•ด์•ผ ํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. struct SampleDataModel: Codable { let image: UIImage // โ›”๏ธ ์—๋Ÿฌ ๋ฐœ์ƒํ•˜๋Š” ๋ถ€๋ถ„ let title: String let contents: String let tag: [Int] let createdAt: String } ํ•ด๊ฒฐ ์ง€๊ธˆ์€ image ๋‹จ์ผ ๊ฐ์ฒด์— ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, ์•„๋ž˜ 2๊ฐ€์ง€ ๋ฐฉ๋ฒ• ์ค‘ ์ ์ ˆํ•˜๊ฒŒ ํ•˜๋‚˜๋ฅผ ํƒํ•ด์„œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์˜ˆ์‹œ 1 struct SampleDataModel: Codable { ..
ยท๐ŸŽ iOS & Swift
first(where:) Array์˜ ์ธ์Šคํ„ด์Šค ๋ฉ”์„œ๋“œ์ด๋‹ค. ์ƒ๊ฐ๋ณด๋‹ค ์ •๋ง ๋งŽ์€ ๊ณณ์—์„œ ์ฝ”๋“œ๊ฐ€ ์‚ฌ์šฉ๋˜์–ด์„œ ์ด๋ฒˆ์— ์ •๋ฆฌํ•ด์•ผ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค. ์ •์˜ func first(where predicate: (Element) throws -> Bool rethrows -> Element? Parameter predicate ์‹œํ€€์Šค์˜ ์š”์†Œ๋ฅผ ์ธ์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์š”์†Œ๊ฐ€ ์ผ์น˜ํ•˜๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ถ€์šธ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํด๋กœ์ €. Return Predicate๋ฅผ ๋งŒ์กฑํ•˜๋Š” ์ฒซ ๋ฒˆ์งธ ์š”์†Œ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ฑฐ๋‚˜, ์—†๋‹ค๋ฉด nil์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. Example 1 (Apple ๊ณต์‹ ๋ฌธ์„œ) let numbers = [3, 7, 4, -2, 9, -6, 10, 1] if let firstNegative = numbers.first(where: { $0 ..
ยท๐ŸŽ iOS & Swift
๋“ค์–ด๊ฐ€๊ธฐ์ „์— Rx, Reactive Programming์ด ๋น„๋™๊ธฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์ž˜ํ•˜๊ธฐ ์œ„ํ•œ ๋…ธ๋ ฅ์ด๋ผ๊ณ  ์ด์ „ ์‹œ๊ฐ„(Reactive Programming ํŽธ)์— ์ด์•ผ๊ธฐํ–ˆ๋Š”๋ฐ ๊ทธ๋Ÿผ ๋น„๋™๊ธฐ? ๋น„๋™๊ธฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด ๋ฌด์—‡์ผ๊ฐ€์š”? ๊ฐ„๋‹จํ•˜๊ฒŒ ์‚ดํŽด๋ณด๋„๋ก ํ•˜์ฃ . ๋น„๋™๊ธฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ? iOS ์•ฑ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฒ„ํŠผ ํƒญ(ํด๋ฆญ)์— ๋ฐ˜์‘ํ•˜๊ธฐ ํ‚ค๋ณด๋“œ๋ฅผ ํ…์ŠคํŠธ ํ•„๋“œ๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜ํ•˜๋ฉด ํฌ์ปค์Šค๊ฐ€ ์‚ฌ๋ผ์ง ์ธํ„ฐ๋„ท์—์„œ ํฐ ์‚ฌ์ง„ ๋‹ค์šด๋กœ๋“œ → ๋‹ค์šด๋กœ๋“œ ์ค‘์— ๋‹ค๋ฅธ ์ž‘์—…์„ ์ˆ˜ํ–‰ ๋ฐ์ดํ„ฐ ๋น„ํŠธ๋ฅผ ๋””์Šคํฌ์— ์ €์žฅ ์˜ค๋””์˜ค ์žฌ์ƒ ์ถœ์ฒ˜ : Raywenderich - ์—ฌ๊ธฐ ํด๋ฆญ ํ•œ ๋ฒˆ ์ƒ๊ฐ์„ ํ•ด๋ณด๋ฉด ๊ฐ๊ฐ์˜ ์ž‘์—…๋“ค์€ ์„œ๋กœ์˜ ์‹คํ–‰์„ ์ฐจ๋‹จํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์„œ๋กœ ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ์—์„œ ์„œ๋กœ ๋‹ค๋ฅธ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋„๋ก iOS๋Š” ๋‹ค์–‘ํ•œ ์ข…๋ฅ˜์˜ API๋ฅผ ์ œ..
ยท๐ŸŒฑ SeSAC
FrameBaseLayout FrameBaseLayout + AutoResizing ์š”์ฆ˜์—๋Š” ํ•ด๋‹น ๋ฐฉ์‹์œผ๋กœ๋Š” ๊ธฐ๊ธฐ๋ฅผ ์ „๋ถ€ ๋Œ€์‘ํ•˜๊ธฐ ์–ด๋ ค์›Œ์ง view.addSubview(emailTextField) // ํฌ๊ธฐ์™€ ์œ„์น˜ ๋ฐ ์†์„ฑ ์ •์˜ emailTextField.frame = CGRect(x: 50, y: 50, width: UIScreen.main.bounds.width - 100, height: 50) emailTextField.borderStyle = .line emailTextField.backgroundColor = .lightGray AutoLayout AutoLayout (๊ธฐ๊ธฐ๋ณ„ ๋Œ€์‘ ํ•„์š”) + NSLayoutConstraints Class(- base) AutoLayout ์ž‘์—… ์‹œ AutoResi..
ยท๐ŸŒฑ SeSAC
๊ธฐ์ˆ  ์ปจํผ๋Ÿฐ์Šค ๊ธฐ์ˆ  ์ปจํผ๋Ÿฐ์Šค, ๋ธ”๋กœ๊ทธ ์ž์ฃผ ๋ณด๊ธฐ! wwdc if kakao slash tech blog ๋ชจ๋“ˆํ™”์™€ ์ ‘๊ทผ ์ œ์–ด ๋ชจ๋“ˆํ™” ์ž‘์—…์„ ํ•˜๋‹ค๋ณด๋ฉด ์—ฌ๋Ÿฌ ํ”„๋กœ์ ํŠธ์—์„œ ๊ณตํ†ต์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค. UI ์ปดํฌ๋„ŒํŠธ, ๊ณตํ†ต์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ํด๋ž˜์Šค ๋“ฑ๋“ฑ์ด ์žˆ์„ํ…๋ฐ ์ด๋ฅผ ๋งค ํ”„๋กœ์ ํŠธ ๋‚ด์—์„œ ์ง์ ‘ ์ž‘์„ฑํ•ด์ฃผ๋Š” ๊ฒƒ๋ณด๋‹ค ๋น„์Šทํ•œ ์„ฑ๊ฒฉ์˜ ์ฝ”๋“œ๋ผ๋ฆฌ ๋ชจ์•„์„œ ์ข€ ๋” ํšจ์œจ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋‹ค. ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ๋งŒ๋“ ๋‹ค๊ณ ๋„ ์ดํ•ดํ•ด๋ณผ ์ˆ˜ ์žˆ์Œ ๋ชจ๋“ˆํ™”๋ฅผ ํ•ด๋ณด๋ฉด ์ ‘๊ทผ ์ œ์–ด์— ๋Œ€ํ•œ ๊ฐœ๋…์ด ์กฐ๊ธˆ ๋ช…ํ™•ํ•ด์ง (- ์‹ค์ œ๋กœ ๋‚ด๊ฐ€ EasyKit์ด๋ผ๋Š” ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ๋งŒ๋“ค์–ด๋ณด๋ฉด์„œ ๋Š๊ผˆ๋˜ ๋ถ€๋ถ„์ด๋‹ค.) ์‹ค์ œ ํ”„๋กœ์ ํŠธ๋Š” ์กฐ๊ธˆ ๊ฐ€๋ฒผ์›Œ์ง ๊ฐ๊ฐ ์—ญํ• ์— ๋Œ€ํ•œ ๋ถ„๋ฆฌ๊ฐ€ ๋ช…ํ™•ํ•ด์ง ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ์ฝ”๋“œ, UI ๋ชจ์•„๋†“๊ธฐ ์ ‘๊ทผ ์ œ์–ด ์ด๋ก ์ ์œผ๋กœ ์ •๋ฆฌํ•˜๋Š” ๊ฒƒ๋„ ์ค‘์š”ํ•˜์ง€๋งŒ..
taeeekki
'IOS' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก (5 Page)