From 18725b6606fef141e334b944455ab67c37733eb8 Mon Sep 17 00:00:00 2001 From: Max Hyun <73330542+maxhyunm@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:14:55 +0900 Subject: [PATCH] docs: Update README.md --- README.md | 136 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 113 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index fe527d61b..d87fff162 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ๐Ÿ“” ์ผ๊ธฐ์žฅ -ํ”„๋กœ์ ํŠธ ๊ธฐ๊ฐ„: 2023.8.28 ~ +ํ”„๋กœ์ ํŠธ ๊ธฐ๊ฐ„: 2023.8.28 ~ 2023.9.15 ## ๐Ÿ“– ๋ชฉ์ฐจ 1. [๐Ÿ€ ์†Œ๊ฐœ](#1.) @@ -38,7 +38,10 @@ |2023.09.01| `CoreData`: `Create` ๊ตฌํ˜„| |2023.09.05| `CoreData`: `UpDate`, `Delete` ๊ตฌํ˜„
`Swipe` `share`, `delete` ๊ตฌํ˜„
`AlertController` ์ƒ์„ฑ | |2023.09.06| `CoreData`: `fetchDiary` ๊ตฌํ˜„ | -|2023.09.07| ๊ฐœ์ธ ํ•™์Šต ๋ฐ README ์ž‘์„ฑ | +|2023.09.07| ๊ฐœ์ธ ํ•™์Šต ๋ฐ `README` ์ž‘์„ฑ | +|2023.09.10| `CoreDataError` ์ƒ์„ฑ, ์˜ˆ์™ธ์ฒ˜๋ฆฌ ์ถ”๊ฐ€
`AlertVC`๋กœ์ง์ˆ˜์ •, `Namespace`์ƒ์„ฑ | +|2023.09.13| `WeatherAPI`ํ†ต์‹  ์ง„ํ–‰
`WeatherIcon Cache` ๊ตฌํ˜„
`CoreLocation` ์ƒ์„ฑ
`Migration-DiaryV2` ๊ตฌํ˜„ | +
@@ -48,22 +51,33 @@ โ”œโ”€โ”€ Diary โ”‚ย ย  โ”œโ”€โ”€ Protocol โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ AlertDisplayble.swift - โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ShareDiary.swift - โ”‚ย ย  โ”œโ”€โ”€ DataManager - โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ CoreDataManager.swift + โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ShareDisplayable.swift โ”‚ย ย  โ”œโ”€โ”€ Extension โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ DateFormatter+.swift - โ”‚ย ย  โ”œโ”€โ”€ Model - โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Diary+CoreDataClass.swift - โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Diary+CoreDataProperties.swift - โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ DecodingManager.swift - โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ DiaryEntity.swift โ”‚ย ย  โ”œโ”€โ”€ Error + โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ APIError.swift + โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ CoreDataError.swift โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ DecodingError.swift + โ”‚ย ย  โ”œโ”€โ”€ Model + โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ CoreData + โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ CoreDataManager.swift + โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Diary+CoreDataClass.swift + โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Diary+CoreDataProperties.swift + โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ DTO + โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ DecodingManager.swift + โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ WeatherResult.swift + โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ ImageCache + โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ImageCachingManager.swift + โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Namespace + โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ AlertNamespace.swift + โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ButtonNamespace.swift + โ”‚ย ย  โ”œโ”€โ”€ Network + โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ NetworkConfiguration.swift + โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ NetworkManager.swift โ”‚ย ย  โ”œโ”€โ”€ Controller - โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ CreateDiaryViewController.swift + โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ DiaryDetailViewController.swift โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ DiaryListViewController.swift - โ”‚ย ย  โ”œโ”€โ”€ View + โ”‚ย ย  โ”œโ”€โ”€ View โ”‚ย ย  โ”‚ โ””โ”€โ”€ DiaryListTableViewCell.swift โ”‚ย ย  โ”œโ”€โ”€ App โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ AppDelegate.swift @@ -71,16 +85,17 @@ โ”‚ย ย  โ”œโ”€โ”€ Assets.xcassets โ”‚ย ย  โ”œโ”€โ”€ Info.plist โ”‚ย ย  โ””โ”€โ”€ Diary.xcdatamodeld - โ””โ”€โ”€ Diary.xcodeproj + โ”œโ”€โ”€ Diary.xcodeproj + โ””โ”€โ”€ README.md

## ๐Ÿ’ป ์‹คํ–‰ ํ™”๋ฉด -|์ž‘๋™ ํ™”๋ฉด| +| ์ž‘๋™ํ™”๋ฉด | |:--:| -|| +||
@@ -88,6 +103,8 @@ ## ๐Ÿช„ ํ•ต์‹ฌ ๊ฒฝํ—˜ #### ๐ŸŒŸ CoreData๋ฅผ ํ™œ์šฉํ•œ ๋ฐ์ดํ„ฐ ์ €์žฅ ์ผ๊ธฐ ๋ฐ์ดํ„ฐ๋ฅผ ์œ„ํ•œ ์ €์žฅ์†Œ๋กœ CoreData๋ฅผ ํ™œ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค. +#### ๐ŸŒŸ MappingModel ํŒŒ์ผ์„ ํ™œ์šฉํ•œ CoreData Migration ์ง„ํ–‰ +CoreData์˜ ๋ฒ„์ „ ์ •๋ณด๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์ด๋ฅผ MappingModel๋กœ ์—ฐ๊ฒฐํ•˜์—ฌ DB ๋ณ€๊ฒฝ์‚ฌํ•ญ์— ๋Œ€ํ•œ Migration์„ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค. #### ๐ŸŒŸ Singleton ํŒจํ„ด์„ ํ™œ์šฉํ•œ CoreDataManager ๊ตฌํ˜„ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๋กœ์ง ์ „๋ฐ˜์„ Singleton ํŒจํ„ด์œผ๋กœ ๊ตฌํ˜„ํ•˜์—ฌ ์•ฑ ์ „์—ญ์—์„œ ํ™œ์šฉ ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค. #### ๐ŸŒŸ NotificationCenter๋ฅผ ํ™œ์šฉํ•œ ํ‚ค๋ณด๋“œ ์ธ์‹ @@ -96,6 +113,8 @@ ์ƒํ™ฉ์— ๋”ฐ๋ผ ViewController์—์„œ ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ๋ฅผ ํ‘œ์‹œํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ์— ๋Œ€๋น„ํ•ด ์ƒ์„ฑ์ž๋ฅผ ํ™œ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค. #### ๐ŸŒŸ Protocol๊ณผ Extension์„ ํ™œ์šฉํ•œ ์ฝ”๋“œ ๋ถ„๋ฆฌ Alert, Swipe ๋“ฑ ๋ณ„๊ฐœ์˜ ์ž‘์—…์œผ๋กœ ๋ถ„๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ๋‚ด์šฉ๋“ค์€ Protocol๊ณผ Extension์„ ํ†ตํ•ด ๋ถ„๋ฆฌํ•˜์˜€์Šต๋‹ˆ๋‹ค. +#### ๐ŸŒŸ URLSessionDataTask๋ฅผ ํ™œ์šฉํ•œ NetworkManager ๊ตฌํ˜„ +ํ•˜๋‚˜์˜ NetworkManager ํƒ€์ž…์„ ๊ตฌํ˜„ํ•˜์—ฌ ๋‚ ์”จ API ๋ฐ์ดํ„ฐ ํ†ต์‹ ๊ณผ ์•„์ด์ฝ˜ ์ด๋ฏธ์ง€ ๊ด€๋ จ ํ†ต์‹ ์— ๋ชจ๋‘ ํ™œ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.
@@ -212,16 +231,87 @@ fetchํ•ด ์˜จ ์ผ๊ธฐ๋“ค ์ค‘์— title์ด ๋น„์–ด์žˆ๋Š” ๊ฑด์€ ๊ฑธ๋Ÿฌ๋‚ผ ์ˆ˜ ์žˆ๋„ } } ``` +

+ +### 4๏ธโƒฃ **์•„์ด์ฝ˜ ์ด๋ฏธ์ง€ ํ†ต์‹ ** +๐Ÿ”’ **๋ฌธ์ œ์ **
+์ผ๊ธฐ์žฅ ์•ฑ์€ ๋ชจ๋“  ์…€์ด ์„œ๋ฒ„ํ†ต์‹ ์„ ํ†ตํ•ด ์•„์ด์ฝ˜์„ ๊ฐ€์ง€๊ณ  ์˜ค๋„๋ก ๊ตฌํ˜„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋‚ ์”จ ์•„์ด์ฝ˜์€ ๋ช‡ ๊ฐœ์˜ ์ •ํ•ด์ง„ ์•„์ด์ฝ˜์„ ๋ฐ˜๋ณตํ•˜์—ฌ ํ™œ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋™์ผํ•œ ์ด๋ฏธ์ง€๋ฅผ ๋งค๋ฒˆ ํ†ต์‹ ์„ ํ†ตํ•ด ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์€ ๋น„ํšจ์œจ์ ์ด๋ผ๊ณ  ์ƒ๊ฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. +

+ +๐Ÿ”‘ **ํ•ด๊ฒฐ๋ฐฉ๋ฒ•**
+ํ•œ ๋ฒˆ ํ™œ์šฉ๋œ ์ด๋ฏธ์ง€๋Š” `NSCache`๋ฅผ ํ†ตํ•ด ์บ์‹ฑ ์ฒ˜๋ฆฌํ•˜์—ฌ ๋ฐ”๋กœ ๋ณด์—ฌ์ค„ ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค. + +```swift +class ImageCachingManager { + static let shared = NSCache() + ... +} +``` + +```swift +guard let image = UIImage(data: data) else { return } +DispatchQueue.main.async { + ImageCachingManager.shared.setObject(image, forKey: NSString(string: icon)) + self?.weatherIconImageView.image = image +} +``` +

+ +### 5๏ธโƒฃ **CoreLocation** +๐Ÿ”’ **๋ฌธ์ œ์  (1) - CoreLocation์„ ํ†ตํ•ด ์ •๋ณด๋ฅผ ๋ฐ›์•„์˜ค๋Š” ์œ„์น˜**
+ +์‹ค์งˆ์ ์œผ๋กœ Location ์ •๋ณด๊ฐ€ ํ•„์š”ํ•œ ๊ฒƒ์€ `DiaryDetailViewController`์—์„œ ๋‚ ์”จ API๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ์ž…๋‹ˆ๋‹ค. ๋•Œ๋ฌธ์— ์ฒ˜์Œ์—๋Š” `DiaryDetailViewController`์—์„œ ํ™œ์šฉ ๋™์˜๋ฅผ ๋ฐ›๊ณ  ์œ„์น˜ ์ •๋ณด๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๋„๋ก ๊ตฌํ˜„ํ•˜๋ ค ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์•ฑ์„ ์‹คํ–‰ํ•œ ๋’ค ์ผ๊ธฐ์žฅ ์ƒ์„ฑ ํ™”๋ฉด์— ๋„˜์–ด๊ฐ€์„œ์•ผ ์œ„์น˜์ •๋ณด ํ™œ์šฉ ๋™์˜ ์ฐฝ์ด ํ™œ์„ฑํ™”๋˜์–ด ํ๋ฆ„์ƒ ์–ด์ƒ‰ํ•ด์ง€๊ณ , ๋˜ ์œ„์น˜ ์ •๋ณด๊ฐ€ ์ œ๋•Œ ์—…๋ฐ์ดํŠธ๋˜์ง€ ์•Š์•„ API ํ˜ธ์ถœ์ด ์ด๋ฃจ์–ด์ง€์ง€ ์•Š๋Š” ๋“ฑ ๋‹ค์–‘ํ•œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. +

+ +๐Ÿ”‘ **ํ•ด๊ฒฐ๋ฐฉ๋ฒ• (1)**
+์œ„์น˜ ์ •๋ณด ์—…๋ฐ์ดํŠธ ์ž์ฒด๋Š” ์ฒซ ํ™”๋ฉด์ธ `DiaryListViewController`์—์„œ ์ง„ํ–‰ํ•˜๊ณ , `DiaryDetailViewController`์—์„œ๋Š” API ํ†ต์‹ ์— ํ•„์š”ํ•œ ์œ„๋„, ๊ฒฝ๋„ ๋ฐ์ดํ„ฐ๋งŒ ๋„˜๊ฒจ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค. +```swift +let createDiaryView = DiaryDetailViewController(latitude: self.latitude, longitude: self.longitude) +self.navigationController?.pushViewController(createDiaryView, animated: true) +``` + +๋˜ํ•œ ์œ„์น˜์ •๋ณด ํ™œ์šฉ์— ๋™์˜ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ์—๋„ ์ผ๊ธฐ ์ž์ฒด๋Š” ์ž‘์„ฑ ๊ฐ€๋Šฅํ•˜๋„๋ก ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด(๋‚ ์”จ ์ด๋ชจํ‹ฐ์ฝ˜๋งŒ ์ œ์™ธ) ์œ„๋„, ๊ฒฝ๋„ ๋ฐ์ดํ„ฐ๋Š” nil๋กœ๋„ ์ „๋‹ฌ๋  ์ˆ˜ ์žˆ๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค. + +```swift +init(latitude: Double?, longitude: Double?) { + self.diary = CoreDataManager.shared.createDiary() + self.isNew = true + self.latitude = latitude + self.longitude = longitude + + super.init(nibName: nil, bundle: nil) + fetchWeather() +} +``` +

+ +๐Ÿ”’ **๋ฌธ์ œ์  (2) - ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ์˜ ์œ„์น˜ ์ •๋ณด ์„ค์ •**
+ +์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ๋กœ `CoreLocation` ๊ธฐ๋Šฅ์„ ํ…Œ์ŠคํŠธํ•˜๋ฉด ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ ์ž์ฒด์— ์„ค์ •๋œ Location ์ •๋ณด์— ๋”ฐ๋ผ ์œ„์น˜๋ฅผ ํ‘œ์‹œํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด ์„ค์ •์ด None์œผ๋กœ ๋˜์–ด์žˆ์„ ๊ฒฝ์šฐ์—๋Š” ์œ„์น˜๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋ถˆ๋Ÿฌ์™€์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด ์‚ฌ์‹ค์„ ๊ฐ„๊ณผํ•˜์—ฌ ํ…Œ์ŠคํŠธ ๊ณผ์ •์—์„œ ๋งŽ์€ ์‹œํ–‰์ฐฉ์˜ค๋ฅผ ๊ฑฐ์ณค์Šต๋‹ˆ๋‹ค. +

+ +๐Ÿ”‘ **ํ•ด๊ฒฐ๋ฐฉ๋ฒ• (2)**
+ +Custom Location์„ ํ™œ์šฉํ•˜์—ฌ ์ •์ƒ์ ์œผ๋กœ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
+
+
## ๐Ÿ“š ์ฐธ๊ณ  ๋งํฌ -- [Apple Developer Documentation: Adaptivity and Layout](https://developer.apple.com/design/human-interface-guidelines/layout) -- [Apple Developer Documentation: DateFormatter](https://developer.apple.com/documentation/foundation/dateformatter) -- [Apple Developer Documentation: UITextView](https://developer.apple.com/documentation/uikit/uitextview) -- [Apple Developer Documentation: Core Data](https://developer.apple.com/documentation/coredata) -- [Apple Developer Documentation: Making Apps with Core Data](https://developer.apple.com/videos/play/wwdc2019/230/) -- [Apple Developer Documentation: NSFetchedResultsController](https://developer.apple.com/documentation/coredata/nsfetchedresultscontroller) -- [Apple Developer Documentation: UITextViewDelegate](https://developer.apple.com/documentation/uikit/uitextviewdelegate) -- [Apple Developer Documentation: UISwipeActionsConfiguration](https://developer.apple.com/documentation/uikit/uiswipeactionsconfiguration) + +- [Apple Docs: Adaptivity and Layout](https://developer.apple.com/design/human-interface-guidelines/layout) +- [Apple Docs: DateFormatter](https://developer.apple.com/documentation/foundation/dateformatter) +- [Apple Docs: UITextView](https://developer.apple.com/documentation/uikit/uitextview) +- [Apple Docs: Core Data](https://developer.apple.com/documentation/coredata) +- [Apple Docs: Making Apps with Core Data](https://developer.apple.com/videos/play/wwdc2019/230/) +- [Apple Docs: NSFetchedResultsController](https://developer.apple.com/documentation/coredata/nsfetchedresultscontroller) +- [Apple Docs: UITextViewDelegate](https://developer.apple.com/documentation/uikit/uitextviewdelegate) +- [Apple Docs: UISwipeActionsConfiguration](https://developer.apple.com/documentation/uikit/uiswipeactionsconfiguration) +- [Apple Docs: CoreLocation](https://developer.apple.com/documentation/corelocation) +- [Apple Docs: Migrating your data model automatically](https://developer.apple.com/documentation/coredata/migrating_your_data_model_automatically) +- [Apple Docs: NSCache](https://openweathermap.org/current) +- [Open Weather API](https://openweathermap.org/current) +
+