728x90

๐Ÿ“ฑ App Development Study/iOS๐ŸŽ 57

[Udemy iOS & Swift Bootcamp] Typing Animation(Timers, For loops)

์›ฐ์ปด ํ™”๋ฉด์˜ ๊ธ€์ž๋ฅผ ํƒ€์ดํ•‘ ์น˜๋Š” ๋“ฏํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜์œผ๋กœ ํ‘œํ˜„ํ•ด๋ณด์ž. 1. TextLabel ์Šคํฌ๋ฆฝํŠธ์— ์—ฐ๊ฒฐ 2. ๋ฐ˜๋ณต๋ฌธ์— ํƒ€์ด๋จธ ์ถ”๊ฐ€ import UIKit class WelcomeViewController: UIViewController { @IBOutlet weak var titleLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() titleLabel.text = "" var charIndex = 0.0 let titleText = "โšก๏ธFlashChat" for letter in titleText{ print("-") print(0.1 * charIndex) print(letter) Timer.scheduledTimer(withTimeI..

[Udemy iOS & Swift Bootcamp] Navigation Controller Stack

ํ™”๋ฉด์„ ๋„˜๊ธธ ๋•Œ๋งˆ๋‹ค ์œ„๋กœ ์Œ“๋˜, Back ๋ฒ„ํŠผ์„ ๋งŒ๋“ค์–ด์„œ ๊ด€๋ฆฌํ•ด์ฃผ์ž. 1. Ctrl ํ‚ค๋กœ ํ™”๋ฉด๊ณผ ํ™”๋ฉด์‚ฌ์ด๋ฅผ ์—ฐ๊ฒฐํ•ด์ค€๋‹ค. 2. Root ๋…ธ๋“œ์˜ View Controller ๋ฒ„ํŠผ์„ ํด๋ฆญํ•œ ํ›„, Editor > Embed In > Navigation Controller ํด๋ฆญ ํ•œ๋‹ค. ๊ทธ๋Ÿผ ์œ„์™€ ๊ฐ™์ด Root ํ™”๋ฉด์„ ๊ธฐ์ค€์œผ๋กœ ๋‹ค๋ฅธ ํ™”๋ฉด์— Back ๋ฒ„ํŠผ์ด ์ƒ๊ธด๋‹ค. ์ด๊ฒŒ ๋ฐ”๋กœ Navigation Controller Stack. 3. Chat ํ™”๋ฉด์—์„œ Register/Login ํ™”๋ฉด์œผ๋กœ ๋Œ์•„๊ฐˆ ๋•Œ๋Š” ํ—ท๊ฐˆ๋‹ˆ๊นŒ RegisterToChat, LoginToChat์œผ๋กœ ์ด๋ฆ„ ์ •์˜ํ•ด์ฃผ๊ธฐ. 4. ์‹คํ–‰ํ•ด์„œ ๊ฒฐ๊ณผ๋ฌผ ํ™•์ธ

[Udemy iOS & Swift Bootcamp] ํ˜„์žฌ ์œ„์น˜ ์ •๋ณด ์‚ฌ์šฉํ•˜๊ธฐ

์•ฑ์—์„œ ํ˜„์žฌ ์œ„์น˜ ์ •๋ณด ๋ฐ›์•„์˜ค๋Š” ๋ฒ• ! 1. CoreLocation ํด๋ž˜์Šค import ํ•ด์ฃผ๊ธฐ 2. CLLocationManager๋ฅผ ์„ ์–ธํ•˜๊ธฐ 3. requestWhenInUseAuthorization()์œผ๋กœ ํ˜„์žฌ ์œ„์น˜์ •๋ณด ์ ‘๊ทผ๊ถŒํ•œ ๋ฐ›์•„์˜ค๊ธฐ import CoreLocation let locationManager = CLLocationManager() locationManager.requestWhenInUseAuthorization() ์œ„ ์„ธ์ค„ ์ถ”๊ฐ€ํ•จ! 4. Property ์ •๋ณด ์ถ”๊ฐ€ํ•ด์ฃผ๊ธฐ ์•ฑ์˜ ๊ธฐ๋ณธ์„ค์ •์„ ๋‹ด๋‹นํ•˜๋Š” Info.plist ํŒŒ์ผ์— Property ๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค. (.plist๋Š” property list์˜ ์ค„์ž„๋ง์ด๊ณ  property list ํŒŒ์ผ์˜ ํ™•์žฅ์ž๋‹ค) Privacy - Locatio..

[Udemy iOS & Swift Bootcamp] extension

extension ? ๊ธฐ์กด ํด๋ž˜์Šค, ๊ตฌ์กฐ์ฒด, ์—ด๊ฑฐํ˜• ํƒ€์ž…์— ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ. Swift๊ฐ€ ์˜คํ”ˆ์†Œ์Šค๊ฐ€ ์•„๋‹ˆ๋ผ์„œ ๊ธฐ์กด ์†Œ์Šค์ฝ”๋“œ์—์„œ ์ ‘๊ทผํ•˜์ง€ ๋ชปํ•˜๋Š” ํƒ€์ž…๋“ค์„ ํ™•์žฅํ•  ์ˆ˜ ์žˆ๋‹ค. ์ฝ”๋“œ ๊ธฐ๋ณธํ˜• extension someType{ //Add new functionality } ์˜ˆ์‹œ 1) import UIKit var myDouble = 3.14519 let myRoundedDouble = String(format: "%.1f", myDouble) // 3.1 myDouble.round() //3 //myDouble.round(to: 3) //???? round์— to๊ฐ’์„ ๋„ฃ๋Š” ํ•จ์ˆ˜๋Š” ์—†์œผ๋ฏ€๋กœ error๋ฅผ ๋ฐœ์ƒ์‹œํ‚จ๋‹ค. 3.14519 ๋ผ๋Š” ๊ฐ’์„ ๊ฐ€์ง„ myDouble ๋ณ€์ˆ˜๊ฐ€ ์žˆ๋‹ค. ์ด ๊ฑธ String ํ•จ์ˆ˜๋ฅผ ์ด..

[Udemy iOS & Swift Bootcamp] Internal and External Parameter Names

swift ํ•จ์ˆ˜์—์„œ ์•„๋ž˜์ฒ˜๋Ÿผ external, internal ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. func myFunc(External Internal: Type){ print(Internal) } myFunc(External: value) ๊ทธ๋ฆฌ๊ณ  ๋‹ค๋ฅธ ๋ถ€๋ถ„์—์„œ myFunc ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•  ๋•, External ๋ณ€์ˆ˜์— ์–ด๋–ค ๊ฐ’์„ ๋„ฃ์–ด์•ผ ํ•˜๋Š”์ง€ ์œ„์ฒ˜๋Ÿผ ์ •ํ™•ํ•˜๊ฒŒ ๋ช…์‹œํ•ด์•ผ ํ•œ๋‹ค. ์ด ๋•Œ, ์•„๋ž˜์ฒ˜๋Ÿผ _ ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด External ๋ณ€์ˆ˜๋ช…์„ ์•ˆ์ ์–ด๋„ ๋œ๋‹ค. func myFunc(_ Internal: Type){ print(Internal) } myFunc(value) ์‚ด์ง ํ—ท๊ฐˆ๋ฆฌ์ง€๋งŒ ๊ธฐ์–ตํ•ด๋‘์ž!

[Udemy iOS & Swift Bootcamp] Computed Property(์—ฐ์‚ฐ ํ”„๋กœํผํ‹ฐ)

*Computed Property: ๋‹ค๋ฅธ ์†์„ฑ ๊ฐ’์œผ๋กœ ํ•ด๋‹น ์†์„ฑ์˜ ๊ฐ’์„ ์ •์˜ํ•˜๋Š” ๊ฒƒ. ์•„๋ž˜ condition ID ๊ฐ’์œผ๋กœ condition Name์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค. ์ด ๋•Œ, condition Name์„ ๋ฐ˜ํ™˜ํ•˜๋ ค๋ฉด weatherData๋ฅผ ์„ ์–ธ ํ›„ ํ•จ์ˆ˜๋กœ ์ ‘๊ทผํ•ด์•ผํ•  ๊ฒƒ์ด๋‹ค. ์ด ๋ถ€๋ถ„์„ computed Property๋กœ ๋ฐ”๊พธ๋ฉด watherData ์„ ์–ธ ์ฆ‰์‹œ condition Name์˜ ๊ฐ’๋„ ์„ ์–ธ๋˜์–ด ๋ฐ”๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ์ฐธ๊ณ ๋กœ ๊ทธ๋ƒฅ ์„ ์–ธํ•œ conditionId, cityName ๊ฐ™์€ stored Property๋Š” ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์„ ์ฐจ์ง€ํ•˜์ง€๋งŒ, computed Property๋Š” ์ €์žฅ๊ณต๊ฐ„์„ ์ฐจ์ง€ ํ•˜์ง€ ์•Š๋Š”๋‹ค. ๋˜ ๊ณ„์† ๊ฐ’์ด ๋‹ฌ๋ผ์ง€๋ฏ€๋กœ var ํ˜•์œผ๋กœ ์„ ์–ธํ•ด์•ผ ํ•œ๋‹ค. import Foundation struc..

[Udemy iOS & Swift Bootcamp] API ๋กœ Json ๋ฐ์ดํ„ฐ ๋ฐ›์•„์˜ค๊ธฐ. Json Parsing

* Json ์ด๋ž€? : JavaScript Object Notation. ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๊ฐ์ฒด ํ‘œ๊ธฐ๋ฒ•. : JavaScript ๊ฐ์ฒด๋ฅผ ์ „์†กํ•˜๊ธฐ ์‰ฝ๋„๋ก ๊ฐ€๋ณ๊ฒŒ ํ‘œํ˜„ํ•œ ๋ฐฉ๋ฒ•. -> Networking์„ ์œ„ํ•ด ๊ฐ์ฒด๋ฅผ Json์œผ๋กœ ๋ณ€๊ฒฝํ•˜์—ฌ ๋„˜๊ฒจ์•ผ ํ•˜๊ณ , Web์—์„œ ๋ฐ›์•„์˜จ Json ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ์ฒด๋กœ ๋ณ€๊ฒฝํ•˜๋Š” Parse ํ•จ์ˆ˜๊ฐ€ ํ•„์š”ํ•˜๋‹ค. [Json ๋ฐ์ดํ„ฐ] { "coord": { "lon": -0.1257, "lat": 51.5085 }, "weather": [ { "id": 804, "main": "Clouds", "description": "overcast clouds", "icon": "04d" } ], "base": "stations", "main": { "temp": 285.22, "feels_like": 28..

[Udemy iOS & Swift Bootcamp] Closure(ํด๋กœ์ €)

* Closures : ๋žŒ๋‹ค์‹ ๊ฐ™์€๊ณ . : Closure๋Š” named Closure๊ณผ unnamed Closure๊ฐ€ ์žˆ๋‹ค. named Closure๊ฐ€ ์ผ๋ฐ˜ swift ํ•จ์ˆ˜๋ฅผ ๋งํ•˜๊ณ , unnamed Closure๋Š” ์ด๋ฆ„์—†์ด ์‚ฌ์šฉํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๋งํ•œ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ Closure๋ผ๊ณ  ํ•˜๋ฉด unnamed Closure๋ฅผ ๋œปํ•œ๋‹ค. ์•„๋ž˜ completionHandler๋กœ ์‚ฌ์šฉํ•œ handle ํ•จ์ˆ˜๋ฅผ ๋ณด์ž. handle ํ•จ์ˆ˜๋ฅผ func ํ•จ์ˆ˜๋กœ ๋ช…์‹œํ•˜์—ฌ ๋”ฐ๋กœ ์ •์˜ํ•ด์ฃผ์—ˆ๋‹ค. ์ด๋Ÿฐ๊ฑธ named Closure๋ผ๊ณ  ํ•œ๋‹ค. ์ด๊ฑธ Closure(unnamed Closure)๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋œ๋‹ค. ํ•จ์ˆ˜๋ช…์„ ์—†์• ๊ณ  ์ธ์ž๋งŒ ๋‚จ๊ธด ํ›„, in ์•ˆ์— handle ํ•จ์ˆ˜์— ์žˆ๋˜ ๋‚ด์šฉ์„ ์ ์–ด์คฌ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•จ์ˆ˜๋ช… ์—†์ด ์ธ์ž, ๋ฆฌํ„ด, ํ•จ์ˆ˜๋‚ด์šฉ์„..

[Udemy iOS & Swift Bootcamp] Delegate Design Pattern

Delegate Design Pattern? delegate. ํ•œ๊ธ€๋กœ๋Š” ์œ„์ž„์ž๋ผ๋Š” ๋œป์ด๋‹ค. ์ฆ‰, delegate(์œ„์ž„์ž)๋ฅผ ๊ฐ–๊ณ  ์žˆ๋Š” ๊ฐ์ฒด๊ฐ€ ๋‹ค๋ฅธ ๊ฐ์ฒด์—๊ฒŒ ์ž์‹ ์˜ ์ผ์„ ์œ„์ž„ํ•˜๋Š” ํ˜•ํƒœ์˜ ๋””์ž์ธ ํŒจํ„ด์ด๋‹ค. Delegate Design Pattern์˜ ๊ธฐ์›? ์•ž์„œ ๋ฐฐ์šด UITextField ๊ฐ€ ์ˆ˜์ •์„ ์‹œ์ž‘ํ•  ๋•Œ๋ฅผ ํด๋ž˜์Šค์—์„œ ์•Œ๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„ํ•ด์•ผํ• ๊นŒ? ์œ„ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ UITextField ํด๋ž˜์Šค๊ฐ€ ํด๋ž˜์Šค์—๊ฒŒ ์ง์ ‘ ๋ณด๊ณ  ํ•ด์•ผํ•  ๊ฒƒ์ด๋‹ค. ์ด๋ ‡๊ฒŒ ๊ตฌํ˜„ํ•œ๋‹ค ๊ฐ€์ •ํ–ˆ์„ ๋•Œ์˜ ๋ฌธ์ œ์ ์ด ๋งŽ๋‹ค. ๊ฐ€์žฅ ํฐ ๋ฌธ์ œ๋Š” UITextField๋ฅผ ๋งŒ๋“ค ์‹œ์ ์— WeatherViewController์˜ ์กด์žฌ๋ฅผ ๋ชจ๋ฅธ๋‹ค. ์ƒˆ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค ๋•Œ๋งˆ๋‹ค ์ƒˆ UITextField ํด๋ž˜์Šค์—์„œ ๊ณ„์† ์ถ”๊ฐ€ํ•ด์ค˜์•ผ ํ•œ๋‹ค. ์ฆ‰, ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์œผ๋กœ ์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋„๋ก ์–ด๋–ค ..

728x90