반응형
날씨 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": 229.003
},
"sys": {
"pod": "d"
},
"dt_txt": "2018-07-23 03:00:00"
},
날씨 API 호출된 모델 객체를 생성합니다.
#import <Foundation/Foundation.h>
#import "Main.h"
#import "Weather.h"
#import "CloudsModel.h"
#import "WindModel.h"
#import "RainModel.h"
@interface WeatherModel : NSObject
@property (nonatomic,strong) NSString *dt;
@property (nonatomic,strong) Main *main; // 메인 정보
@property (nonatomic,strong) NSArray <Weather*> *weather; // 날씨 정보
@property (nonatomic,strong) CloudsModel *clouds;
@property (nonatomic,strong) WindModel *wind;
@property (nonatomic,strong) RainModel *rain;
//@property (nonatomic,strong) NSString *sys;
@property (nonatomic,strong) NSString *dt_txt; // 날짜
@end
#import <Foundation/Foundation.h>
@interface Main : NSObject
@property (nonatomic,strong) NSString *temp; // 온도
@property (nonatomic,strong) NSString *temp_min;
@property (nonatomic,strong) NSString *temp_max;
@property (nonatomic,strong) NSString *pressure;
@property (nonatomic,strong) NSString *sea_level;
@property (nonatomic,strong) NSString *grnd_level;
@property (nonatomic,strong) NSString *humidity;
@property (nonatomic,strong) NSString *temp_kf;
#import <Foundation/Foundation.h>
@interface Weather : NSObject
@property (nonatomic,strong) id id;
@property (nonatomic,strong) NSString *main; // 날씨 타입
//@property (nonatomic,strong) NSString *description;
@property (nonatomic,strong) NSString *icon; // 아이콘
@end
#import <Foundation/Foundation.h>
@interface WindModel : NSObject
@property (nonatomic,strong) NSString *speed;
@property (nonatomic,strong) NSString *deg;
@end
#import <Foundation/Foundation.h>
@interface CloudsModel : NSObject
@property (nonatomic,strong) NSString *all;
@end
#import <Foundation/Foundation.h>
@interface RainModel : NSObject
@property (nonatomic,strong) NSString *hh;
@end
'Programming > iOS' 카테고리의 다른 글
[iOS 개발팁] 스토리보드 분리하기 (0) | 2020.04.24 |
---|---|
[iOS 강좌] 오픈API 이용한 날씨 APP 만들기 - 5. 도시 정보 변경 (0) | 2020.04.22 |
[iOS 강좌] 오픈API 이용한 날씨 APP 만들기 - 7. CoreLocation (0) | 2020.04.22 |
[iOS 강좌] 오픈API 이용한 날씨 APP 만들기 - 4. open API (0) | 2020.04.22 |
[iOS 강좌] 오픈API 이용한 날씨 APP 만들기 - 3. UIkit Framework (0) | 2020.04.22 |