Skip to content

PR_forCodeReview_week4#5

Open
leewoojye wants to merge 3 commits into
mainfrom
week4
Open

PR_forCodeReview_week4#5
leewoojye wants to merge 3 commits into
mainfrom
week4

Conversation

@leewoojye
Copy link
Copy Markdown
Collaborator

โญ๏ธ 4์ฃผ์ฐจ ๊ณผ์ œ ํ•ต์‹ฌ ํฌ์ธํŠธ โญ๏ธ

  • ๊ธฐ๋ณธ&์‹ฌํ™”๊ณผ์ œ ๋ชจ๋‘ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค! ๋‚ ์”จ์ƒ์„ธ๋ทฐ์—์„œ ์‹œ๊ฐ„๋Œ€๋ณ„ ๋‚ ์”จ๋Š” 3์‹œ๊ฐ„ ๋‹จ์œ„๋กœ ๋‚ ์”จ๋ฅผ ์ œ๊ณตํ•˜๋Š” API๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. (Hourly forecast API๊ฐ€ ์œ ๋ฃŒ์ธ ๊ด€๊ณ„๋กœ...)
  • ์„œ๋ฒ„์—์„œ ์›ํ•˜๋Š” ๋‚ ์”จ์ •๋ณด๋ฅผ API ํ˜ธ์ถœ์„ ํ†ตํ•ด ๊ฐ€์ ธ์˜ค๊ธฐ
  • ์„œ๋ฒ„์—์„œ ๋ฐ›์•„์˜จ JSON ๊ฐ์ฒด๋ฅผ ๊ตฌ์กฐ์ฒด๋กœ ๋ณ€ํ™˜ํ•˜๊ณ , ํ•ด๋‹น ๊ตฌ์กฐ์ฒด์—์„œ ์‚ฌ์šฉํ•  ์ •๋ณด๋งŒ์„ ๋˜ ์ถ”์ถœํ•˜๊ธฐ
  • JSON์—์„œ ๋ฐ›์•„์˜จ ๋ฐ์ดํ„ฐ๋“ค์„ ๊ตฌ์กฐ์ฒด.swift ํŒŒ์ผ์„ ํ†ตํ•ด ์›ํ•˜๋Š” ๋ฐ์ดํ„ฐ ํฌ๋งท์œผ๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ
  • ํ™ˆํ™”๋ฉด ํ…Œ์ด๋ธ”๋ทฐ ์…€ ๊ฒน์นฉ ํ˜„์ƒ ํ•ด๊ฒฐ
  • ๋‚ ์”จ์ƒ์„ธ๋ทฐ์˜ 10์ผ๊ฐ„ ์ผ๊ธฐ์˜ˆ๋ณด์—๋Š” API๊ฐ€ ๋ฐ˜์˜๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

๐Ÿ”จ ๊ตฌํ˜„ ๋ฐฉ์•ˆ ๊ฐœ์š” ๐Ÿ”จ

  • JSON -> ๊ตฌ์กฐ์ฒด ๋ณ€ํ™˜์€ quicktype.io๋ฅผ ํ†ตํ•ด ๋ณ€ํ™˜ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • JSON ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜ค๋Š” ๊ฒƒ๊ณผ ๋ณ„๊ฐœ๋กœ, ItemListData, ImageCollectionData ์Šค์œ„ํ”„ํŠธ ํŒŒ์ผ์—์„œ ์•ฑ์— ํ•„์š”ํ•œ ํ˜•ํƒœ์˜ ์ •๋ณด๋กœ ๊ฐ€๊ณตํ•˜๋Š” ๊ณผ์ •์„ ๊ฑฐ์ณค์Šต๋‹ˆ๋‹ค.

๐Ÿ“ ํ•ต์‹ฌ ์ฝ”๋“œ ์„ค๋ช… ๐Ÿ“

SecondViewController.swift

    private func fetchWeatherInfo() async {
        let city = self.Location
        imageCollectionList = [] // append๋ฅผ ์“ฐ๊ธฐ ๋•Œ๋ฌธ์— ๋ฐฐ์—ด ์ดˆ๊ธฐํ™”ํ•ด์ค˜์•ผํ•จ
        
        for i in 0...11 {
            do {
                guard let currentWeather = try await GetTimeline.shared.GetTimelineData(cityname: city) else {return}
                let weatherInfo = ImageCollectionData(time: currentWeather.list[i].dtTxt, weather: currentWeather.list[i].weather[0].main.rawValue, temperature: currentWeather.list[i].main.temp)
                
                imageCollectionList.append(weatherInfo)
            } catch {
                print(error)
            }
        }
        
        do {
            guard let currentWeather = try await GetTimeline.shared.GetTimelineData(cityname: city) else {return}
            guard let time = extractHour(from: currentWeather.list[0].dtTxt) else {return}
            self.descriptionView.text = "\(String(describing: time))์— \(self.Weather) ์ƒํƒœ๊ฐ€ ์˜ˆ์ƒ๋ฉ๋‹ˆ๋‹ค."
        } catch {
            print(error)
        }
        collectionview.reloadData()
    }

do-catch ๋ฌธ์„ ๋‘ ๋ฒˆ ์ด์šฉํ•˜์—ฌ ํ•œ ๋ฒˆ์€ ์‹œ๊ฐ„๋Œ€๋ณ„ ๋‚ ์”จ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐฐ์—ด์— ๋„ฃ์–ด์ฃผ๊ณ , ๋‹ค๋ฅธ ํ•œ ๋ฒˆ์€ ํ˜„์žฌ์˜ ๋‚ ์”จ๋ฅผ ๋ผ๋ฒจ๋กœ ํ‘œํ˜„ํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค. ํ™ˆํ™”๋ฉด์˜ ํ…Œ์ด๋ธ”๋ทฐ์™€ ๋‹ฌ๋ฆฌ ์‹œ๊ฐ„๋Œ€๋ณ„ ๋‚ ์”จ์— ์‚ฌ์šฉ๋œ ์ฝœ๋ ‰์…˜๋ทฐ์—๋Š” ์ดˆ๋ฐ˜์— ๋ฐฐ์—ด ์ดˆ๊ธฐํ™”๋ฅผ ์ง„ํ–‰ํ•˜์—ฌ ๋‹ค๋ฅธ ์žฅ์†Œ์˜ ๋‚ ์”จ๋ฐ์ดํ„ฐ๊ฐ€ ๋ˆ„์ ๋˜๋Š” ํ˜„์ƒ์„ ๋ฐฉ์ง€ํ–ˆ์Šต๋‹ˆ๋‹ค.
๋˜ ์‹œ๊ฐ„๋Œ€๋ณ„ ๋‚ ์”จ ์•„์ด์ฝ˜์˜ ๊ฒฝ์šฐ 3-hourly API์—์„œ ์ œ๊ณต๋œ ๋‚ ์”จ enum, ์ฆ‰ Clear, Clouds, Snow, Rain ๋‚ ์”จ๋ฅผ ๋„ค ์ข…๋ฅ˜๋กœ ๊ฐ„๋žตํ™” ํ•œ ๋’ค ๊ธฐ์ƒ ์•„์ด์ฝ˜๊ณผ ๋งค์นญํ•ด ์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค.

@leewoojye leewoojye self-assigned this Nov 17, 2023
@leewoojye leewoojye changed the title Create README.md PR_forCodeReview_week4 Nov 17, 2023
Copy link
Copy Markdown
Member

@mini-min mini-min left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์˜ค ํ’€๋ฆฌํ€˜ ์„ค๋ช…๋œ ํŒŒ์ผ ์–ด๋””์žˆ๋Š”์ง€ ์•Œ๋ ค์ฃผ์‹œ๋ฉด ์ œ๊ฐ€ ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋‹ฌ๋Ÿฌ๊ฐ€๊ฒ ์Šต๋‹ˆ๋‹ค ^___^

@ena-isme
Copy link
Copy Markdown

์šฐ์™• ์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค! ํŒŒ์ผ์ด ์•„์ง ์•ˆ์˜ฌ๋ผ์˜จ ๊ฒƒ ๊ฐ™์•„์šฉ !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants