-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
일기장 [Step3] RedMango, Minsup #141
base: ic_9_redmango
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// WeatherFetcher.swift | ||
// Diary | ||
// | ||
// Created by 김민성 on 2023/09/15. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
struct WeatherFetcher { | ||
let locationManager: LocationManager | ||
|
||
init(locationManager: LocationManager = LocationManager()) { | ||
self.locationManager = locationManager | ||
} | ||
|
||
func fetch(_ completion: @escaping (Data?) -> Void) { | ||
locationManager.fetchSingleLocation { location in | ||
Task { | ||
Comment on lines
+18
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. location을 전달받을 때 꼭 클로저로 전달받아야 하나요? |
||
do { | ||
let weather = try await NetworkManager.fetchCurrentWeather(coordinate: location.coordinate) | ||
|
||
let icon = try await NetworkManager.fetchWeatherIcon(icon: weather?.icon) | ||
completion(icon) | ||
} catch { | ||
completion(nil) | ||
} | ||
Comment on lines
+21
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NetworkManager 내의 fetch~ 메서드들은 throws로 에러를 던지고있는데, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그리고 해당 객체는 |
||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21513" systemVersion="21G651" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> | ||
<entity name="Diary" representedClassName="Diary" syncable="YES" codeGenerationType="class"> | ||
<attribute name="content" optional="YES" attributeType="String"/> | ||
<attribute name="createdDate" optional="YES" attributeType="Date" usesScalarValueType="NO"/> | ||
<attribute name="title" optional="YES" attributeType="String"/> | ||
<attribute name="weatherImage" optional="YES" attributeType="Binary"/> | ||
</entity> | ||
</model> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WeatherFetcher
내에서 현재의 경,위도 정보만 필요한거라면해당 값만 주입받는 방법은 어떨까요?
LocationManager
객체 자체를 들고있기엔 현재 구조체의 기능이나 책임이 조금 모호하게 비대한 느낌이 들어요