Weather app source 분석
특징 1. Yahoo! Weather RSS Feed 사용 2. zip Code 를 이용하여 검색 -> WOEID (Where on Earth Identifier) 를 사용하여 검색하는 방법도 있다. 3. WebView 를 통해 web 의 data 를 가공하지 않고 application content 에 적용시켰다.
Weather app 현재시간 Current Conditions: 상태, 온도 Forecast: 금일 날씨 내일 날씨 Zip Code
Weather - url 접근구현 Main View - 앞 화면구현 Flipside View - 뒷 화면구현 ( 구현되지 않음 ) Application Controllers - Main ( 초기화 ) FlipsideView.xib MainView.xib MainWindow.xib Weather app
*** MainWindow.xib 프로젝트의 주 인터페이스 파일 어플리케이션 실행시 로드되고 그 안에 인터페이스 요소와 클래스의 인스턴스들이 초기화 된다 UIWindow RootViewController 로 구성되어 있고 RootViewController 에는 UIView UIButton 구성되어 있다. Weather app
*** Flipside.xib main view 에서 info 버튼을 누르면 보여지는 뒷면 인터페이스 이곳의 인터페이스는 코드로 작성되어 있어 인터페이스 빌더에는 아무것도 구성하지 않고 클래스 파일에서 직접 구현하였다. Weather app
*** MainView.xib Main View 인터페이스 UIWebView UITextField UIButton 인스턴스로 구성됨 UIWebView 는 웹에 있는 content 를 어플리케이션에 embed 할때 사용한다. UITextField 는 zip Code 를 입력 받기 위해 만들어졌다. Weather app
*** AmuckWeather.h Property 없음 Methods // 해당하는 ZipCode 의 날씨 xml 를 가져온다. +(NSString*)getWeatherXmlForZipCode: (NSString*)zipCode; 메소드 안의 로직부분의 설명은 소스에 주석 표시를 하였음 Weather app
*** Mainview.h – 파일 생성 그대로 되어있음 Property 없음 Methods 없음 *** MainviewController.h Property // 옛날 방식의 코딩법 - 최근에는 변수와 IBOutlet 선언을 따로 따로 한다. //ex) UIWebView *webView; (nonatomic) IBOutlet UIWebView *webView; IBOutlet UIWebView *webView; IBOutlet UITextField *textField; Methods //AmuckWeather class 의 getWeatherXmlForZipCode 메소드를 통해 가져온 URL 의 결 과값을 webView 를 통해 어플리케이션에 담는다. - (IBAction)goClick; Weather app
*** FlipsideView.h Property 없음 Methods 없음 *** FlipsideViewController.h Property 없음 Methods 없음 Flipside View 폴더의 클래스들은 생성기본 클래스 Flipside 의 인터페이스의 구현 로직은 RootViewController 클래스에서 이루어졌다. Weather app
*** RootViewController.h Property IBOutlet UIButton *infoButton; //MainViewController class 객체 변수 MainViewController *mainViewController; //FlipsideViewController class 객체 변수 FlipsideViewController *flipsideViewController; UINavigationBar *flipsideNavigationBar; Methods //info button 의 action //mainView 에서 flipsideView 로 전환될 때 세팅 - (IBAction)toggleView; Weather app
*** ZipWeatherAppDelegate.h – 파일생성 그대로 되어있음 Property IBOutlet UIWindow *window; //RootViewController class 객체 변수 IBOutlet RootViewController *rootViewController; Methods 없음 Weather app