๋คํธ์ํฌ ํต์
Open API ๋ชฉ๋ก
- ๊ณต๊ณต ๋ฐ์ดํฐ ํฌํธ https://www.data.go.kr/
- ๋ค์ด๋ฒ ๊ฐ๋ฐ์ ์ผํฐ https://developers.naver.com/main/
- ์นด์นด์ค ๊ฐ๋ฐ์ ์ผํฐ https://developers.kakao.com/
- TMDB ์ํ https://developer.themoviedb.org/reference/intro/getting-started
- Unsplash ์ด๋ฏธ์ง https://unsplash.com/developers
- Giphy ์ ๋๋ฉ์ด์ ๋ฐ Gif https://developers.giphy.com/
- ๋ ์จ https://openweathermap.org/
- ์ํ์งํฅ์์ํ ๋ฐ์ค์คํผ์ค https://www.kobis.or.kr/kobisopenapi/homepg/main/main.do
- ๋ก๋ ๋น์ฒจ ๋ฒํธ ์กฐํ https://www.dhlottery.co.kr/common.do?method=getLottoNumber&drwNo=1079
- ๋งฅ์ฃผ ๊ฒ์ https://punkapi.com/documentation/v2
- JSON Viewer Pro (Chrome) https://chrome.google.com/webstore/detail/json-viewer-pro/eifflpmocdbdmepbjaopkkhbfmdgijcc
- Insomnia https://insomnia.rest/download
Get
๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ
POST
์๋ก์ด ์ฝํ ์ธ ๋ณด๋ผ๋ (ex. ์๋ก์ด ์คํ ๋ฆฌ ์์ฑํด์ ๋ณด๋)
PUT
๊ธฐ์กด ์ฝํ ์ธ ์์ ( ex. ์์ฑํ๋ ์คํ ๋ฆฌ ํ ์คํธ ๋ด์ฉ ์์ ํจ)
DELETE
๊ธฐ์กด ์ฝํ ์ธ ์ญ์ (ex.์คํ ๋ฆฌ ์ญ์ )
๋ฐ์ดํฐ๋ฉ - SERVICE-API
๋ฐ์ดํฐ๋ฉ ํตํฉ๊ฒ์์ด ํธ๋ ๋ ํตํฉ๊ฒ์์ด ํธ๋ ๋๋ ๋ค์ด๋ฒ ํตํฉ๊ฒ์์์ ๋ฐ์ํ๋ ๊ฒ์์ด๋ฅผ ์ฐ๋ น๋ณ, ์ฑ๋ณ, ๊ธฐ๊ธฐ๋ณ(PC, ๋ชจ๋ฐ์ผ)๋ก ์ธ๋ถํํด์ ์กฐํํ ์ ์๋ API์ ๋๋ค. ๋ถ์ํ๊ณ ์ถ์ ์ฃผ์ ๊ตฐ์
developers.naver.com
๊ฒ์ > ๋ธ๋ก๊ทธ - Search API
๊ฒ์ > ๋ธ๋ก๊ทธ ๋ธ๋ก๊ทธ ๊ฒ์ ๊ฐ์ ๊ฐ์ ๊ฒ์ API์ ๋ธ๋ก๊ทธ ๊ฒ์ ๊ฐ์ ๊ฒ์ API๋ ๋ค์ด๋ฒ ๊ฒ์ ๊ฒฐ๊ณผ๋ฅผ ๋ด์ค, ๋ฐฑ๊ณผ์ฌ์ , ๋ธ๋ก๊ทธ, ์ผํ, ์ํ, ์น ๋ฌธ์, ์ ๋ฌธ์ ๋ณด, ์ง์iN, ์ฑ , ์นดํ๊ธ ๋ฑ ๋ถ์ผ๋ณ๋ก ๋ณผ ์
developers.naver.com
API(Application Programming Interface)
์ฑ → ์๋ฒ : Request(HTTP Method) & ์ธ์ฆํค
์๋ฒ → ์ฑ : Response
Response
xml๋ฐฉ์(์น์นํ) or json ๋ฐฉ์
xml
json
- iOS๋ json์ ๋ ๋ง์ด ์
SwifyJson & Alamofire ์ค์ต
SwifyJson & Alamofire ํจํค์ง ์ถ๊ฐ
https://github.com/SwiftyJSON/SwiftyJSON
json๊ด๋ฆฌ ํธํ๊ฒ ํด์ฃผ๋ ๊ฒ
Alamofire.request(url, method: .get).validate().responseJSON { response in
switch response.result {
case .success(let value):
let json = JSON(value)
print("JSON: \(json)")
case .failure(let error):
print(error)
}
}
url : https://www.dhlottery.co.kr/common.do?method=getLottoNumber&drwNo=1079
let json = JSON(value)
→ SwiftyJson ํตํด์ ๋งคํ ๋์ด์๋ json ๊ฐ ์ป์ด์ค๋ ๊ฒ
json์ ์๋ ๋ด์ฉ๋ฌผ ๊ฐ์ ธ์ค๋ ๋ฐฉ๋ฒ
self ๋ถ์ฌ์ผ ํจ.
์๋ฒ ํต์ ์ฝ๋ ์์ ์๋ print๋ ๋ฆ๊ฒ ์ถ๋ ฅ ๋จ.
์๋ฒํต์ ํจ์ํ
PickerView
ํ์ฐจ ์ซ์๋ก ํผ์ปค๋ทฐ ๋ฐ์ดํฐ ์ค์
ํผ์ปค๋ทฐ ์ ํํ๋ฉด ํด๋น ์ฐ๋ ์๋ฒํต์
ATS
- http๋ ๋ฌด์กฐ๊ฑด ๋ธ๋ฝ
- https ๋ ๊ธฐ๊ด์์ ๋ณด์์ ๋ํ ์ธ์ฆ์๋ฅผ ๋ฐ์์ผ ๋ฐ์ ์ ์๋ ์ฃผ์
์๋ฒํต์ ์๋๊ณ ์๋ฌ๋จ
๋ชจ๋ url ํ์ฉ
xcode์์ ๋ง๋ค์ด์ง๋ ๋ชจ๋ ํน์ ํ์ผ .gitignore ํ๋ ๋ฒ
ํน์ ํ๋ก์ ํธ์์ ์ํ๋ ํ์ผ .gitignoreํ๋ ๋ฒ
๋ฌด์ํ๊ณ USE “.”
.gitignore์ ์ถ์ ์ํ๊ณ ์ถ์ ํ์ผ์ด๋ฆ(APIKey.swift)์ด๋ฆ ์ถ๊ฐ
APIKey ํ์ผ ์๋ก ์์ฑํ์ด๋ A ์ ๋ธ → ๊น์์ ์ถ์ ์ ํ๋ค๋ ๋ป.
SwiftyJson ์ฌ์ฉ๋ฒ
json ๋ฐ์ดํฐ์ movieNm์ ๊ฐ์ ธ์ค๊ณ ์ถ์.
์ด๋ ๊ฒ ๊ฐ์ ธ์ค๋ฉด ์๋ชป ๊ฐ์ ธ์จ๊ฑฐ๋ผ ๊ณต๋ฐฑ ๋ฐ์ ๋ชป ๊ฐ์ ธ์ด
์๋์ฒ๋ผ json depth ๋ฐ๊นฅ๋ถํฐ ์์ ํ๋ํ๋ ์ ๊ทผํ๋ฉด์ ๊ฐ์ ธ์์ผํจ.
url ์ฃผ์์ ๊ตฌ์กฐ
scheme,host, port, path, querystring
์ฑ ๋ฒ๋ค ์ถ์ถํ๊ธฐ
- ์์ถํ๊ฑฐ ๋ค๋ฅธ ๊ณณ์ ๋นผ๋ด์ ์ ์กํ๋๊ฒ ๊ฐ๋ฅ (buildํ๊ณ ์์ถํด์ผํจ)
- ์ ์ก๋ฐ์ผ๋ฉด ์์ถ ํ์ด์ ์๋ฎฌ๋ ์ดํฐ์ ๋์ด๋ค ๋์ผ๋ฉด ์คํ ๊ฐ๋ฅ
'SeSAC' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[iOS] TIL_230809 (0) | 2023.08.10 |
---|---|
[iOS] TIL_230808 (0) | 2023.08.09 |
[iOS] TIL_230804 (0) | 2023.08.06 |
[iOS] TIL_230803 (0) | 2023.08.06 |
[iOS] TIL_230802 (0) | 2023.08.05 |