[iOS 강좌] 오픈API 이용한 날씨 APP 만들기 - 5. 도시 정보 변경

제공하는 날씨 API에서 도시 정보를 획득하려면, 별도로 citi 정보를 받기 위해 API를 호출해야합니다. 아래의 json파일을 아마존 s3 저장소에 저장하고, 호출을 하였습니다. https://s3.ap-northeast-2.amazonaws.com/com.ios/city.list.json Citi정보에 대한 모델 객체를 생성하고,  #import <Foundation/Foundation.h> #import "Coord.h" @interface City : NSObject @property ( nonatomic , strong ) id id ; @property ( nonatomic , strong ) Coord *coord; @property ( nonatomic , strong ) NSString *country; @property ( nonatomic , strong ) NSString *name; @end AFKNetwork를 이용하여 호출을 합니다.   AFHTTPSessionManager *manager = [ AFHTTPSessionManager manager ];          [manager GET :url parameters :parameters progress : nil success :^( NSURLSessionTask *task, id responseObject) {         //         NSLog(@"JSON: %@", responseObject);         [ self resCityCode :responseObject];     } failure :^( NSURLSessionTask *operation, NSError *error) {         NSLog ( @"Error: %@" , error

[iOS 강좌] 오픈API 이용한 날씨 APP 만들기 - 6. 모델 객체

날씨 API 호출된 모델 객체를 생성합니다. {             "dt": 1532314800,             "main": {                 "temp": 308.77,                 "temp_min": 305.287,                 "temp_max": 308.77,                 "pressure": 1002.18,                 "sea_level": 1023.05,                 "grnd_level": 1002.18,                 "humidity": 67,                 "temp_kf": 3.48             },             "weather": [                 {                     "id": 801,                     "main": "Clouds",                     "description": "few clouds",                     "icon": "02d"                 }             ],             "clouds": {                 "all": 20             },             "wind": {                 "speed": 1.47,                 "deg&quo

[iOS 강좌] 오픈API 이용한 날씨 APP 만들기 - 7. CoreLocation

내위치를 기반으로 날씨 정보를 가져올수 있습니다. // 코어 로케이션 #import < CoreLocation / CoreLocation.h > // 변수 @property ( nonatomic , strong ) CLLocationManager * locationManager ; // Location Manager 생성 self . locationManager = [[ CLLocationManager alloc ] init ];      // Location Receiver 콜백에 대한 delegate 설정 self . locationManager . delegate = self ; // 델리게이트 < CLLocationManagerDelegate > // longitude, latitude 값 가져옴 - ( void ) locationManager :( CLLocationManager *)manager didUpdateLocations :( NSArray *)locations{    CLLocation * currentLocation = [locations lastObject ];     currentLocation. coordinate . longitude     currentLocation. coordinate . latitude } 사용권한을 확인 후 코어 로케이션을 시작합니다.   // 사용권한 확인 , 사용권한이 켜있을 경우 코어 로케이션 START CLAuthorizationStatus status = [ CLLocationManager authorizationStatus ];     if (status == kCLAuthorizationStatusAuthorizedWhenInUse || status == kCLAuthorizationStatusDenied ) {           

[iOS 강좌] 오픈API 이용한 날씨 APP 만들기 - 4. open API

날씨 API를 이용하기 위해, 아래의 사이트에서 회원가입 후 key를 발급 받습니다. • https://openweathermap.org/ • 날씨 오픈 API . 회원가입 후 API   Key 발급 ( 무료 ) 여러 API 중 5일 3시간 단위의 API를 사용합니다. 도시명과, APP ID, 발급받은 Key로 API를 호출합니다. • API > 5 day / 3 hour forecast > API DOC • 도시명으로 날씨 검색 (3 시간 단위 , 5 일치 )   api.openweathermap.org /data/2.5/ forecast? id =524901&APPID= 발급받은 API Key 호출방법은 AFKNetwork 오픈소스를 이용 하여, get 방식으로 간단하게 호출할수 있습니다. NSDictionary * parameters = @{                          @"id" : @"1835848" ,                          @"APPID" : @"f18379cb9ed5dff3d62ad51bab87ba8a" ,                          } ; [ self reqWeatherApi : @"https:// api.openweathermap.org /data/2.5/forecast?" parameters :dic ]; -( void ) reqWeatherApi :( NSString *) url parameters:( NSDictionary *)parameters{     AFHTTPSessionManager *manager = [ AFHTTPSessionManager manager ];     [manager GET :url parameters :parameters