forked from yagom-academy/ios-diary
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CoreLocation 추가, 위치에 따른 날씨 데이터 fetch 구현
- Loading branch information
Showing
9 changed files
with
132 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ xcuserdata/ | |
*.moved-aside | ||
*.xccheckout | ||
*.xcscmblueprint | ||
Key.plist | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// NetworkConfiguration.swift | ||
// Diary | ||
// | ||
// Created by Maxhyunm, Hamg on 2023/09/13. | ||
// | ||
|
||
import Foundation | ||
|
||
enum NetworkConfiguration { | ||
case weatherAPI(latitude: Double, longitude: Double) | ||
case weatherIcon(id: String) | ||
|
||
var url: String? { | ||
switch self { | ||
case .weatherAPI(let latitude, let longitude): | ||
guard let apiKey = NetworkConfiguration.apiKey else { return nil } | ||
return "https://api.openweathermap.org/data/2.5/weather?lat=\(latitude)&lon=\(longitude)&appid=\(apiKey)" | ||
case .weatherIcon(let id): | ||
return "https://openweathermap.org/img/wn/\(id).png" | ||
} | ||
} | ||
|
||
static var apiKey: String? { | ||
guard let path = Bundle.main.url(forResource: "Key", withExtension: "plist"), | ||
let plist = NSDictionary(contentsOf: path), | ||
let key = plist.value(forKey: "WeatherAPIKey") else { | ||
return nil | ||
} | ||
return "\(key)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>WeatherAPIKey</key> | ||
<string>aaa5700cbd82d1a09e738731002f97be</string> | ||
</dict> | ||
</plist> |