diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/.gitignore b/lecture/minsik/mentoring/MentoringWeatherAPI/.gitignore new file mode 100644 index 0000000..5bd0ce0 --- /dev/null +++ b/lecture/minsik/mentoring/MentoringWeatherAPI/.gitignore @@ -0,0 +1,2 @@ +*.xcconfig + diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima.xcodeproj/project.pbxproj b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima.xcodeproj/project.pbxproj index c0b0ed1..89c4dbc 100644 --- a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima.xcodeproj/project.pbxproj +++ b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ A45696542A330A480062BD12 /* WeatherManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherManager.swift; sourceTree = ""; }; A4AD65F82A4AD4390039746B /* WeatherData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherData.swift; sourceTree = ""; }; A4AD65FA2A4C21C50039746B /* WeatherModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherModel.swift; sourceTree = ""; }; + A4BD8A7C2B04BCF70084308A /* Secrets.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Secrets.xcconfig; path = Model/Secrets.xcconfig; sourceTree = ""; }; ADAA27AD231BBFAF00365194 /* Clima.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Clima.app; sourceTree = BUILT_PRODUCTS_DIR; }; ADAA27B0231BBFAF00365194 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; ADAA27B2231BBFAF00365194 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -79,6 +80,7 @@ ADAA27AF231BBFAF00365194 /* Clima */ = { isa = PBXGroup; children = ( + A4BD8A7C2B04BCF70084308A /* Secrets.xcconfig */, ADAA27B0231BBFAF00365194 /* AppDelegate.swift */, ADAA27B2231BBFAF00365194 /* SceneDelegate.swift */, A45696532A330A2E0062BD12 /* Model */, @@ -330,6 +332,7 @@ }; ADAA27C2231BBFB300365194 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = A4BD8A7C2B04BCF70084308A /* Secrets.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Info.plist b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Info.plist index 761d1d7..f6f6e84 100644 --- a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Info.plist +++ b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Info.plist @@ -2,8 +2,8 @@ - NSLocationWhenInUseUsageDescription - We need your location to get the current weather for where you are. + API_KEY + $(API_KEY) CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -22,6 +22,8 @@ 1 LSRequiresIPhoneOS + NSLocationWhenInUseUsageDescription + We need your location to get the current weather for where you are. UIApplicationSceneManifest UIApplicationSupportsMultipleScenes diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/WeatherManager.swift b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/WeatherManager.swift index 54246d9..818bddf 100644 --- a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/WeatherManager.swift +++ b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/WeatherManager.swift @@ -9,13 +9,20 @@ import Foundation import CoreLocation + + protocol WeatherManagerDelegate { func didUpdateWeather(_ weatherManager: Weathermanager, weather: WeatherModel) func didFailWithError(error: Error) } -struct Weathermanager{ - let weatherURL = "https://api.openweathermap.org/data/2.5/weather?appid=ecc3373ffe347304fd4ab1e4bbec05b7&units=metric" +struct Weathermanager { + + private let apikey = Bundle.main.infoDictionary?["API_KEY"] as! String + + var weatherURL: String { + return "https://api.openweathermap.org/data/2.5/weather?units=metric&appid=\(apikey)" + } var delegate: WeatherManagerDelegate?