├── Weather.sqlite ├── assets ├── bg.png ├── bird.png ├── gear2.png ├── icon.png ├── Default.png ├── forecast.png ├── location.png ├── refresh.png ├── umbrella.png ├── app_header.png ├── minis │ ├── day.png │ ├── fog.png │ ├── hail.png │ ├── haze.png │ ├── night.png │ ├── wind.png │ ├── day-foggy.png │ ├── day-rain.png │ ├── lightning.png │ ├── night-rain.png │ ├── night-snow.png │ ├── rain-heavy.png │ ├── rain-light.png │ ├── rain-snow.png │ ├── rain-wind.png │ ├── snow-heavy.png │ ├── snow-light.png │ ├── snow-wind.png │ ├── cloudy-heavy.png │ ├── night-foggy.png │ ├── day-lightning.png │ ├── night-lightning.png │ ├── day-cloudy-heavy.png │ ├── day-cloudy-light.png │ ├── night-cloudy-heavy.png │ └── night-cloudy-light.png ├── WxHere_Icon_Mini.png └── about.html ├── Classes ├── kissxml │ ├── .svn │ │ ├── dir-prop-base │ │ ├── text-base │ │ │ ├── DDXML.h.svn-base │ │ │ ├── AppDelegate.h.svn-base │ │ │ ├── DDXMLTesting.h.svn-base │ │ │ ├── KissXML_Prefix.pch.svn-base │ │ │ ├── AppDelegate.m.svn-base │ │ │ ├── main.m.svn-base │ │ │ ├── NSStringAdditions.h.svn-base │ │ │ ├── NSStringAdditions.m.svn-base │ │ │ ├── DDXMLElementAdditions.h.svn-base │ │ │ ├── Info.plist.svn-base │ │ │ ├── DDXMLElement.h.svn-base │ │ │ ├── DDXMLDocument.h.svn-base │ │ │ ├── DDXMLPrivate.h.svn-base │ │ │ ├── DDXMLDocument.m.svn-base │ │ │ ├── DDXMLElementAdditions.m.svn-base │ │ │ └── DDXMLNode.h.svn-base │ │ ├── all-wcprops │ │ └── entries │ ├── DDXML.h │ ├── NSStringAdditions.h │ ├── NSStringAdditions.m │ ├── DDXMLElementAdditions.h │ ├── DDXMLElement.h │ ├── DDXMLDocument.h │ ├── DDXMLPrivate.h │ ├── DDXMLElementAdditions.m │ ├── DDXMLDocument.m │ └── DDXMLNode.h ├── Period.m ├── HourForecast.m ├── Period.h ├── NSUserDefaults-Defaults.h ├── HourForecast.h ├── HourlyViewController.h ├── NSUserDefaults-Defaults.m ├── URLConnectionHandler.h ├── Weather.m ├── AboutViewController.h ├── DataViewController.h ├── Weather.h ├── ICAO.h ├── ICAOList.h ├── ForecastPeriod.m ├── LocationDataModel.h ├── GraphView.h ├── ForecastPeriod.h ├── GPSDataModel.h ├── ForecastTableViewCell.h ├── ForecastTableViewController.h ├── ForecastDay.h ├── WxHereAppDelegate.h ├── ICAO.m ├── WxAnnotation.h ├── HourlyForecastDataModel.h ├── BasicDataModel.h ├── WxDataModel.h ├── CurrentConditionsDataModel.h ├── ForecastTableViewCell.m ├── NetDataModel.h ├── WxAnnotation.m ├── MapViewController.h ├── NOAADataModel.h ├── ForecastDay.m ├── BasicDataModel.m ├── HourlyViewController.m ├── NetDataModel.m ├── URLConnectionHandler.m ├── AboutViewController.m ├── LocationDataModel.m ├── GPSDataModel.m ├── WxHereAppDelegate.m ├── CurrentConditionsDataModel.m ├── WxDataModel.m ├── ForecastTableViewController.m ├── GraphView.m ├── HourlyForecastDataModel.m ├── DataViewController.m └── MapViewController.m ├── Weather.xcdatamodel ├── layout └── elements ├── Settings.bundle ├── en.lproj │ └── Root.strings └── Root.plist ├── .gitignore ├── README.markdown ├── WxHere.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── aspitz.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── WorkspaceSettings.xcsettings └── xcuserdata │ └── aspitz.xcuserdatad │ ├── xcschemes │ ├── xcschememanagement.plist │ └── WxHere.xcscheme │ ├── xcbreakpoints │ └── Breakpoints.xcbkptlist │ └── xcdebugger │ └── Breakpoints.xcbkptlist ├── Entitlements.plist ├── WxHere_Prefix.pch ├── Categories.plist ├── main.m └── WxHere-Info.plist /Weather.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/Weather.sqlite -------------------------------------------------------------------------------- /assets/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/bg.png -------------------------------------------------------------------------------- /assets/bird.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/bird.png -------------------------------------------------------------------------------- /assets/gear2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/gear2.png -------------------------------------------------------------------------------- /assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/icon.png -------------------------------------------------------------------------------- /assets/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/Default.png -------------------------------------------------------------------------------- /assets/forecast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/forecast.png -------------------------------------------------------------------------------- /assets/location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/location.png -------------------------------------------------------------------------------- /assets/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/refresh.png -------------------------------------------------------------------------------- /assets/umbrella.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/umbrella.png -------------------------------------------------------------------------------- /Classes/kissxml/.svn/dir-prop-base: -------------------------------------------------------------------------------- 1 | K 10 2 | svn:ignore 3 | V 6 4 | build 5 | 6 | END 7 | -------------------------------------------------------------------------------- /assets/app_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/app_header.png -------------------------------------------------------------------------------- /assets/minis/day.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/day.png -------------------------------------------------------------------------------- /assets/minis/fog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/fog.png -------------------------------------------------------------------------------- /assets/minis/hail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/hail.png -------------------------------------------------------------------------------- /assets/minis/haze.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/haze.png -------------------------------------------------------------------------------- /assets/minis/night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/night.png -------------------------------------------------------------------------------- /assets/minis/wind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/wind.png -------------------------------------------------------------------------------- /Weather.xcdatamodel/layout: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/Weather.xcdatamodel/layout -------------------------------------------------------------------------------- /assets/WxHere_Icon_Mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/WxHere_Icon_Mini.png -------------------------------------------------------------------------------- /assets/minis/day-foggy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/day-foggy.png -------------------------------------------------------------------------------- /assets/minis/day-rain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/day-rain.png -------------------------------------------------------------------------------- /assets/minis/lightning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/lightning.png -------------------------------------------------------------------------------- /assets/minis/night-rain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/night-rain.png -------------------------------------------------------------------------------- /assets/minis/night-snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/night-snow.png -------------------------------------------------------------------------------- /assets/minis/rain-heavy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/rain-heavy.png -------------------------------------------------------------------------------- /assets/minis/rain-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/rain-light.png -------------------------------------------------------------------------------- /assets/minis/rain-snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/rain-snow.png -------------------------------------------------------------------------------- /assets/minis/rain-wind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/rain-wind.png -------------------------------------------------------------------------------- /assets/minis/snow-heavy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/snow-heavy.png -------------------------------------------------------------------------------- /assets/minis/snow-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/snow-light.png -------------------------------------------------------------------------------- /assets/minis/snow-wind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/snow-wind.png -------------------------------------------------------------------------------- /Classes/kissxml/DDXML.h: -------------------------------------------------------------------------------- 1 | #import "DDXMLNode.h" 2 | #import "DDXMLElement.h" 3 | #import "DDXMLDocument.h" 4 | -------------------------------------------------------------------------------- /Weather.xcdatamodel/elements: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/Weather.xcdatamodel/elements -------------------------------------------------------------------------------- /assets/minis/cloudy-heavy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/cloudy-heavy.png -------------------------------------------------------------------------------- /assets/minis/night-foggy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/night-foggy.png -------------------------------------------------------------------------------- /assets/minis/day-lightning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/day-lightning.png -------------------------------------------------------------------------------- /assets/minis/night-lightning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/night-lightning.png -------------------------------------------------------------------------------- /assets/minis/day-cloudy-heavy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/day-cloudy-heavy.png -------------------------------------------------------------------------------- /assets/minis/day-cloudy-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/day-cloudy-light.png -------------------------------------------------------------------------------- /Settings.bundle/en.lproj/Root.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/Settings.bundle/en.lproj/Root.strings -------------------------------------------------------------------------------- /assets/minis/night-cloudy-heavy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/night-cloudy-heavy.png -------------------------------------------------------------------------------- /assets/minis/night-cloudy-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/assets/minis/night-cloudy-light.png -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/DDXML.h.svn-base: -------------------------------------------------------------------------------- 1 | #import "DDXMLNode.h" 2 | #import "DDXMLElement.h" 3 | #import "DDXMLDocument.h" 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *~.nib 4 | 5 | build/ 6 | 7 | *.pbxuser 8 | *.perspective 9 | *.perspectivev3 10 | 11 | *.mode1v3 12 | *.mode2v3 -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/AppDelegate.h.svn-base: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface AppDelegate : NSObject 4 | { 5 | 6 | } 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | ## WxHere 2 | 3 | WxHere is a zero effort weather application that gives the user the weather at their current location as well as a seven day forecast. -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/DDXMLTesting.h.svn-base: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | @interface DDXMLTesting : NSObject 5 | 6 | + (void)performTests; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/KissXML_Prefix.pch.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'KissXML' target in the 'KissXML' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /WxHere.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WxHere.xcodeproj/project.xcworkspace/xcuserdata/aspitz.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspitz/WxHere/HEAD/WxHere.xcodeproj/project.xcworkspace/xcuserdata/aspitz.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | get-task-allow 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/AppDelegate.m.svn-base: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "DDXML.h" 3 | #import "DDXMLTesting.h" 4 | 5 | 6 | @implementation AppDelegate 7 | 8 | - (void)applicationDidFinishLaunching:(NSNotification *)notification 9 | { 10 | [DDXMLTesting performTests]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Classes/kissxml/NSStringAdditions.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | 5 | @interface NSString (NSStringAdditions) 6 | 7 | /** 8 | * xmlChar - A basic replacement for char, a byte in a UTF-8 encoded string. 9 | **/ 10 | - (const xmlChar *)xmlChar; 11 | 12 | - (NSString *)stringByTrimming; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/main.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // KissXML 4 | // 5 | // Created by Robbie Hanson on 9/27/08. 6 | // Copyright Deusty Designs, LLC. 2008. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/NSStringAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | 5 | @interface NSString (NSStringAdditions) 6 | 7 | /** 8 | * xmlChar - A basic replacement for char, a byte in a UTF-8 encoded string. 9 | **/ 10 | - (const xmlChar *)xmlChar; 11 | 12 | - (NSString *)trimWhitespace; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /WxHere_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'WxNow' target in the 'WxNow' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | 10 | #ifdef DEBUG 11 | #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); 12 | #else 13 | #define DLog(...) 14 | #endif -------------------------------------------------------------------------------- /Classes/Period.m: -------------------------------------------------------------------------------- 1 | // 2 | // Period.m 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 2/2/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "Period.h" 10 | 11 | 12 | @implementation Period 13 | @synthesize date, dateComponents; 14 | 15 | - (void) dealloc{ 16 | [date release]; 17 | [dateComponents release]; 18 | [super dealloc]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Classes/HourForecast.m: -------------------------------------------------------------------------------- 1 | // 2 | // HourForecast.m 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 7/9/10. 6 | // Copyright 2010 MITRE Corp. All rights reserved. 7 | // 8 | 9 | #import "HourForecast.h" 10 | #import "Period.h" 11 | 12 | @implementation HourForecast 13 | 14 | @synthesize period; 15 | @synthesize temperature; 16 | @synthesize dewPoint; 17 | @synthesize percentHumidity; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Classes/Period.h: -------------------------------------------------------------------------------- 1 | // 2 | // Period.h 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 2/2/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface Period : NSObject { 13 | NSDate *date; 14 | NSDateComponents *dateComponents; 15 | } 16 | 17 | @property (nonatomic, retain) NSDate *date; 18 | @property (nonatomic, retain) NSDateComponents *dateComponents; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Classes/NSUserDefaults-Defaults.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSUserDefaults+Defaults.h 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 2/10/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSUserDefaults (Defaults) 13 | 14 | - (NSInteger)integerForKey:(NSString *)defaultName defaultValue:(NSInteger)defaultValue; 15 | - (BOOL)boolForKey:(NSString *)defaultName defaultValue:(BOOL)defaultValue; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /WxHere.xcodeproj/project.xcworkspace/xcuserdata/aspitz.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceUserSettings_HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges 6 | 7 | IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/NSStringAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | #import "NSStringAdditions.h" 2 | 3 | 4 | @implementation NSString (NSStringAdditions) 5 | 6 | - (const xmlChar *)xmlChar 7 | { 8 | return (const xmlChar *)[self UTF8String]; 9 | } 10 | 11 | - (NSString *)trimWhitespace 12 | { 13 | NSMutableString *mStr = [self mutableCopy]; 14 | CFStringTrimWhitespace((CFMutableStringRef)mStr); 15 | 16 | NSString *result = [mStr copy]; 17 | 18 | [mStr release]; 19 | return [result autorelease]; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Classes/kissxml/NSStringAdditions.m: -------------------------------------------------------------------------------- 1 | #import "NSStringAdditions.h" 2 | 3 | 4 | @implementation NSString (NSStringAdditions) 5 | 6 | - (const xmlChar *)xmlChar 7 | { 8 | return (const xmlChar *)[self UTF8String]; 9 | } 10 | 11 | #ifdef GNUSTEP 12 | - (NSString *)stringByTrimming 13 | { 14 | return [self stringByTrimmingSpaces]; 15 | } 16 | #else 17 | - (NSString *)stringByTrimming 18 | { 19 | NSMutableString *mStr = [self mutableCopy]; 20 | CFStringTrimWhitespace((CFMutableStringRef)mStr); 21 | 22 | NSString *result = [mStr copy]; 23 | 24 | [mStr release]; 25 | return [result autorelease]; 26 | } 27 | #endif 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /WxHere.xcodeproj/xcuserdata/aspitz.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | WxHere.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 1D6058900D05DD3D006BFB54 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Classes/HourForecast.h: -------------------------------------------------------------------------------- 1 | // 2 | // HourForecast.h 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 7/9/10. 6 | // Copyright 2010 MITRE Corp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef enum { 12 | kTemp, 13 | kDewPoint 14 | } ElementType; 15 | 16 | @class Period; 17 | 18 | @interface HourForecast : NSObject { 19 | Period *period; 20 | int temperature; 21 | int dewPoint; 22 | int percentHumidity; 23 | } 24 | 25 | @property (retain, nonatomic) Period *period; 26 | @property (assign) int temperature; 27 | @property (assign) int dewPoint; 28 | @property (assign) int percentHumidity; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Classes/kissxml/DDXMLElementAdditions.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDXML.h" 3 | 4 | // These methods are not part of the standard NSXML API. 5 | // But any developer working extensively with XML will likely appreciate them. 6 | 7 | @interface DDXMLElement (DDAdditions) 8 | 9 | + (DDXMLElement *)elementWithName:(NSString *)name xmlns:(NSString *)ns; 10 | 11 | - (DDXMLElement *)elementForName:(NSString *)name; 12 | - (DDXMLElement *)elementForName:(NSString *)name xmlns:(NSString *)xmlns; 13 | 14 | - (NSString *)xmlns; 15 | - (void)setXmlns:(NSString *)ns; 16 | 17 | - (void)addAttributeWithName:(NSString *)name stringValue:(NSString *)string; 18 | 19 | - (NSDictionary *)attributesAsDictionary; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/DDXMLElementAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDXML.h" 3 | 4 | // These methods are not part of the standard NSXML API. 5 | // But any developer working extensively with XML will likely appreciate them. 6 | 7 | @interface DDXMLElement (DDAdditions) 8 | 9 | + (DDXMLElement *)elementWithName:(NSString *)name xmlns:(NSString *)ns; 10 | 11 | - (DDXMLElement *)elementForName:(NSString *)name; 12 | - (DDXMLElement *)elementForName:(NSString *)name xmlns:(NSString *)xmlns; 13 | 14 | - (NSString *)xmlns; 15 | - (void)setXmlns:(NSString *)ns; 16 | 17 | - (void)addAttributeWithName:(NSString *)name stringValue:(NSString *)string; 18 | 19 | - (NSDictionary *)attributesAsDictionary; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Classes/HourlyViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HourlyViewController.h 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 7/15/10. 6 | // Copyright 2010 MITRE Corp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class HourlyForecastDataModel; 12 | @class GraphView; 13 | 14 | @interface HourlyViewController : UIViewController { 15 | UIView *activityView; 16 | UIActivityIndicatorView *activityIndicator; 17 | 18 | HourlyForecastDataModel *hourlyForecastDataModel; 19 | GraphView *graphView; 20 | } 21 | 22 | - (void)dataModelUpdating; 23 | 24 | @property (retain) IBOutlet UIView *activityView; 25 | @property (retain) IBOutlet UIActivityIndicatorView *activityIndicator; 26 | @property (retain) IBOutlet GraphView *graphView; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Classes/NSUserDefaults-Defaults.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSUserDefaults+Defaults.m 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 2/10/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "NSUserDefaults-Defaults.h" 10 | 11 | 12 | @implementation NSUserDefaults (Defaults) 13 | 14 | - (NSInteger)integerForKey:(NSString *)defaultName defaultValue:(NSInteger)defaultValue{ 15 | if ([self objectForKey:defaultName] == nil){ 16 | return defaultValue; 17 | } else { 18 | return [self integerForKey:defaultName]; 19 | } 20 | } 21 | 22 | - (BOOL)boolForKey:(NSString *)defaultName defaultValue:(BOOL)defaultValue{ 23 | if ([self objectForKey:defaultName] == nil){ 24 | return defaultValue; 25 | } else { 26 | return [self boolForKey:defaultName]; 27 | } 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Classes/URLConnectionHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // URLConnectionHandler.h 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 5/25/09. 6 | // Copyright 2009 Ayal Spitz. All rights reserved. 7 | // 8 | 9 | @interface URLConnectionHandler : NSObject { 10 | NSMutableData *receivedData; 11 | 12 | NSURLRequest *urlRequest; 13 | 14 | NSInvocation *successInvocation; 15 | NSInvocation *failureInvocation; 16 | } 17 | 18 | @property (nonatomic, retain) NSMutableData *receivedData; 19 | 20 | @property (nonatomic, retain) NSURLRequest *urlRequest; 21 | 22 | @property (nonatomic, retain) NSInvocation *successInvocation; 23 | @property (nonatomic, retain) NSInvocation *failureInvocation; 24 | 25 | - (id) initWithTarget:(id)anObject successSelector:(SEL)successSelector failureSelector:(SEL)failureSelector; 26 | - (void)connect:(NSString *)urlString; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/Info.plist.svn-base: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /Categories.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Mostly Cloudy 6 | cloudy-heavy.png 7 | Fair 8 | day.png 9 | Partly Cloudy 10 | cloudy-heavy.png 11 | Overcast 12 | cloudy-heavy.png 13 | Fog 14 | fog.png 15 | Rain 16 | rain-heavy.png 17 | Hail 18 | hail.png 19 | Snow 20 | snow-heavy.png 21 | Thundestorm 22 | lightning.png 23 | Windy 24 | wind.png 25 | Light Rain 26 | rain-light.png 27 | Tornado 28 | wind.png 29 | Dust 30 | wind.png 31 | Haze 32 | haze.png 33 | 34 | 35 | -------------------------------------------------------------------------------- /Classes/Weather.m: -------------------------------------------------------------------------------- 1 | // 2 | // Weather.m 3 | // Location 4 | // 5 | // Created by Ayal Spitz on 11/6/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "Weather.h" 24 | 25 | 26 | @implementation Weather 27 | 28 | @dynamic condition; 29 | @dynamic category; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Classes/AboutViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AboutViewController.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 9/25/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | 25 | 26 | @interface AboutViewController : UIViewController { 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Classes/DataViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DataViewController.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 5/19/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | 25 | @class WxDataModel; 26 | 27 | @interface DataViewController : UITableViewController{ 28 | NSArray *sectionHeaders; 29 | } 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Classes/Weather.h: -------------------------------------------------------------------------------- 1 | // 2 | // Weather.h 3 | // Location 4 | // 5 | // Created by Ayal Spitz on 11/6/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | 25 | 26 | @interface Weather : NSManagedObject{} 27 | 28 | @property (nonatomic, retain) NSString * condition; 29 | @property (nonatomic, retain) NSString * category; 30 | 31 | @end 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 5/8/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import "WxHereAppDelegate.h" 25 | 26 | int main(int argc, char *argv[]) { 27 | int retVal = 0; 28 | @autoreleasepool { 29 | retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([WxHereAppDelegate class])); 30 | } 31 | return retVal; 32 | } 33 | -------------------------------------------------------------------------------- /WxHere-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | icon.png 13 | CFBundleIdentifier 14 | spitz.ayal.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.4 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | UIApplicationExitsOnSuspend 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Classes/ICAO.h: -------------------------------------------------------------------------------- 1 | // 2 | // ICAO.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 10/24/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | 25 | 26 | @interface ICAO : NSObject { 27 | double latitude; 28 | double longitude; 29 | NSString *stationID; 30 | } 31 | 32 | @property (copy) NSString *stationID; 33 | 34 | - (id)init:(NSString *)name atLat:(double)lat Lon:(double)lon; 35 | - (double)distanceFromLat:(double)lat Lon:(double)lon; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Classes/ICAOList.h: -------------------------------------------------------------------------------- 1 | // 2 | // ICAOList.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 10/24/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | 25 | 26 | @interface ICAOList : NSObject { 27 | NSMutableArray *icaoList; 28 | } 29 | 30 | @property (retain) NSMutableArray *icaoList; 31 | 32 | - (void)addICAO:(NSString *)name atLat:(double)lat Lon:(double)lon; 33 | - (NSString *)closestICAOtoLat:(double)lat Lon:(double)lon; 34 | - (void)loadList; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Classes/ForecastPeriod.m: -------------------------------------------------------------------------------- 1 | // 2 | // ForecastPeriod.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 1/21/10. 6 | // Copyright (C) 2010 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "ForecastPeriod.h" 24 | 25 | 26 | @implementation ForecastPeriod 27 | @synthesize shortForecast; 28 | @synthesize longForecast; 29 | @synthesize condition; 30 | @synthesize temp; 31 | 32 | - (void) dealloc{ 33 | [shortForecast release]; 34 | [longForecast release]; 35 | [condition release]; 36 | [temp release]; 37 | [super dealloc]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Classes/LocationDataModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocationDataModel.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 11/2/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import "NetDataModel.h" 25 | 26 | @class GPSDataModel; 27 | 28 | 29 | @interface LocationDataModel : NetDataModel { 30 | NSString *location; 31 | NSString *city; 32 | NSString *stateAbbr; 33 | } 34 | 35 | @property (copy) NSString *location; 36 | @property (copy) NSString *city; 37 | @property (copy) NSString *stateAbbr; 38 | 39 | @end -------------------------------------------------------------------------------- /Classes/GraphView.h: -------------------------------------------------------------------------------- 1 | // 2 | // GraphView.h 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 7/15/10. 6 | // Copyright 2010 MITRE Corp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface GraphView : UIView { 13 | NSArray *data; 14 | 15 | CGPoint *dataArray; 16 | NSInteger dataMin; 17 | NSInteger dataMax; 18 | NSUInteger dataLen; 19 | 20 | BOOL debug; 21 | 22 | BOOL strokeGraph; 23 | CGColorRef graphStrokeColor; 24 | CGFloat graphLineWidth; 25 | 26 | BOOL xAxisLabel; 27 | NSString *xAxisLabelFormat; 28 | NSUInteger xAxisLabelCount; 29 | UIFont *xAxisLabelFont; 30 | CGColorRef xAxisLabelColor; 31 | } 32 | 33 | @property (assign) BOOL debug; 34 | 35 | @property (assign) BOOL strokeGraph; 36 | @property (assign) CGColorRef graphStrokeColor; 37 | @property (assign) CGFloat graphLineWidth; 38 | 39 | @property (assign) BOOL xAxisLabel; 40 | @property (copy) NSString *xAxisLabelFormat; 41 | @property (assign) NSUInteger xAxisLabelCount; 42 | @property (retain) UIFont *xAxisLabelFont; 43 | @property (assign) CGColorRef xAxisLabelColor; 44 | 45 | - (void)setDataFromArray:(NSArray *)srcArray withKeyPath:(NSString *)keyPath 46 | startAtIndex:(NSUInteger)startIndex withLength:(NSUInteger)len; 47 | 48 | - (NSUInteger)drawXAxisLabels:(CGContextRef)context viewSize:(CGSize)viewSize; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Classes/ForecastPeriod.h: -------------------------------------------------------------------------------- 1 | // 2 | // ForecastPeriod.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 1/21/10. 6 | // Copyright (C) 2010 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | 25 | 26 | @interface ForecastPeriod : NSObject { 27 | NSString *shortForecast; 28 | NSString *longForecast; 29 | NSString *condition; 30 | NSString *temp; 31 | } 32 | 33 | @property (copy) NSString *shortForecast; 34 | @property (copy) NSString *longForecast; 35 | @property (copy) NSString *condition; 36 | @property (copy) NSString *temp; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Classes/GPSDataModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // GPSDataModel.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/11/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import 25 | #import "BasicDataModel.h" 26 | 27 | @class CLLocation; 28 | @class CLLocationManager; 29 | 30 | @interface GPSDataModel : BasicDataModel { 31 | NSUInteger timeout; 32 | NSUInteger minAccuracy; 33 | 34 | CLLocationManager *locationManager; 35 | CLLocation *location; 36 | } 37 | 38 | @property (copy) CLLocation *location; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Classes/ForecastTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // ForecastTableViewCell.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 1/16/10. 6 | // Copyright (C) 2010 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | 25 | 26 | @interface ForecastTableViewCell : UITableViewCell { 27 | UILabel *conditionLabel; 28 | UILabel *forecastLabel; 29 | 30 | UIImageView *periodImageView; 31 | UILabel *tempLabel; 32 | } 33 | 34 | @property (nonatomic, retain) IBOutlet UILabel *conditionLabel; 35 | @property (nonatomic, retain) IBOutlet UILabel *forecastLabel; 36 | 37 | @property (nonatomic, retain) IBOutlet UIImageView *periodImageView; 38 | @property (nonatomic, retain) IBOutlet UILabel *tempLabel; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Classes/ForecastTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ForcastTableViewController.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 9/13/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | @class ForecastTableViewCell; 25 | @class NOAADataModel; 26 | 27 | @interface ForecastTableViewController : UITableViewController { 28 | UIView *activityView; 29 | UIActivityIndicatorView *activityIndicator; 30 | 31 | NSDictionary *weatherIcons; 32 | 33 | NOAADataModel *noaaDataModel; 34 | } 35 | 36 | @property (retain) IBOutlet UIView *activityView; 37 | @property (retain) IBOutlet UIActivityIndicatorView *activityIndicator; 38 | 39 | - (void)dataModelUpdating; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Classes/ForecastDay.h: -------------------------------------------------------------------------------- 1 | // 2 | // ForecastDay.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 10/30/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | @class ForecastPeriod; 25 | 26 | @interface ForecastDay : NSObject { 27 | NSString *name; 28 | int day; 29 | NSDate *date; 30 | 31 | NSMutableDictionary *periods; 32 | } 33 | 34 | 35 | @property (copy) NSString *name; 36 | @property (assign) int day; 37 | @property (retain) NSDate *date; 38 | @property (retain) NSMutableDictionary *periods; 39 | 40 | 41 | - (ForecastPeriod *)period:(NSInteger)hour; 42 | - (ForecastPeriod *)periodAtIndex:(NSInteger)index; 43 | 44 | NSInteger stringNumberSort(id m1, id m2, void *context); 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Classes/WxHereAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // WxHereAppDelegate.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 5/8/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | 25 | @class WxDataModel; 26 | 27 | @interface WxHereAppDelegate : NSObject { 28 | WxDataModel *wxDataModel; 29 | 30 | UIWindow *window; 31 | UITabBarController *tabBarController; 32 | } 33 | 34 | @property (nonatomic, retain) WxDataModel *wxDataModel; 35 | 36 | @property (nonatomic, retain) IBOutlet UIWindow *window; 37 | @property (nonatomic, retain) IBOutlet UITabBarController *tabBarController; 38 | 39 | - (void)addNotificationObservers; 40 | - (NSString *)applicationDocumentsDirectory; 41 | 42 | @end 43 | 44 | -------------------------------------------------------------------------------- /Classes/ICAO.m: -------------------------------------------------------------------------------- 1 | // 2 | // ICAO.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 10/24/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "ICAO.h" 24 | 25 | 26 | @implementation ICAO 27 | @synthesize stationID; 28 | 29 | - (id)init:(NSString *)name atLat:(double)lat Lon:(double)lon{ 30 | self = [super init]; 31 | if (self != nil) { 32 | latitude = lat; 33 | longitude = lon; 34 | self.stationID = name; 35 | } 36 | return self; 37 | } 38 | 39 | - (void)dealloc{ 40 | [stationID release]; 41 | [super dealloc]; 42 | } 43 | 44 | - (double)distanceFromLat:(double)lat Lon:(double)lon{ 45 | double dLat = latitude - lat; 46 | double dLon = longitude - lon; 47 | 48 | return (dLat * dLat) + (dLon * dLon); 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Classes/WxAnnotation.h: -------------------------------------------------------------------------------- 1 | // 2 | // WxAnnotation.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 5/20/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import 25 | 26 | @class GPSDataModel; 27 | @class CurrentConditionsDataModel; 28 | 29 | @interface WxAnnotation : NSObject { 30 | CLLocationCoordinate2D coordinate; 31 | NSString *title; 32 | NSString *subtitle; 33 | } 34 | 35 | @property (nonatomic, readonly) CLLocationCoordinate2D coordinate; 36 | @property (nonatomic, copy) NSString *title; 37 | @property (nonatomic, copy) NSString *subtitle; 38 | 39 | - (id)initWithGPSDataModel:(GPSDataModel *)dataModel; 40 | 41 | - (void)updateCurrentConditions:(CurrentConditionsDataModel *)currentConditions; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Classes/HourlyForecastDataModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HourlyForecastDataModel.h 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 7/9/10. 6 | // Copyright (C) 2010 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import "NetDataModel.h" 25 | 26 | @class DDXMLElement; 27 | 28 | @interface HourlyForecastDataModel : NetDataModel { 29 | NSDateFormatter *dateFormatter; 30 | } 31 | 32 | @property(retain) NSMutableArray *hourlyForecast; 33 | 34 | 35 | - (void)parseTimeLayout:(DDXMLElement *)dataElement; 36 | - (void)parseTemperatures:(DDXMLElement *)parametersElement; 37 | - (void)parseTemperatureElements:(DDXMLElement *)parametersElement; 38 | - (void)parseHumdity:(DDXMLElement *)parametersElement; 39 | 40 | - (NSDate *)parseTimeDateString:(NSString *)timeDateString; 41 | - (void)parseValues:(DDXMLElement *)valuesElement; 42 | 43 | @end -------------------------------------------------------------------------------- /Classes/BasicDataModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // BasicDataModel.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/13/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | 25 | 26 | typedef enum enumState{ Neutral, Updating, Updated, Error } ModelState; 27 | 28 | @interface BasicDataModel : NSObject { 29 | ModelState state; 30 | 31 | NSDate *startTime; 32 | NSNumber *elapsedTime; 33 | } 34 | 35 | @property (assign) ModelState state; 36 | 37 | @property (retain) NSDate *startTime; 38 | @property (retain) NSNumber *elapsedTime; 39 | 40 | 41 | - (void)bubbleUpError:(NSString *)domain code:(NSInteger)code errorString:(NSString *)errorString; 42 | 43 | - (void)handleError:(NSError *)error; 44 | - (void)handleException:(NSException *)exception; 45 | 46 | - (void)update:(id)dataModel; 47 | - (void)refresh; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Classes/WxDataModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // WxDataModel.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/31/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import "BasicDataModel.h" 25 | 26 | @class GPSDataModel; 27 | @class LocationDataModel; 28 | @class CurrentConditionsDataModel; 29 | @class NOAADataModel; 30 | @class HourlyForecastDataModel; 31 | 32 | @interface WxDataModel : BasicDataModel { 33 | int done; 34 | } 35 | 36 | @property (retain) GPSDataModel *gpsDataModel; 37 | @property (retain) LocationDataModel *locationDataModel; 38 | @property (retain) CurrentConditionsDataModel *currentConditionsDataModel; 39 | @property (retain) NOAADataModel *noaaDataModel; 40 | //@property (retain) HourlyForecastDataModel *hourlyForecastDataModel; 41 | 42 | + (WxDataModel *)dataModel; 43 | 44 | - (void)addObservers; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Classes/CurrentConditionsDataModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // CurrentConditionsDataModel.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 10/25/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import "NetDataModel.h" 25 | 26 | @class GPSDataModel; 27 | @class ICAOList; 28 | 29 | @interface CurrentConditionsDataModel : NetDataModel { 30 | ICAOList *icaoList; 31 | NSString *icao; 32 | NSString *location; 33 | NSString *temperature; 34 | NSString *condition; 35 | UIImageView *conditionImage; 36 | 37 | NSDictionary *categoryToImageDictionary; 38 | NSDictionary *conditionToCategoryDictionary; 39 | } 40 | 41 | @property (copy) NSString *icao; 42 | @property (copy) NSString *location; 43 | @property (copy) NSString *temperature; 44 | @property (copy) NSString *condition; 45 | @property (retain) UIImageView *conditionImage; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Classes/ForecastTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // ForecastTableViewCell.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 1/16/10. 6 | // Copyright (C) 2010 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "ForecastTableViewCell.h" 24 | 25 | 26 | @implementation ForecastTableViewCell 27 | @synthesize conditionLabel, forecastLabel; 28 | @synthesize tempLabel, periodImageView; 29 | 30 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 31 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){} 32 | return self; 33 | } 34 | 35 | - (id) initWithCoder:(NSCoder *)aDecoder{ 36 | if (self = [super initWithCoder:aDecoder]){} 37 | return self; 38 | } 39 | 40 | - (void)dealloc { 41 | [conditionLabel release]; 42 | [forecastLabel release]; 43 | [tempLabel release]; 44 | [periodImageView release]; 45 | [super dealloc]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Classes/NetDataModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // NetDataModel.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/13/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import "BasicDataModel.h" 25 | 26 | @interface NetDataModel : BasicDataModel { 27 | NSURLRequest *urlRequest; 28 | NSMutableData *receivedData; 29 | BOOL retry; 30 | } 31 | 32 | @property (nonatomic, retain) NSURLRequest *urlRequest; 33 | @property (retain) NSMutableData *receivedData; 34 | @property (assign) BOOL retry; 35 | 36 | - (void)connect:(NSString *)urlString; 37 | - (void)retryConnection; 38 | - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response; 39 | - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data; 40 | - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error; 41 | - (void)connectionDidFinishLoading:(NSURLConnection *)connection; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /WxHere.xcodeproj/xcuserdata/aspitz.xcuserdatad/xcbreakpoints/Breakpoints.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 16 | 17 | 28 | 29 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /WxHere.xcodeproj/xcuserdata/aspitz.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 17 | 18 | 29 | 30 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Classes/kissxml/DDXMLElement.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDXMLNode.h" 3 | 4 | 5 | @interface DDXMLElement : DDXMLNode 6 | { 7 | } 8 | 9 | - (id)initWithName:(NSString *)name; 10 | - (id)initWithName:(NSString *)name URI:(NSString *)URI; 11 | - (id)initWithName:(NSString *)name stringValue:(NSString *)string; 12 | - (id)initWithXMLString:(NSString *)string error:(NSError **)error; 13 | 14 | #pragma mark --- Elements by name --- 15 | 16 | - (NSArray *)elementsForName:(NSString *)name; 17 | - (NSArray *)elementsForLocalName:(NSString *)localName URI:(NSString *)URI; 18 | 19 | #pragma mark --- Attributes --- 20 | 21 | - (void)addAttribute:(DDXMLNode *)attribute; 22 | - (void)removeAttributeForName:(NSString *)name; 23 | - (void)setAttributes:(NSArray *)attributes; 24 | //- (void)setAttributesAsDictionary:(NSDictionary *)attributes; 25 | - (NSArray *)attributes; 26 | - (DDXMLNode *)attributeForName:(NSString *)name; 27 | //- (DDXMLNode *)attributeForLocalName:(NSString *)localName URI:(NSString *)URI; 28 | 29 | #pragma mark --- Namespaces --- 30 | 31 | - (void)addNamespace:(DDXMLNode *)aNamespace; 32 | - (void)removeNamespaceForPrefix:(NSString *)name; 33 | - (void)setNamespaces:(NSArray *)namespaces; 34 | - (NSArray *)namespaces; 35 | - (DDXMLNode *)namespaceForPrefix:(NSString *)prefix; 36 | - (DDXMLNode *)resolveNamespaceForName:(NSString *)name; 37 | - (NSString *)resolvePrefixForNamespaceURI:(NSString *)namespaceURI; 38 | 39 | #pragma mark --- Children --- 40 | 41 | - (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index; 42 | //- (void)insertChildren:(NSArray *)children atIndex:(NSUInteger)index; 43 | - (void)removeChildAtIndex:(NSUInteger)index; 44 | - (void)setChildren:(NSArray *)children; 45 | - (void)addChild:(DDXMLNode *)child; 46 | //- (void)replaceChildAtIndex:(NSUInteger)index withNode:(DDXMLNode *)node; 47 | //- (void)normalizeAdjacentTextNodesPreservingCDATA:(BOOL)preserve; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/DDXMLElement.h.svn-base: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDXMLNode.h" 3 | 4 | 5 | @interface DDXMLElement : DDXMLNode 6 | { 7 | } 8 | 9 | - (id)initWithName:(NSString *)name; 10 | - (id)initWithName:(NSString *)name URI:(NSString *)URI; 11 | - (id)initWithName:(NSString *)name stringValue:(NSString *)string; 12 | - (id)initWithXMLString:(NSString *)string error:(NSError **)error; 13 | 14 | #pragma mark --- Elements by name --- 15 | 16 | - (NSArray *)elementsForName:(NSString *)name; 17 | - (NSArray *)elementsForLocalName:(NSString *)localName URI:(NSString *)URI; 18 | 19 | #pragma mark --- Attributes --- 20 | 21 | - (void)addAttribute:(DDXMLNode *)attribute; 22 | - (void)removeAttributeForName:(NSString *)name; 23 | - (void)setAttributes:(NSArray *)attributes; 24 | //- (void)setAttributesAsDictionary:(NSDictionary *)attributes; 25 | - (NSArray *)attributes; 26 | - (DDXMLNode *)attributeForName:(NSString *)name; 27 | //- (DDXMLNode *)attributeForLocalName:(NSString *)localName URI:(NSString *)URI; 28 | 29 | #pragma mark --- Namespaces --- 30 | 31 | - (void)addNamespace:(DDXMLNode *)aNamespace; 32 | - (void)removeNamespaceForPrefix:(NSString *)name; 33 | - (void)setNamespaces:(NSArray *)namespaces; 34 | - (NSArray *)namespaces; 35 | - (DDXMLNode *)namespaceForPrefix:(NSString *)prefix; 36 | - (DDXMLNode *)resolveNamespaceForName:(NSString *)name; 37 | - (NSString *)resolvePrefixForNamespaceURI:(NSString *)namespaceURI; 38 | 39 | #pragma mark --- Children --- 40 | 41 | - (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index; 42 | //- (void)insertChildren:(NSArray *)children atIndex:(NSUInteger)index; 43 | - (void)removeChildAtIndex:(NSUInteger)index; 44 | - (void)setChildren:(NSArray *)children; 45 | - (void)addChild:(DDXMLNode *)child; 46 | //- (void)replaceChildAtIndex:(NSUInteger)index withNode:(DDXMLNode *)node; 47 | //- (void)normalizeAdjacentTextNodesPreservingCDATA:(BOOL)preserve; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Classes/WxAnnotation.m: -------------------------------------------------------------------------------- 1 | // 2 | // WxAnnotation.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 5/20/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "WxAnnotation.h" 24 | #import "GPSDataModel.h" 25 | #import "CurrentConditionsDataModel.h" 26 | 27 | @implementation WxAnnotation 28 | 29 | @synthesize coordinate, title, subtitle; 30 | 31 | 32 | - (id)initWithGPSDataModel:(GPSDataModel *)dataModel{ 33 | self = [super init]; 34 | if(nil != self) { 35 | self.title = @"Current Location"; 36 | coordinate = dataModel.location.coordinate; 37 | } 38 | return self; 39 | } 40 | 41 | 42 | - (void)updateCurrentConditions:(CurrentConditionsDataModel *)currentConditions{ 43 | NSMutableString *mutableTitle = [[NSMutableString alloc] init]; 44 | 45 | if (currentConditions.temperature != nil){ 46 | [mutableTitle appendFormat:@"%@°F", currentConditions.temperature]; 47 | } 48 | 49 | if ((currentConditions.temperature != nil) && (currentConditions.condition != nil)){ 50 | [mutableTitle appendString:@" - "]; 51 | } 52 | if (currentConditions.condition != nil){ 53 | [mutableTitle appendString:currentConditions.condition]; 54 | } 55 | 56 | self.title = mutableTitle; 57 | [mutableTitle release]; 58 | } 59 | 60 | - (void) dealloc { 61 | [title release]; 62 | [subtitle release]; 63 | [super dealloc]; 64 | } 65 | 66 | 67 | @end -------------------------------------------------------------------------------- /Classes/MapViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MapViewController.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/31/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import 25 | 26 | @class MKMapView; 27 | @class WxAnnotation; 28 | @class WxDataModel; 29 | @class MKPinAnnotationView; 30 | 31 | @interface MapViewController : UIViewController { 32 | MKMapView *mapView; 33 | UIView *activityView; 34 | UIActivityIndicatorView *activityIndicator; 35 | UINavigationBar *navigationBar; 36 | UINavigationItem *navigationItem; 37 | UIBarButtonItem *tweetButton; 38 | 39 | WxAnnotation *wxAnnotation; 40 | MKPinAnnotationView *wxAnnotationView; 41 | 42 | WxDataModel *wxDataModel; 43 | UIButton *rightCalloutButton; 44 | 45 | BOOL memoryWarning; 46 | } 47 | 48 | @property (retain) IBOutlet MKMapView *mapView; 49 | @property (retain) IBOutlet UIView *activityView; 50 | @property (retain) IBOutlet UIActivityIndicatorView *activityIndicator; 51 | @property (retain) IBOutlet UINavigationBar *navigationBar; 52 | @property (retain) IBOutlet UINavigationItem *navigationItem; 53 | 54 | - (void)dataModelUpdating; 55 | 56 | - (void)gpsUpdated; 57 | - (void)locationNameUpdated; 58 | - (void)currentConditionsUpdated; 59 | - (void)forecastsUpdated; 60 | 61 | - (IBAction)refreshDataModel:(id)sender; 62 | - (void)updateAnnotation; 63 | 64 | - (void)crawlViews; 65 | - (void)crawlViews:(UIView *)view; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Classes/NOAADataModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // NOAADataModel.h 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 9/8/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import 24 | #import "NetDataModel.h" 25 | 26 | @class GPSDataModel; 27 | @class DDXMLElement; 28 | @class CLLocation; 29 | @class ForecastPeriod; 30 | 31 | @interface NOAADataModel : NetDataModel{ 32 | NSMutableDictionary *timeLayoutDictionary; 33 | NSMutableArray *multidayForecast; 34 | 35 | CLLocation *location; 36 | NSString *locationStr; 37 | 38 | NSDateFormatter *dateFormatter; 39 | } 40 | 41 | @property(retain) NSMutableDictionary *timeLayoutDictionary; 42 | @property(retain) NSMutableArray *multidayForecast; 43 | 44 | @property (retain, nonatomic) CLLocation *location; 45 | @property(nonatomic, copy) NSString *locationStr; 46 | 47 | - (void)parseTimeLayouts:(DDXMLElement *)dataElement; 48 | - (void)parseTimeLayout:(DDXMLElement *)timeLayout; 49 | - (void)parseFullForecasts:(DDXMLElement *)parameterElement; 50 | - (void)parseShortForecasts:(DDXMLElement *)parameterElement; 51 | - (void)parseConditions:(DDXMLElement *)parameterElement; 52 | - (void)parseTemperatures:(DDXMLElement *)parameterElement; 53 | - (void)parseTemperatures:(DDXMLElement *)parameterElement isMin:(BOOL)type; 54 | 55 | - (NSDate *)parseTimeDateString:(NSString *)timeDateString; 56 | 57 | - (BOOL)hasOvernightPeriod; 58 | - (ForecastPeriod *)period:(NSIndexPath *)indexPath; 59 | - (NSString *)currentHighLowString; 60 | 61 | @end -------------------------------------------------------------------------------- /Classes/kissxml/DDXMLDocument.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDXMLElement.h" 3 | #import "DDXMLNode.h" 4 | 5 | 6 | enum { 7 | DDXMLDocumentXMLKind = 0, 8 | DDXMLDocumentXHTMLKind, 9 | DDXMLDocumentHTMLKind, 10 | DDXMLDocumentTextKind 11 | }; 12 | typedef NSUInteger DDXMLDocumentContentKind; 13 | 14 | @interface DDXMLDocument : DDXMLNode 15 | { 16 | } 17 | 18 | - (id)initWithXMLString:(NSString *)string options:(NSUInteger)mask error:(NSError **)error; 19 | //- (id)initWithContentsOfURL:(NSURL *)url options:(NSUInteger)mask error:(NSError **)error; 20 | - (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)error; 21 | //- (id)initWithRootElement:(DDXMLElement *)element; 22 | 23 | //+ (Class)replacementClassForClass:(Class)cls; 24 | 25 | //- (void)setCharacterEncoding:(NSString *)encoding; //primitive 26 | //- (NSString *)characterEncoding; //primitive 27 | 28 | //- (void)setVersion:(NSString *)version; 29 | //- (NSString *)version; 30 | 31 | //- (void)setStandalone:(BOOL)standalone; 32 | //- (BOOL)isStandalone; 33 | 34 | //- (void)setDocumentContentKind:(DDXMLDocumentContentKind)kind; 35 | //- (DDXMLDocumentContentKind)documentContentKind; 36 | 37 | //- (void)setMIMEType:(NSString *)MIMEType; 38 | //- (NSString *)MIMEType; 39 | 40 | //- (void)setDTD:(DDXMLDTD *)documentTypeDeclaration; 41 | //- (DDXMLDTD *)DTD; 42 | 43 | //- (void)setRootElement:(DDXMLNode *)root; 44 | - (DDXMLElement *)rootElement; 45 | 46 | //- (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index; 47 | 48 | //- (void)insertChildren:(NSArray *)children atIndex:(NSUInteger)index; 49 | 50 | //- (void)removeChildAtIndex:(NSUInteger)index; 51 | 52 | //- (void)setChildren:(NSArray *)children; 53 | 54 | //- (void)addChild:(DDXMLNode *)child; 55 | 56 | //- (void)replaceChildAtIndex:(NSUInteger)index withNode:(DDXMLNode *)node; 57 | 58 | - (NSData *)XMLData; 59 | - (NSData *)XMLDataWithOptions:(NSUInteger)options; 60 | 61 | //- (id)objectByApplyingXSLT:(NSData *)xslt arguments:(NSDictionary *)arguments error:(NSError **)error; 62 | //- (id)objectByApplyingXSLTString:(NSString *)xslt arguments:(NSDictionary *)arguments error:(NSError **)error; 63 | //- (id)objectByApplyingXSLTAtURL:(NSURL *)xsltURL arguments:(NSDictionary *)argument error:(NSError **)error; 64 | 65 | //- (BOOL)validateAndReturnError:(NSError **)error; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Classes/ForecastDay.m: -------------------------------------------------------------------------------- 1 | // 2 | // ForecastDay.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 10/30/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "ForecastDay.h" 24 | #import "ForecastPeriod.h" 25 | 26 | @implementation ForecastDay 27 | @synthesize name; 28 | @synthesize day; 29 | @synthesize date; 30 | @synthesize periods; 31 | 32 | - (id) init{ 33 | self = [super init]; 34 | if (self != nil) { 35 | self.periods = [[NSMutableDictionary alloc]init]; 36 | } 37 | return self; 38 | } 39 | 40 | - (void) dealloc{ 41 | [name release]; 42 | [periods release]; 43 | [date release]; 44 | [super dealloc]; 45 | } 46 | 47 | - (ForecastPeriod *)period:(NSInteger)hour{ 48 | NSString *key = [[NSString alloc]initWithFormat:@"%d",hour]; 49 | ForecastPeriod *forecastPeriod = [periods objectForKey:key]; 50 | 51 | if (forecastPeriod == nil){ 52 | forecastPeriod = [[[ForecastPeriod alloc]init] autorelease]; 53 | [periods setObject:forecastPeriod forKey:key]; 54 | } 55 | 56 | [key release]; 57 | 58 | return forecastPeriod; 59 | } 60 | 61 | NSInteger stringNumberSort(id m1, id m2, void *context){ 62 | return [((NSString*)m1) compare:((NSString*)m2) options:NSNumericSearch]; 63 | } 64 | 65 | - (ForecastPeriod *)periodAtIndex:(NSInteger)index{ 66 | NSArray *keys = [periods allKeys]; 67 | if (index < keys.count){ 68 | NSArray *sortedKeys = [keys sortedArrayUsingFunction:stringNumberSort context:nil]; 69 | NSString *key = [sortedKeys objectAtIndex:index]; 70 | return [periods objectForKey:key]; 71 | } else { 72 | return nil; 73 | } 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/DDXMLDocument.h.svn-base: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDXMLElement.h" 3 | #import "DDXMLNode.h" 4 | 5 | 6 | enum { 7 | DDXMLDocumentXMLKind = 0, 8 | DDXMLDocumentXHTMLKind, 9 | DDXMLDocumentHTMLKind, 10 | DDXMLDocumentTextKind 11 | }; 12 | typedef NSUInteger DDXMLDocumentContentKind; 13 | 14 | @interface DDXMLDocument : DDXMLNode 15 | { 16 | } 17 | 18 | - (id)initWithXMLString:(NSString *)string options:(NSUInteger)mask error:(NSError **)error; 19 | //- (id)initWithContentsOfURL:(NSURL *)url options:(NSUInteger)mask error:(NSError **)error; 20 | - (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)error; 21 | //- (id)initWithRootElement:(DDXMLElement *)element; 22 | 23 | //+ (Class)replacementClassForClass:(Class)cls; 24 | 25 | //- (void)setCharacterEncoding:(NSString *)encoding; //primitive 26 | //- (NSString *)characterEncoding; //primitive 27 | 28 | //- (void)setVersion:(NSString *)version; 29 | //- (NSString *)version; 30 | 31 | //- (void)setStandalone:(BOOL)standalone; 32 | //- (BOOL)isStandalone; 33 | 34 | //- (void)setDocumentContentKind:(DDXMLDocumentContentKind)kind; 35 | //- (DDXMLDocumentContentKind)documentContentKind; 36 | 37 | //- (void)setMIMEType:(NSString *)MIMEType; 38 | //- (NSString *)MIMEType; 39 | 40 | //- (void)setDTD:(DDXMLDTD *)documentTypeDeclaration; 41 | //- (DDXMLDTD *)DTD; 42 | 43 | //- (void)setRootElement:(DDXMLNode *)root; 44 | - (DDXMLElement *)rootElement; 45 | 46 | //- (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index; 47 | 48 | //- (void)insertChildren:(NSArray *)children atIndex:(NSUInteger)index; 49 | 50 | //- (void)removeChildAtIndex:(NSUInteger)index; 51 | 52 | //- (void)setChildren:(NSArray *)children; 53 | 54 | //- (void)addChild:(DDXMLNode *)child; 55 | 56 | //- (void)replaceChildAtIndex:(NSUInteger)index withNode:(DDXMLNode *)node; 57 | 58 | - (NSData *)XMLData; 59 | - (NSData *)XMLDataWithOptions:(NSUInteger)options; 60 | 61 | //- (id)objectByApplyingXSLT:(NSData *)xslt arguments:(NSDictionary *)arguments error:(NSError **)error; 62 | //- (id)objectByApplyingXSLTString:(NSString *)xslt arguments:(NSDictionary *)arguments error:(NSError **)error; 63 | //- (id)objectByApplyingXSLTAtURL:(NSURL *)xsltURL arguments:(NSDictionary *)argument error:(NSError **)error; 64 | 65 | //- (BOOL)validateAndReturnError:(NSError **)error; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /WxHere.xcodeproj/xcuserdata/aspitz.xcuserdatad/xcschemes/WxHere.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 13 | 14 | 15 | 16 | 22 | 23 | 24 | 25 | 34 | 35 | 41 | 42 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 22 4 | /svn/!svn/ver/20/trunk 5 | END 6 | main.m 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 28 10 | /svn/!svn/ver/3/trunk/main.m 11 | END 12 | KissXML_Prefix.pch 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 40 16 | /svn/!svn/ver/3/trunk/KissXML_Prefix.pch 17 | END 18 | Info.plist 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 32 22 | /svn/!svn/ver/3/trunk/Info.plist 23 | END 24 | DDXMLPrivate.h 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 37 28 | /svn/!svn/ver/19/trunk/DDXMLPrivate.h 29 | END 30 | DDXMLTesting.h 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 36 34 | /svn/!svn/ver/3/trunk/DDXMLTesting.h 35 | END 36 | NSStringAdditions.h 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 41 40 | /svn/!svn/ver/9/trunk/NSStringAdditions.h 41 | END 42 | DDXMLDocument.h 43 | K 25 44 | svn:wc:ra_dav:version-url 45 | V 38 46 | /svn/!svn/ver/10/trunk/DDXMLDocument.h 47 | END 48 | DDXML.h 49 | K 25 50 | svn:wc:ra_dav:version-url 51 | V 29 52 | /svn/!svn/ver/3/trunk/DDXML.h 53 | END 54 | DDXMLTesting.m 55 | K 25 56 | svn:wc:ra_dav:version-url 57 | V 37 58 | /svn/!svn/ver/19/trunk/DDXMLTesting.m 59 | END 60 | AppDelegate.h 61 | K 25 62 | svn:wc:ra_dav:version-url 63 | V 35 64 | /svn/!svn/ver/3/trunk/AppDelegate.h 65 | END 66 | NSStringAdditions.m 67 | K 25 68 | svn:wc:ra_dav:version-url 69 | V 41 70 | /svn/!svn/ver/9/trunk/NSStringAdditions.m 71 | END 72 | DDXMLDocument.m 73 | K 25 74 | svn:wc:ra_dav:version-url 75 | V 38 76 | /svn/!svn/ver/19/trunk/DDXMLDocument.m 77 | END 78 | DDXMLNode.h 79 | K 25 80 | svn:wc:ra_dav:version-url 81 | V 33 82 | /svn/!svn/ver/9/trunk/DDXMLNode.h 83 | END 84 | AppDelegate.m 85 | K 25 86 | svn:wc:ra_dav:version-url 87 | V 35 88 | /svn/!svn/ver/3/trunk/AppDelegate.m 89 | END 90 | DDXMLElementAdditions.h 91 | K 25 92 | svn:wc:ra_dav:version-url 93 | V 46 94 | /svn/!svn/ver/11/trunk/DDXMLElementAdditions.h 95 | END 96 | DDXMLElement.h 97 | K 25 98 | svn:wc:ra_dav:version-url 99 | V 37 100 | /svn/!svn/ver/16/trunk/DDXMLElement.h 101 | END 102 | DDXMLNode.m 103 | K 25 104 | svn:wc:ra_dav:version-url 105 | V 34 106 | /svn/!svn/ver/19/trunk/DDXMLNode.m 107 | END 108 | DDXMLElementAdditions.m 109 | K 25 110 | svn:wc:ra_dav:version-url 111 | V 46 112 | /svn/!svn/ver/11/trunk/DDXMLElementAdditions.m 113 | END 114 | DDXMLElement.m 115 | K 25 116 | svn:wc:ra_dav:version-url 117 | V 37 118 | /svn/!svn/ver/19/trunk/DDXMLElement.m 119 | END 120 | -------------------------------------------------------------------------------- /Classes/BasicDataModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // BasicDataModel.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/13/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "BasicDataModel.h" 24 | 25 | 26 | @implementation BasicDataModel 27 | @synthesize state; 28 | @synthesize startTime, elapsedTime; 29 | 30 | 31 | - (id)init{ 32 | self = [super init]; 33 | if (self != nil){ self.state = Neutral; } 34 | 35 | return self; 36 | } 37 | 38 | - (void) dealloc{ 39 | [startTime release]; 40 | [elapsedTime release]; 41 | [super dealloc]; 42 | } 43 | 44 | - (void)bubbleUpError:(NSString *)domain code:(NSInteger)code errorString:(NSString *)errorString{ 45 | NSDictionary *userInfo = [[NSDictionary alloc]initWithObjectsAndKeys:errorString, NSLocalizedDescriptionKey, nil]; 46 | NSError *error = [NSError errorWithDomain:domain code:code userInfo:userInfo]; 47 | [self handleError:error]; 48 | [userInfo release]; 49 | } 50 | 51 | - (void)handleError:(NSError *)error{ 52 | self.state = Error; 53 | NSDictionary *userInfo = [[NSDictionary alloc]initWithObjectsAndKeys:error, @"error", nil]; 54 | [[NSNotificationCenter defaultCenter] postNotificationName:@"error" object:self userInfo:userInfo]; 55 | [userInfo release]; 56 | } 57 | 58 | - (void)handleException:(NSException *)exception{ 59 | self.state = Error; 60 | NSDictionary *userInfo = [[NSDictionary alloc]initWithObjectsAndKeys:exception, @"exception", nil]; 61 | [[NSNotificationCenter defaultCenter] postNotificationName:@"exception" object:self userInfo:userInfo]; 62 | [userInfo release]; 63 | } 64 | 65 | - (void)update:(id)dataModel{ 66 | self.startTime = [NSDate date]; 67 | self.state = Updating; 68 | } 69 | 70 | - (void)refresh{ 71 | self.state = Neutral; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /Classes/HourlyViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HourlyViewController.m 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 7/15/10. 6 | // Copyright 2010 MITRE Corp. All rights reserved. 7 | // 8 | 9 | #import "HourlyViewController.h" 10 | #import "HourlyForecastDataModel.h" 11 | #import "WxDataModel.h" 12 | #import "GraphView.h" 13 | 14 | 15 | @implementation HourlyViewController 16 | @synthesize activityView, activityIndicator; 17 | @synthesize graphView; 18 | 19 | #pragma mark - 20 | #pragma mark NSObject lifecycle methods 21 | 22 | - (id)initWithCoder:(NSCoder *)decoder{ 23 | self = [super initWithCoder:decoder]; 24 | if (self != nil){ 25 | //hourlyForecastDataModel = [WxDataModel dataModel].hourlyForecastDataModel; 26 | } 27 | return self; 28 | } 29 | 30 | - (void)dealloc { 31 | [hourlyForecastDataModel release]; 32 | [super dealloc]; 33 | } 34 | 35 | - (void)didReceiveMemoryWarning{ 36 | DLog(@"memory warning"); 37 | [super didReceiveMemoryWarning]; 38 | } 39 | 40 | #pragma mark - 41 | #pragma mark UIViewController methods 42 | 43 | - (void)viewWillAppear:(BOOL)animated{ 44 | [super viewWillAppear:animated]; 45 | 46 | [hourlyForecastDataModel addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptionNew) context:nil]; 47 | 48 | [self.view.superview addSubview:self.activityView]; 49 | [self dataModelUpdating]; 50 | } 51 | 52 | - (void)viewWillDisappear:(BOOL)animated{ 53 | [super viewWillDisappear:animated]; 54 | 55 | [hourlyForecastDataModel removeObserver:self forKeyPath:@"state"]; 56 | } 57 | 58 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 59 | if ([keyPath isEqual:@"state"]){ 60 | [self dataModelUpdating]; 61 | } 62 | } 63 | 64 | - (void)dataModelUpdating{ 65 | DLog(@"Start"); 66 | 67 | if (hourlyForecastDataModel.state == Updating){ 68 | [self.activityIndicator startAnimating]; 69 | self.activityView.alpha = 0.5; 70 | } else if ((hourlyForecastDataModel.state == Updated) || (hourlyForecastDataModel.state == Error)){ 71 | /*if (hourlyForecastDataModel.hourlyForecast.count != 0){ 72 | [self.tableView reloadData]; 73 | }*/ 74 | [self.activityIndicator stopAnimating]; 75 | self.activityView.alpha = 0.0; 76 | 77 | [graphView setDataFromArray:hourlyForecastDataModel.hourlyForecast 78 | withKeyPath:@"temperature" startAtIndex:0 withLength:48]; 79 | graphView.xAxisLabelFormat = @"%d°"; 80 | 81 | [graphView setNeedsDisplay]; 82 | } 83 | 84 | DLog(@"End"); 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Classes/NetDataModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // NetDataModel.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/13/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "NetDataModel.h" 24 | 25 | 26 | @implementation NetDataModel 27 | @synthesize receivedData, urlRequest, retry; 28 | 29 | - (id) init{ 30 | self = [super init]; 31 | if (self != nil) { 32 | self.receivedData = [[NSMutableData alloc] init]; 33 | } 34 | return self; 35 | } 36 | 37 | - (void) dealloc{ 38 | [urlRequest release]; 39 | [receivedData release]; 40 | [super dealloc]; 41 | } 42 | 43 | - (void)connect:(NSString *)urlString{ 44 | self.retry = YES; 45 | 46 | NSURL *url = [[NSURL alloc]initWithString:urlString]; 47 | self.urlRequest = [[NSURLRequest alloc] initWithURL:url]; 48 | [self retryConnection]; 49 | [url release]; 50 | } 51 | 52 | - (void)retryConnection{ 53 | self.startTime = [NSDate date]; 54 | self.receivedData.length = 0; 55 | 56 | [[NSURLConnection alloc] initWithRequest:self.urlRequest delegate:self startImmediately:YES]; 57 | } 58 | 59 | 60 | - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ 61 | self.receivedData.length = 0; 62 | } 63 | 64 | - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ 65 | [self.receivedData appendData:data]; 66 | } 67 | 68 | - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{ 69 | [connection release]; 70 | 71 | if (self.retry){ 72 | self.retry = NO; 73 | self.receivedData.length = 0; 74 | [self retryConnection]; 75 | } else { 76 | state = Error; 77 | self.receivedData = nil; 78 | [self handleError:error]; 79 | } 80 | } 81 | 82 | - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ 83 | self.elapsedTime = [NSNumber numberWithDouble:-[self.startTime timeIntervalSinceNow]]; 84 | [connection release]; 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Classes/kissxml/DDXMLPrivate.h: -------------------------------------------------------------------------------- 1 | #import "DDXMLNode.h" 2 | #import "DDXMLElement.h" 3 | #import "DDXMLDocument.h" 4 | 5 | // We can't rely solely on NSAssert, because many developers disable them for release builds. 6 | // Our API contract requires us to keep these assertions intact. 7 | #define DDCheck(condition, desc, ...) { if(!(condition)) { [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd object:self file:[NSString stringWithUTF8String:__FILE__] lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; } } 8 | 9 | #define DDLastErrorKey @"DDXML:LastError" 10 | 11 | 12 | @interface DDXMLNode (PrivateAPI) 13 | 14 | + (id)nodeWithUnknownPrimitive:(xmlKindPtr)kindPtr; 15 | 16 | + (id)nodeWithPrimitive:(xmlKindPtr)kindPtr; 17 | - (id)initWithCheckedPrimitive:(xmlKindPtr)kindPtr; 18 | 19 | + (id)nodeWithPrimitive:(xmlNsPtr)ns nsParent:(xmlNodePtr)parent; 20 | - (id)initWithCheckedPrimitive:(xmlNsPtr)ns nsParent:(xmlNodePtr)parent; 21 | 22 | + (BOOL)isXmlAttrPtr:(xmlKindPtr)kindPtr; 23 | - (BOOL)isXmlAttrPtr; 24 | 25 | + (BOOL)isXmlNodePtr:(xmlKindPtr)kindPtr; 26 | - (BOOL)isXmlNodePtr; 27 | 28 | + (BOOL)isXmlDocPtr:(xmlKindPtr)kindPtr; 29 | - (BOOL)isXmlDocPtr; 30 | 31 | + (BOOL)isXmlDtdPtr:(xmlKindPtr)kindPtr; 32 | - (BOOL)isXmlDtdPtr; 33 | 34 | + (BOOL)isXmlNsPtr:(xmlKindPtr)kindPtr; 35 | - (BOOL)isXmlNsPtr; 36 | 37 | - (BOOL)hasParent; 38 | 39 | + (void)recursiveStripDocPointersFromNode:(xmlNodePtr)node; 40 | 41 | + (void)detachAttribute:(xmlAttrPtr)attr fromNode:(xmlNodePtr)node; 42 | + (void)removeAttribute:(xmlAttrPtr)attr fromNode:(xmlNodePtr)node; 43 | + (void)removeAllAttributesFromNode:(xmlNodePtr)node; 44 | 45 | + (void)detachNamespace:(xmlNsPtr)ns fromNode:(xmlNodePtr)node; 46 | + (void)removeNamespace:(xmlNsPtr)ns fromNode:(xmlNodePtr)node; 47 | + (void)removeAllNamespacesFromNode:(xmlNodePtr)node; 48 | 49 | + (void)detachChild:(xmlNodePtr)child fromNode:(xmlNodePtr)node; 50 | + (void)removeChild:(xmlNodePtr)child fromNode:(xmlNodePtr)node; 51 | + (void)removeAllChildrenFromNode:(xmlNodePtr)node; 52 | 53 | + (void)removeAllChildrenFromDoc:(xmlDocPtr)doc; 54 | 55 | - (void)nodeRetain; 56 | - (void)nodeRelease; 57 | 58 | + (NSError *)lastError; 59 | 60 | @end 61 | 62 | @interface DDXMLElement (PrivateAPI) 63 | 64 | + (id)nodeWithPrimitive:(xmlKindPtr)kindPtr; 65 | - (id)initWithCheckedPrimitive:(xmlKindPtr)kindPtr; 66 | 67 | - (NSArray *)elementsWithName:(NSString *)name uri:(NSString *)URI; 68 | 69 | + (DDXMLNode *)resolveNamespaceForPrefix:(NSString *)prefix atNode:(xmlNodePtr)nodePtr; 70 | + (NSString *)resolvePrefixForURI:(NSString *)uri atNode:(xmlNodePtr)nodePtr; 71 | 72 | @end 73 | 74 | @interface DDXMLDocument (PrivateAPI) 75 | 76 | + (id)nodeWithPrimitive:(xmlKindPtr)kindPtr; 77 | - (id)initWithCheckedPrimitive:(xmlKindPtr)kindPtr; 78 | 79 | @end -------------------------------------------------------------------------------- /Classes/URLConnectionHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // URLConnectionHandler.m 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 5/25/09. 6 | // Copyright 2009 Ayal Spitz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "URLConnectionHandler.h" 11 | 12 | 13 | @implementation URLConnectionHandler 14 | @synthesize receivedData, urlRequest; 15 | @synthesize successInvocation, failureInvocation; 16 | 17 | - (id) init{ 18 | self = [super init]; 19 | if (self != nil) { 20 | } 21 | return self; 22 | } 23 | 24 | - (id) initWithTarget:(id)anObject successSelector:(SEL)successSelector failureSelector:(SEL)failureSelector{ 25 | self = [super init]; 26 | if (self != nil) { 27 | NSMethodSignature *sig = [[anObject class] instanceMethodSignatureForSelector:successSelector]; 28 | self.successInvocation = [NSInvocation invocationWithMethodSignature:sig]; 29 | [self.successInvocation setTarget:anObject]; 30 | [self.successInvocation setSelector:successSelector]; 31 | 32 | sig = [[anObject class] instanceMethodSignatureForSelector:failureSelector]; 33 | self.failureInvocation = [NSInvocation invocationWithMethodSignature:sig]; 34 | [self.failureInvocation setTarget:anObject]; 35 | [self.failureInvocation setSelector:failureSelector]; 36 | 37 | self.receivedData = [NSMutableData data]; 38 | } 39 | return self; 40 | } 41 | 42 | - (void)connect:(NSString *)urlString{ 43 | urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]; 44 | [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self]; 45 | } 46 | 47 | 48 | - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ 49 | [self.receivedData setLength:0]; 50 | } 51 | 52 | - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ 53 | [self.receivedData appendData:data]; 54 | } 55 | 56 | - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{ 57 | [self.failureInvocation setArgument:&error atIndex:2]; 58 | [self.failureInvocation retainArguments]; 59 | [self.failureInvocation invoke]; 60 | 61 | [connection release]; 62 | [receivedData release]; 63 | [successInvocation release]; 64 | [failureInvocation release]; 65 | } 66 | 67 | - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ 68 | NSMutableData *data = self.receivedData; 69 | [self.successInvocation setArgument:&data atIndex:2]; 70 | [self.successInvocation retainArguments]; 71 | [self.successInvocation invoke]; 72 | 73 | [connection release]; 74 | [receivedData release]; 75 | [successInvocation release]; 76 | [failureInvocation release]; 77 | } 78 | 79 | - (void)dealloc { 80 | [successInvocation release]; 81 | [failureInvocation release]; 82 | [urlRequest release]; 83 | [super dealloc]; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Classes/AboutViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AboutViewController.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 9/25/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "AboutViewController.h" 24 | 25 | 26 | @implementation AboutViewController 27 | 28 | - (void)viewDidLoad { 29 | [super viewDidLoad]; 30 | 31 | UIWebView *webView = (UIWebView *)(self.view); 32 | 33 | NSString *appVer = [NSString stringWithFormat:@"%@", 34 | [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]; 35 | 36 | NSString *imagePath = [[NSBundle mainBundle] resourcePath]; 37 | imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"]; 38 | imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; 39 | 40 | NSString *filePath = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"]; 41 | NSString *htmlStr = [[NSString alloc] initWithContentsOfFile:filePath 42 | encoding:NSASCIIStringEncoding 43 | error:nil]; 44 | 45 | NSString *modHtmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"VERSION" withString:appVer]; 46 | NSData *htmlData = [modHtmlStr dataUsingEncoding:NSASCIIStringEncoding]; 47 | [htmlStr release]; 48 | 49 | if (htmlData) { 50 | NSString *urlString = [[NSString alloc] initWithFormat:@"file:/%@//",imagePath]; 51 | NSURL *url = [[NSURL alloc] initWithString:urlString]; 52 | 53 | [webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:url]; 54 | 55 | [url release]; 56 | [urlString release]; 57 | } 58 | } 59 | 60 | - (void)dealloc { 61 | [super dealloc]; 62 | } 63 | 64 | - (void)didReceiveMemoryWarning{ 65 | DLog(@"memory warning"); 66 | [super didReceiveMemoryWarning]; 67 | } 68 | 69 | 70 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request 71 | navigationType:(UIWebViewNavigationType)navigationType { 72 | 73 | NSURL *requestURL = request.URL; 74 | 75 | if (requestURL.isFileURL){ 76 | return YES; 77 | } else { 78 | [[UIApplication sharedApplication] openURL:requestURL]; 79 | return NO; 80 | } 81 | } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/DDXMLPrivate.h.svn-base: -------------------------------------------------------------------------------- 1 | #import "DDXMLNode.h" 2 | #import "DDXMLElement.h" 3 | #import "DDXMLDocument.h" 4 | 5 | // We can't rely solely on NSAssert, because many developers disable them for release builds. 6 | // Our API contract requires us to keep these assertions intact. 7 | #define DDCheck(condition, desc, ...) { if(!(condition)) { [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd object:self file:[NSString stringWithUTF8String:__FILE__] lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; } } 8 | 9 | #define DDLastErrorKey @"DDXML:LastError" 10 | 11 | 12 | @interface DDXMLNode (PrivateAPI) 13 | 14 | + (id)nodeWithPrimitive:(xmlKindPtr)nodePtr; 15 | - (id)initWithCheckedPrimitive:(xmlKindPtr)nodePtr; 16 | - (id)initWithUncheckedPrimitive:(xmlKindPtr)nodePtr; 17 | 18 | + (id)nodeWithPrimitive:(xmlKindPtr)nodePtr nsParent:(xmlNodePtr)parentPtr; 19 | - (id)initWithCheckedPrimitive:(xmlKindPtr)nodePtr nsParent:(xmlNodePtr)parentPtr; 20 | - (id)initWithUncheckedPrimitive:(xmlKindPtr)nodePtr nsParent:(xmlNodePtr)parentPtr; 21 | 22 | + (BOOL)isXmlAttrPtr:(xmlKindPtr)kindPtr; 23 | - (BOOL)isXmlAttrPtr; 24 | 25 | + (BOOL)isXmlNodePtr:(xmlKindPtr)kindPtr; 26 | - (BOOL)isXmlNodePtr; 27 | 28 | + (BOOL)isXmlDocPtr:(xmlKindPtr)kindPtr; 29 | - (BOOL)isXmlDocPtr; 30 | 31 | + (BOOL)isXmlDtdPtr:(xmlKindPtr)kindPtr; 32 | - (BOOL)isXmlDtdPtr; 33 | 34 | + (BOOL)isXmlNsPtr:(xmlKindPtr)kindPtr; 35 | - (BOOL)isXmlNsPtr; 36 | 37 | - (BOOL)hasParent; 38 | 39 | + (void)recursiveStripDocPointersFromNode:(xmlNodePtr)node; 40 | 41 | + (void)detachAttribute:(xmlAttrPtr)attr fromNode:(xmlNodePtr)node; 42 | + (void)removeAttribute:(xmlAttrPtr)attr fromNode:(xmlNodePtr)node; 43 | + (void)removeAllAttributesFromNode:(xmlNodePtr)node; 44 | 45 | + (void)detachNamespace:(xmlNsPtr)ns fromNode:(xmlNodePtr)node; 46 | + (void)removeNamespace:(xmlNsPtr)ns fromNode:(xmlNodePtr)node; 47 | + (void)removeAllNamespacesFromNode:(xmlNodePtr)node; 48 | 49 | + (void)detachChild:(xmlNodePtr)child fromNode:(xmlNodePtr)node; 50 | + (void)removeChild:(xmlNodePtr)child fromNode:(xmlNodePtr)node; 51 | + (void)removeAllChildrenFromNode:(xmlNodePtr)node; 52 | 53 | + (void)removeAllChildrenFromDoc:(xmlDocPtr)doc; 54 | 55 | - (void)nodeRetain; 56 | - (void)nodeRelease; 57 | 58 | + (NSError *)lastError; 59 | 60 | @end 61 | 62 | @interface DDXMLElement (PrivateAPI) 63 | 64 | + (id)nodeWithPrimitive:(xmlKindPtr)nodePtr; 65 | - (id)initWithCheckedPrimitive:(xmlKindPtr)nodePtr; 66 | - (id)initWithUncheckedPrimitive:(xmlKindPtr)nodePtr; 67 | 68 | - (NSArray *)elementsWithName:(NSString *)name uri:(NSString *)URI; 69 | 70 | + (DDXMLNode *)resolveNamespaceForPrefix:(NSString *)prefix atNode:(xmlNodePtr)nodePtr; 71 | + (NSString *)resolvePrefixForURI:(NSString *)uri atNode:(xmlNodePtr)nodePtr; 72 | 73 | @end 74 | 75 | @interface DDXMLDocument (PrivateAPI) 76 | 77 | + (id)nodeWithPrimitive:(xmlKindPtr)nodePtr; 78 | - (id)initWithCheckedPrimitive:(xmlKindPtr)nodePtr; 79 | - (id)initWithUncheckedPrimitive:(xmlKindPtr)nodePtr; 80 | 81 | @end -------------------------------------------------------------------------------- /Settings.bundle/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | StringsTable 6 | Root 7 | PreferenceSpecifiers 8 | 9 | 10 | Type 11 | PSGroupSpecifier 12 | Title 13 | General 14 | 15 | 16 | Type 17 | PSToggleSwitchSpecifier 18 | Title 19 | Data View 20 | Key 21 | data_view_preference 22 | DefaultValue 23 | 24 | 25 | 26 | Type 27 | PSMultiValueSpecifier 28 | Title 29 | Map Type 30 | Key 31 | map_type_preference 32 | Values 33 | 34 | Standard 35 | Satellite 36 | Hybrid 37 | 38 | Titles 39 | 40 | Standard 41 | Satellite 42 | Hybrid 43 | 44 | DefaultValue 45 | Standard 46 | 47 | 48 | Type 49 | PSGroupSpecifier 50 | Title 51 | GPS 52 | 53 | 54 | Type 55 | PSMultiValueSpecifier 56 | Title 57 | Minimum Accuracy 58 | Key 59 | gps_accuracy_preference 60 | Values 61 | 62 | 3000 63 | 2500 64 | 2000 65 | 1500 66 | 1000 67 | 500 68 | 250 69 | 100 70 | 50 71 | 72 | Titles 73 | 74 | 3000m 75 | 2500m 76 | 2000m 77 | 1500m 78 | 1000m 79 | 500m 80 | 250m 81 | 100m 82 | 50m 83 | 84 | DefaultValue 85 | 2500 86 | 87 | 88 | Type 89 | PSMultiValueSpecifier 90 | Title 91 | Timeout 92 | Key 93 | gps_timeout_preference 94 | Values 95 | 96 | 30 97 | 20 98 | 15 99 | 10 100 | 7 101 | 5 102 | 103 | Titles 104 | 105 | 30 sec 106 | 20 sec 107 | 15 sec 108 | 10 sec 109 | 7 sec 110 | 5 sec 111 | 112 | DefaultValue 113 | 10 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /Classes/LocationDataModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // LocationDataModel.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 11/2/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "LocationDataModel.h" 24 | #import "DDXML.h" 25 | #import 26 | #import "GPSDataModel.h" 27 | 28 | @implementation LocationDataModel 29 | @synthesize location, city, stateAbbr; 30 | 31 | - (id)init{ 32 | self = [super init]; 33 | if (self != nil) {} 34 | return self; 35 | } 36 | 37 | - (void) dealloc{ 38 | [location release]; 39 | [city release]; 40 | [stateAbbr release]; 41 | [super dealloc]; 42 | } 43 | 44 | - (void)update:(id)dataModel{ 45 | [super update:dataModel]; 46 | GPSDataModel *gpsDataModel = dataModel; 47 | 48 | NSString *urlString = [[NSString alloc] initWithFormat:@"http://api.geonames.org/findNearbyPostalCodes?lat=%f&lng=%f&username=aspitz", 49 | gpsDataModel.location.coordinate.latitude, 50 | gpsDataModel.location.coordinate.longitude]; 51 | DLog(@"%@", urlString); 52 | [self connect:urlString]; 53 | 54 | [urlString release]; 55 | } 56 | 57 | - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ 58 | NSError *error = nil; 59 | DDXMLDocument *xmlDoc = [[DDXMLDocument alloc] initWithData:self.receivedData options:0 error:&error]; 60 | if (error){ 61 | [xmlDoc release]; 62 | [self handleError:error]; 63 | return; 64 | } 65 | DDXMLElement *rootElement = [xmlDoc rootElement]; 66 | NSArray *elements = [rootElement elementsForName:@"code"]; 67 | if ([elements count] == 0){ 68 | [xmlDoc release]; 69 | [self bubbleUpError:@"LocationDataModelErrorDomain" code:0 errorString:@"Unable to extract data"]; 70 | return; 71 | } 72 | DDXMLElement *code = [elements objectAtIndex:0]; 73 | 74 | elements = [code elementsForName:@"name"]; 75 | if ([elements count] == 0){ 76 | [xmlDoc release]; 77 | [self bubbleUpError:@"LocationDataModelErrorDomain" code:1 errorString:@"Unable to extract data"]; 78 | return; 79 | } 80 | self.city = [[elements objectAtIndex:0] stringValue]; 81 | 82 | elements = [code elementsForName:@"adminCode1"]; 83 | if ([elements count] == 0){ 84 | [xmlDoc release]; 85 | [self bubbleUpError:@"LocationDataModelErrorDomain" code:2 errorString:@"Unable to extract data"]; 86 | return; 87 | } 88 | self.stateAbbr = [[elements objectAtIndex:0] stringValue]; 89 | 90 | self.location = [[NSString alloc]initWithFormat:@"%@, %@", self.city, self.stateAbbr]; 91 | DLog(@"%@", self.location); 92 | 93 | self.state = Updated; 94 | 95 | [xmlDoc release]; 96 | [super connectionDidFinishLoading:connection]; 97 | } 98 | 99 | - (void)refresh{ 100 | [super refresh]; 101 | self.location = nil; 102 | self.city = nil; 103 | self.stateAbbr = nil; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/DDXMLDocument.m.svn-base: -------------------------------------------------------------------------------- 1 | #import "DDXMLDocument.h" 2 | #import "NSStringAdditions.h" 3 | #import "DDXMLPrivate.h" 4 | 5 | 6 | @implementation DDXMLDocument 7 | 8 | + (id)nodeWithPrimitive:(xmlKindPtr)nodePtr 9 | { 10 | if(nodePtr == NULL || nodePtr->type != XML_DOCUMENT_NODE) 11 | { 12 | return nil; 13 | } 14 | 15 | xmlDocPtr doc = (xmlDocPtr)nodePtr; 16 | if(doc->_private == NULL) 17 | return [[[DDXMLDocument alloc] initWithCheckedPrimitive:nodePtr] autorelease]; 18 | else 19 | return [[((DDXMLDocument *)(doc->_private)) retain] autorelease]; 20 | } 21 | 22 | - (id)initWithUncheckedPrimitive:(xmlKindPtr)nodePtr 23 | { 24 | if(nodePtr == NULL || nodePtr->type != XML_DOCUMENT_NODE) 25 | { 26 | [self release]; 27 | return nil; 28 | } 29 | 30 | xmlDocPtr doc = (xmlDocPtr)nodePtr; 31 | if(doc->_private == NULL) 32 | { 33 | return [self initWithCheckedPrimitive:nodePtr]; 34 | } 35 | else 36 | { 37 | [self release]; 38 | return [((DDXMLDocument *)(doc->_private)) retain]; 39 | } 40 | } 41 | 42 | - (id)initWithCheckedPrimitive:(xmlKindPtr)nodePtr 43 | { 44 | self = [super initWithCheckedPrimitive:nodePtr]; 45 | return self; 46 | } 47 | 48 | /** 49 | * Initializes and returns a DDXMLDocument object created from an NSData object. 50 | * 51 | * Returns an initialized DDXMLDocument object, or nil if initialization fails 52 | * because of parsing errors or other reasons. 53 | **/ 54 | - (id)initWithXMLString:(NSString *)string options:(NSUInteger)mask error:(NSError **)error 55 | { 56 | return [self initWithData:[string dataUsingEncoding:NSUTF8StringEncoding] options:mask error:error]; 57 | } 58 | 59 | /** 60 | * Initializes and returns a DDXMLDocument object created from an NSData object. 61 | * 62 | * Returns an initialized DDXMLDocument object, or nil if initialization fails 63 | * because of parsing errors or other reasons. 64 | **/ 65 | - (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)error 66 | { 67 | if(data == nil || [data length] == 0) 68 | { 69 | if(error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:0 userInfo:nil]; 70 | 71 | [self release]; 72 | return nil; 73 | } 74 | 75 | // Even though xmlKeepBlanksDefault(0) is called in DDXMLNode's initialize method, 76 | // it has been documented that this call seems to get reset on the iPhone: 77 | // http://code.google.com/p/kissxml/issues/detail?id=8 78 | // 79 | // Therefore, we call it again here just to be safe. 80 | xmlKeepBlanksDefault(0); 81 | 82 | xmlDocPtr doc = xmlParseMemory([data bytes], [data length]); 83 | if(doc == NULL) 84 | { 85 | if(error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:1 userInfo:nil]; 86 | 87 | [self release]; 88 | return nil; 89 | } 90 | 91 | return [self initWithCheckedPrimitive:(xmlKindPtr)doc]; 92 | } 93 | 94 | /** 95 | * Returns the root element of the receiver. 96 | **/ 97 | - (DDXMLElement *)rootElement 98 | { 99 | xmlDocPtr doc = (xmlDocPtr)genericPtr; 100 | 101 | // doc->children is a list containing possibly comments, DTDs, etc... 102 | 103 | xmlNodePtr rootNode = xmlDocGetRootElement(doc); 104 | 105 | if(rootNode != NULL) 106 | return [DDXMLElement nodeWithPrimitive:(xmlKindPtr)(rootNode)]; 107 | else 108 | return nil; 109 | } 110 | 111 | - (NSData *)XMLData 112 | { 113 | return [[self XMLString] dataUsingEncoding:NSUTF8StringEncoding]; 114 | } 115 | 116 | - (NSData *)XMLDataWithOptions:(NSUInteger)options 117 | { 118 | return [[self XMLStringWithOptions:options] dataUsingEncoding:NSUTF8StringEncoding]; 119 | } 120 | 121 | @end 122 | -------------------------------------------------------------------------------- /Classes/kissxml/DDXMLElementAdditions.m: -------------------------------------------------------------------------------- 1 | #import "DDXMLElementAdditions.h" 2 | 3 | @implementation DDXMLElement (DDAdditions) 4 | 5 | /** 6 | * Quick method to create an element 7 | **/ 8 | + (DDXMLElement *)elementWithName:(NSString *)name xmlns:(NSString *)ns 9 | { 10 | DDXMLElement *element = [DDXMLElement elementWithName:name]; 11 | [element setXmlns:ns]; 12 | return element; 13 | } 14 | 15 | /** 16 | * This method returns the first child element for the given name. 17 | * If no child element exists for the given name, returns nil. 18 | **/ 19 | - (DDXMLElement *)elementForName:(NSString *)name 20 | { 21 | NSArray *elements = [self elementsForName:name]; 22 | if([elements count] > 0) 23 | { 24 | return [elements objectAtIndex:0]; 25 | } 26 | else 27 | { 28 | // Note: If you port this code to work with Apple's NSXML, beware of the following: 29 | // 30 | // There is a bug in the NSXMLElement elementsForName: method. 31 | // Consider the following XML fragment: 32 | // 33 | // 34 | // 35 | // 36 | // 37 | // Calling [query elementsForName:@"x"] results in an empty array! 38 | // 39 | // However, it will work properly if you use the following: 40 | // [query elementsForLocalName:@"x" URI:@"some:other:namespace"] 41 | // 42 | // The trouble with this is that we may not always know the xmlns in advance, 43 | // so in this particular case there is no way to access the element without looping through the children. 44 | // 45 | // This bug was submitted to apple on June 1st, 2007 and was classified as "serious". 46 | // 47 | // --!!-- This bug does NOT exist in DDXML --!!-- 48 | 49 | return nil; 50 | } 51 | } 52 | 53 | /** 54 | * This method returns the first child element for the given name and given xmlns. 55 | * If no child elements exist for the given name and given xmlns, returns nil. 56 | **/ 57 | - (DDXMLElement *)elementForName:(NSString *)name xmlns:(NSString *)xmlns 58 | { 59 | NSArray *elements = [self elementsForLocalName:name URI:xmlns]; 60 | if([elements count] > 0) 61 | { 62 | return [elements objectAtIndex:0]; 63 | } 64 | else 65 | { 66 | return nil; 67 | } 68 | } 69 | 70 | /** 71 | * Returns the common xmlns "attribute", which is only accessible via the namespace methods. 72 | * The xmlns value is often used in jabber elements. 73 | **/ 74 | - (NSString *)xmlns 75 | { 76 | return [[self namespaceForPrefix:@""] stringValue]; 77 | } 78 | 79 | - (void)setXmlns:(NSString *)ns 80 | { 81 | // If you use setURI: then the xmlns won't be displayed in the XMLString. 82 | // Adding the namespace this way works properly. 83 | // 84 | // This applies to both Apple's NSXML and DDXML. 85 | 86 | [self addNamespace:[DDXMLNode namespaceWithName:@"" stringValue:ns]]; 87 | } 88 | 89 | /** 90 | * Shortcut to avoid having to manually create a DDXMLNode everytime. 91 | **/ 92 | - (void)addAttributeWithName:(NSString *)name stringValue:(NSString *)string 93 | { 94 | [self addAttribute:[DDXMLNode attributeWithName:name stringValue:string]]; 95 | } 96 | 97 | /** 98 | * Returns all the attributes as a dictionary. 99 | **/ 100 | - (NSDictionary *)attributesAsDictionary 101 | { 102 | NSArray *attributes = [self attributes]; 103 | NSMutableDictionary *result = [NSMutableDictionary dictionaryWithCapacity:[attributes count]]; 104 | 105 | uint i; 106 | for(i = 0; i < [attributes count]; i++) 107 | { 108 | DDXMLNode *node = [attributes objectAtIndex:i]; 109 | 110 | [result setObject:[node stringValue] forKey:[node name]]; 111 | } 112 | return result; 113 | } 114 | 115 | @end 116 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/DDXMLElementAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | #import "DDXMLElementAdditions.h" 2 | 3 | @implementation DDXMLElement (DDAdditions) 4 | 5 | /** 6 | * Quick method to create an element 7 | **/ 8 | + (DDXMLElement *)elementWithName:(NSString *)name xmlns:(NSString *)ns 9 | { 10 | DDXMLElement *element = [DDXMLElement elementWithName:name]; 11 | [element setXmlns:ns]; 12 | return element; 13 | } 14 | 15 | /** 16 | * This method returns the first child element for the given name. 17 | * If no child element exists for the given name, returns nil. 18 | **/ 19 | - (DDXMLElement *)elementForName:(NSString *)name 20 | { 21 | NSArray *elements = [self elementsForName:name]; 22 | if([elements count] > 0) 23 | { 24 | return [elements objectAtIndex:0]; 25 | } 26 | else 27 | { 28 | // Note: If you port this code to work with Apple's NSXML, beware of the following: 29 | // 30 | // There is a bug in the NSXMLElement elementsForName: method. 31 | // Consider the following XML fragment: 32 | // 33 | // 34 | // 35 | // 36 | // 37 | // Calling [query elementsForName:@"x"] results in an empty array! 38 | // 39 | // However, it will work properly if you use the following: 40 | // [query elementsForLocalName:@"x" URI:@"some:other:namespace"] 41 | // 42 | // The trouble with this is that we may not always know the xmlns in advance, 43 | // so in this particular case there is no way to access the element without looping through the children. 44 | // 45 | // This bug was submitted to apple on June 1st, 2007 and was classified as "serious". 46 | // 47 | // --!!-- This bug does NOT exist in DDXML --!!-- 48 | 49 | return nil; 50 | } 51 | } 52 | 53 | /** 54 | * This method returns the first child element for the given name and given xmlns. 55 | * If no child elements exist for the given name and given xmlns, returns nil. 56 | **/ 57 | - (DDXMLElement *)elementForName:(NSString *)name xmlns:(NSString *)xmlns 58 | { 59 | NSArray *elements = [self elementsForLocalName:name URI:xmlns]; 60 | if([elements count] > 0) 61 | { 62 | return [elements objectAtIndex:0]; 63 | } 64 | else 65 | { 66 | return nil; 67 | } 68 | } 69 | 70 | /** 71 | * Returns the common xmlns "attribute", which is only accessible via the namespace methods. 72 | * The xmlns value is often used in jabber elements. 73 | **/ 74 | - (NSString *)xmlns 75 | { 76 | return [[self namespaceForPrefix:@""] stringValue]; 77 | } 78 | 79 | - (void)setXmlns:(NSString *)ns 80 | { 81 | // If you use setURI: then the xmlns won't be displayed in the XMLString. 82 | // Adding the namespace this way works properly. 83 | // 84 | // This applies to both Apple's NSXML and DDXML. 85 | 86 | [self addNamespace:[DDXMLNode namespaceWithName:@"" stringValue:ns]]; 87 | } 88 | 89 | /** 90 | * Shortcut to avoid having to manually create a DDXMLNode everytime. 91 | **/ 92 | - (void)addAttributeWithName:(NSString *)name stringValue:(NSString *)string 93 | { 94 | [self addAttribute:[DDXMLNode attributeWithName:name stringValue:string]]; 95 | } 96 | 97 | /** 98 | * Returns all the attributes as a dictionary. 99 | **/ 100 | - (NSDictionary *)attributesAsDictionary 101 | { 102 | NSArray *attributes = [self attributes]; 103 | NSMutableDictionary *result = [NSMutableDictionary dictionaryWithCapacity:[attributes count]]; 104 | 105 | uint i; 106 | for(i = 0; i < [attributes count]; i++) 107 | { 108 | DDXMLNode *node = [attributes objectAtIndex:i]; 109 | 110 | [result setObject:[node stringValue] forKey:[node name]]; 111 | } 112 | return result; 113 | } 114 | 115 | @end 116 | -------------------------------------------------------------------------------- /Classes/kissxml/DDXMLDocument.m: -------------------------------------------------------------------------------- 1 | #import "DDXMLDocument.h" 2 | #import "NSStringAdditions.h" 3 | #import "DDXMLPrivate.h" 4 | 5 | 6 | @implementation DDXMLDocument 7 | 8 | /** 9 | * Returns a DDXML wrapper object for the given primitive node. 10 | * The given node MUST be non-NULL and of the proper type. 11 | * 12 | * If the wrapper object already exists, it is retained/autoreleased and returned. 13 | * Otherwise a new wrapper object is alloc/init/autoreleased and returned. 14 | **/ 15 | + (id)nodeWithPrimitive:(xmlKindPtr)kindPtr 16 | { 17 | // If a wrapper object already exists, the _private variable is pointing to it. 18 | 19 | xmlDocPtr doc = (xmlDocPtr)kindPtr; 20 | if(doc->_private == NULL) 21 | return [[[DDXMLDocument alloc] initWithCheckedPrimitive:kindPtr] autorelease]; 22 | else 23 | return [[((DDXMLDocument *)(doc->_private)) retain] autorelease]; 24 | } 25 | 26 | /** 27 | * Returns a DDXML wrapper object for the given primitive node. 28 | * The given node MUST be non-NULL and of the proper type. 29 | * 30 | * The given node is checked, meaning a wrapper object for it does not already exist. 31 | **/ 32 | - (id)initWithCheckedPrimitive:(xmlKindPtr)kindPtr 33 | { 34 | self = [super initWithCheckedPrimitive:kindPtr]; 35 | return self; 36 | } 37 | 38 | /** 39 | * Initializes and returns a DDXMLDocument object created from an NSData object. 40 | * 41 | * Returns an initialized DDXMLDocument object, or nil if initialization fails 42 | * because of parsing errors or other reasons. 43 | **/ 44 | - (id)initWithXMLString:(NSString *)string options:(NSUInteger)mask error:(NSError **)error 45 | { 46 | return [self initWithData:[string dataUsingEncoding:NSUTF8StringEncoding] options:mask error:error]; 47 | } 48 | 49 | /** 50 | * Initializes and returns a DDXMLDocument object created from an NSData object. 51 | * 52 | * Returns an initialized DDXMLDocument object, or nil if initialization fails 53 | * because of parsing errors or other reasons. 54 | **/ 55 | - (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)error 56 | { 57 | if(data == nil || [data length] == 0) 58 | { 59 | if(error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:0 userInfo:nil]; 60 | 61 | [self release]; 62 | return nil; 63 | } 64 | 65 | // Even though xmlKeepBlanksDefault(0) is called in DDXMLNode's initialize method, 66 | // it has been documented that this call seems to get reset on the iPhone: 67 | // http://code.google.com/p/kissxml/issues/detail?id=8 68 | // 69 | // Therefore, we call it again here just to be safe. 70 | xmlKeepBlanksDefault(0); 71 | 72 | xmlDocPtr doc = xmlParseMemory([data bytes], [data length]); 73 | if(doc == NULL) 74 | { 75 | if(error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:1 userInfo:nil]; 76 | 77 | [self release]; 78 | return nil; 79 | } 80 | 81 | return [self initWithCheckedPrimitive:(xmlKindPtr)doc]; 82 | } 83 | 84 | /** 85 | * Returns the root element of the receiver. 86 | **/ 87 | - (DDXMLElement *)rootElement 88 | { 89 | xmlDocPtr doc = (xmlDocPtr)genericPtr; 90 | 91 | // doc->children is a list containing possibly comments, DTDs, etc... 92 | 93 | xmlNodePtr rootNode = xmlDocGetRootElement(doc); 94 | 95 | if(rootNode != NULL) 96 | return [DDXMLElement nodeWithPrimitive:(xmlKindPtr)rootNode]; 97 | else 98 | return nil; 99 | } 100 | 101 | - (NSData *)XMLData 102 | { 103 | return [[self XMLString] dataUsingEncoding:NSUTF8StringEncoding]; 104 | } 105 | 106 | - (NSData *)XMLDataWithOptions:(NSUInteger)options 107 | { 108 | return [[self XMLStringWithOptions:options] dataUsingEncoding:NSUTF8StringEncoding]; 109 | } 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /assets/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WxHere - About... 5 | 86 | 87 | 88 | 89 |
90 | WxHere 91 |
92 | 93 |
94 |
95 | Map data 96 | by Google
97 |
98 | 99 |
100 | Geographic data 101 | by GeoNames
102 |
103 | 104 |
105 | Weather data 106 | by NOAA
107 |
108 | 109 |
110 | iPhone XML library 111 | by KissXML
112 |
113 | 114 |
115 | Toolbar icons 116 | by Joseph Wain
117 |
118 | 119 |
120 | Weather icons 121 | by Digital*CHET
122 |
123 |
124 | 125 | 128 | 129 |
130 | Version VERSION
131 | © 2010 Ayal Spitz 132 |
133 | 134 | -------------------------------------------------------------------------------- /Classes/GPSDataModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // GPSDataModel.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/11/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "GPSDataModel.h" 24 | #import 25 | #import "NSUserDefaults-Defaults.h" 26 | 27 | @implementation GPSDataModel 28 | @synthesize location; 29 | 30 | - (id) init{ 31 | self = [super init]; 32 | if (self != nil) { 33 | // Read in 'gps_timeout_preference' 34 | timeout = [[NSUserDefaults standardUserDefaults] integerForKey:@"gps_timeout_preference" defaultValue:10]; 35 | DLog(@"GPS timeout: %d", timeout); 36 | 37 | // Read in 'gps_accuracy_preference' 38 | minAccuracy = [[NSUserDefaults standardUserDefaults] integerForKey:@"gps_accuracy_preference" defaultValue:2500]; 39 | DLog(@"GPS min accuracy: %d", minAccuracy); 40 | } 41 | return self; 42 | } 43 | 44 | - (void)dealloc{ 45 | [locationManager release]; 46 | [location release]; 47 | [super dealloc]; 48 | } 49 | 50 | 51 | - (void)update:(id)dataModel{ 52 | DLog(@"Start"); 53 | 54 | [super update:dataModel]; 55 | 56 | if (locationManager == nil){ 57 | locationManager = [[CLLocationManager alloc] init]; 58 | } 59 | locationManager.delegate = self; 60 | locationManager.desiredAccuracy = kCLLocationAccuracyBest; 61 | [locationManager startUpdatingLocation]; 62 | 63 | [self performSelector:@selector(stopLocationManager:) withObject:nil afterDelay:timeout]; 64 | 65 | DLog(@"End"); 66 | } 67 | 68 | - (void)stopLocationManager:(id)sender{ 69 | DLog(@"Start"); 70 | 71 | if (self.state == Updating){ 72 | self.state = Updated; 73 | [locationManager stopUpdatingLocation]; 74 | [[self class] cancelPreviousPerformRequestsWithTarget: self]; 75 | 76 | self.elapsedTime = [[NSNumber alloc] initWithDouble:fabs([self.startTime timeIntervalSinceNow])]; 77 | } 78 | 79 | DLog(@"End"); 80 | } 81 | 82 | #pragma mark - 83 | #pragma mark CLLocationManagerDelegate Protocol implementation 84 | 85 | - (void)locationManager:(CLLocationManager *)locatioManager 86 | didUpdateToLocation:(CLLocation *)newLocation 87 | fromLocation:(CLLocation *)oldLocation{ 88 | 89 | DLog(@"Star"); 90 | #ifndef DEBUG 91 | self.location = newLocation; 92 | DLog(@"%@",self.location); 93 | 94 | NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow]; 95 | if (locationAge > 5.0) return; 96 | 97 | if (self.location.horizontalAccuracy <= minAccuracy){ 98 | [self stopLocationManager:nil]; 99 | } 100 | #else 101 | CLLocation *debugLocation = [[CLLocation alloc] initWithLatitude:42.3665 102 | longitude:-71.2358]; 103 | self.location = debugLocation; 104 | [debugLocation release]; 105 | [self stopLocationManager:nil]; 106 | #endif 107 | DLog(@"End"); 108 | } 109 | 110 | - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{ 111 | NSDictionary *userInfo = [NSDictionary dictionaryWithObject:error forKey:@"error"]; 112 | [[NSNotificationCenter defaultCenter] postNotificationName:@"error" object:self userInfo:userInfo]; 113 | } 114 | 115 | - (void)refresh{ 116 | [super refresh]; 117 | [locationManager release]; 118 | locationManager = nil; 119 | self.location = nil; 120 | } 121 | 122 | @end -------------------------------------------------------------------------------- /Classes/WxHereAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // WxHereAppDelegate.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 5/8/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "WxHereAppDelegate.h" 24 | #import "WxDataModel.h" 25 | #import "DataViewController.h" 26 | 27 | @implementation WxHereAppDelegate 28 | 29 | @synthesize wxDataModel; 30 | @synthesize window; 31 | @synthesize tabBarController; 32 | 33 | 34 | #pragma mark - 35 | #pragma mark Application lifecycle 36 | 37 | - (void)applicationDidFinishLaunching:(UIApplication *)application { 38 | [self addNotificationObservers]; 39 | self.wxDataModel = [WxDataModel dataModel]; 40 | 41 | if (![[NSUserDefaults standardUserDefaults] boolForKey:@"data_view_preference"]){ 42 | NSMutableArray *viewControllerArray = [NSMutableArray arrayWithArray:tabBarController.viewControllers]; 43 | //DataViewController *viewController = [viewControllerArray objectAtIndex:2]; 44 | //[viewController removeObservers]; 45 | [viewControllerArray removeObjectAtIndex:2]; 46 | tabBarController.viewControllers = viewControllerArray; 47 | } 48 | 49 | // Override point for customization after app launch 50 | [window addSubview:tabBarController.view]; 51 | [window makeKeyAndVisible]; 52 | 53 | [self.wxDataModel update:nil]; 54 | } 55 | 56 | 57 | #pragma mark - 58 | #pragma mark Application's Documents directory 59 | 60 | /** 61 | Returns the path to the application's Documents directory. 62 | */ 63 | - (NSString *)applicationDocumentsDirectory { 64 | return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 65 | } 66 | 67 | 68 | #pragma mark - 69 | #pragma mark Memory management 70 | 71 | - (void)dealloc { 72 | [tabBarController release]; 73 | 74 | [window release]; 75 | [super dealloc]; 76 | } 77 | 78 | #pragma mark - 79 | #pragma mark Notification handeling 80 | 81 | - (void)addNotificationObservers{ 82 | [[NSNotificationCenter defaultCenter] addObserver:self 83 | selector:@selector(handleErrorNotification:) 84 | name:@"error" 85 | object:nil]; 86 | [[NSNotificationCenter defaultCenter] addObserver:self 87 | selector:@selector(handleExceptionNotification:) 88 | name:@"exception" 89 | object:nil]; 90 | } 91 | 92 | - (void)handleErrorNotification:(NSNotification *)notification{ 93 | DLog(@"%@",notification.object); 94 | DLog(@"%@",notification.userInfo); 95 | NSError *error = [notification.userInfo valueForKey:@"error"]; 96 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"An error has occured!" 97 | message:error.localizedDescription 98 | delegate:nil 99 | cancelButtonTitle:@"OK" 100 | otherButtonTitles:nil]; 101 | [alert show]; 102 | [alert release]; 103 | } 104 | 105 | - (void)handleExceptionNotification:(NSNotification *)notification{ 106 | NSException *exception = [notification.userInfo valueForKey:@"exception"]; 107 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"An exception has occured!" 108 | message:exception.reason 109 | delegate:nil 110 | cancelButtonTitle:@"OK" 111 | otherButtonTitles:nil]; 112 | [alert show]; 113 | [alert release]; 114 | } 115 | @end -------------------------------------------------------------------------------- /Classes/CurrentConditionsDataModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // CurrentConditionsDataModel.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 10/25/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "CurrentConditionsDataModel.h" 24 | #import "GPSDataModel.h" 25 | #import "ICAOList.h" 26 | #import "DDXML.h" 27 | #import 28 | #import "WxHereAppDelegate.h" 29 | 30 | @implementation CurrentConditionsDataModel 31 | @synthesize icao; 32 | @synthesize location, temperature, condition; 33 | @synthesize conditionImage; 34 | 35 | - (id)init{ 36 | self = [super init]; 37 | if (self != nil) { 38 | icaoList = [[ICAOList alloc]init]; 39 | 40 | NSString *filePath = nil; 41 | 42 | filePath = [[NSBundle mainBundle] pathForResource:@"Categories" ofType:@"plist"]; 43 | categoryToImageDictionary = [[NSDictionary alloc]initWithContentsOfFile:filePath]; 44 | 45 | filePath = [[NSBundle mainBundle] pathForResource:@"Weather" ofType:@"plist"]; 46 | conditionToCategoryDictionary = [[NSDictionary alloc]initWithContentsOfFile:filePath]; 47 | } 48 | return self; 49 | } 50 | 51 | - (void) dealloc{ 52 | [icaoList release]; 53 | [icao release]; 54 | [temperature release]; 55 | [condition release]; 56 | [conditionImage release]; 57 | 58 | [categoryToImageDictionary release]; 59 | [conditionToCategoryDictionary release]; 60 | 61 | [super dealloc]; 62 | } 63 | 64 | - (void)update:(id)dataModel{ 65 | [super update:dataModel]; 66 | 67 | GPSDataModel *gpsDataModel = dataModel; 68 | 69 | self.icao = [icaoList closestICAOtoLat:gpsDataModel.location.coordinate.latitude 70 | Lon:gpsDataModel.location.coordinate.longitude]; 71 | 72 | NSString *urlString = [[NSString alloc] initWithFormat:@"http://www.weather.gov/xml/current_obs/%@.xml", self.icao]; 73 | DLog(@"%@", urlString); 74 | [self connect:urlString]; 75 | 76 | [urlString release]; 77 | } 78 | 79 | - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ 80 | NSError *error = nil; 81 | DDXMLDocument *xmlDoc = [[DDXMLDocument alloc] initWithData:self.receivedData options:0 error:&error]; 82 | if (error){ 83 | [xmlDoc release]; 84 | [self bubbleUpError:@"CurrentConditionsDataModelErrorDomain" code:0 errorString:@"Unable to extract data"]; 85 | //[self handleError:error]; 86 | return; 87 | } 88 | DDXMLElement *rootElement = [xmlDoc rootElement]; 89 | 90 | DLog(@"%@",xmlDoc); 91 | NSArray *elements = [rootElement elementsForName:@"location"]; 92 | if ([elements count] == 0){ 93 | [xmlDoc release]; 94 | [self bubbleUpError:@"CurrentConditionsDataModelErrorDomain" code:1 errorString:@"Unable to extract data"]; 95 | return; 96 | } 97 | self.location = [[elements objectAtIndex:0] stringValue]; 98 | 99 | elements = [rootElement elementsForName:@"temp_f"]; 100 | if ([elements count] == 0){ 101 | [xmlDoc release]; 102 | [self bubbleUpError:@"CurrentConditionsDataModelErrorDomain" code:2 errorString:@"Unable to extract data"]; 103 | return; 104 | } 105 | self.temperature = [[elements objectAtIndex:0] stringValue]; 106 | self.temperature = [self.temperature substringToIndex:([self.temperature length] - 2)]; 107 | 108 | elements = [rootElement elementsForName:@"weather"]; 109 | if ([elements count] == 0){ 110 | [xmlDoc release]; 111 | [self bubbleUpError:@"CurrentConditionsDataModelErrorDomain" code:3 errorString:@"Unable to extract data"]; 112 | return; 113 | } 114 | self.condition = [[elements objectAtIndex:0] stringValue]; 115 | DLog(@"Current condition: %@", self.condition); 116 | NSString *category = [conditionToCategoryDictionary objectForKey:self.condition]; 117 | DLog(@"Current condition category: %@", category); 118 | NSString *imageName = [categoryToImageDictionary objectForKey:category]; 119 | DLog(@"Current condition image: %@", imageName); 120 | self.conditionImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]]; 121 | 122 | self.state = Updated; 123 | 124 | [xmlDoc release]; 125 | [super connectionDidFinishLoading:connection]; 126 | } 127 | 128 | #pragma mark - 129 | 130 | - (void)refresh{ 131 | [super refresh]; 132 | self.icao = nil; 133 | self.location = nil; 134 | self.temperature = nil; 135 | self.condition = nil; 136 | self.conditionImage = nil; 137 | } 138 | 139 | @end 140 | -------------------------------------------------------------------------------- /Classes/WxDataModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // WxDataModel.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/31/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "WxDataModel.h" 24 | 25 | #import "GPSDataModel.h" 26 | #import "LocationDataModel.h" 27 | #import "CurrentConditionsDataModel.h" 28 | #import "NOAADataModel.h" 29 | #import "HourlyForecastDataModel.h" 30 | 31 | @implementation WxDataModel 32 | @synthesize gpsDataModel; 33 | @synthesize locationDataModel; 34 | @synthesize currentConditionsDataModel; 35 | @synthesize noaaDataModel; 36 | //@synthesize hourlyForecastDataModel; 37 | 38 | #pragma mark Singelton 39 | 40 | static WxDataModel *wxDataModel = nil; 41 | 42 | + (WxDataModel *)dataModel{ 43 | @synchronized(self) { 44 | if (wxDataModel == nil) { 45 | wxDataModel = [[self alloc] init]; // assignment not done here 46 | } 47 | } 48 | 49 | return wxDataModel; 50 | } 51 | 52 | #pragma mark - 53 | 54 | - (id) init{ 55 | self = [super init]; 56 | if (self != nil) { 57 | gpsDataModel = [[GPSDataModel alloc]init]; 58 | locationDataModel = [[LocationDataModel alloc]init]; 59 | currentConditionsDataModel = [[CurrentConditionsDataModel alloc]init]; 60 | noaaDataModel = [[NOAADataModel alloc]init]; 61 | //hourlyForecastDataModel = [[HourlyForecastDataModel alloc]init]; 62 | 63 | done = 0; 64 | 65 | [self addObservers]; 66 | } 67 | return self; 68 | } 69 | 70 | - (void) dealloc{ 71 | [gpsDataModel release]; 72 | [locationDataModel release]; 73 | [currentConditionsDataModel release]; 74 | [noaaDataModel release]; 75 | //[hourlyForecastDataModel release]; 76 | 77 | [super dealloc]; 78 | } 79 | 80 | #pragma mark - 81 | #pragma mark Notification handeling 82 | 83 | - (void)addObservers{ 84 | [[NSNotificationCenter defaultCenter] addObserver:self 85 | selector:@selector(handleErrorNotification:) 86 | name:@"error" 87 | object:nil]; 88 | [[NSNotificationCenter defaultCenter] addObserver:self 89 | selector:@selector(handleErrorNotification:) 90 | name:@"exception" 91 | object:nil]; 92 | 93 | 94 | [self.gpsDataModel addObserver:self forKeyPath:@"state" options:0 context:NULL]; 95 | [self.locationDataModel addObserver:self forKeyPath:@"state" options:0 context:NULL]; 96 | [self.currentConditionsDataModel addObserver:self forKeyPath:@"state" options:0 context:NULL]; 97 | [self.noaaDataModel addObserver:self forKeyPath:@"state" options:0 context:NULL]; 98 | //[self.hourlyForecastDataModel addObserver:self forKeyPath:@"state" options:0 context:NULL]; 99 | } 100 | 101 | - (void)handleErrorNotification:(NSNotification *)notification{ 102 | self.state = Error; 103 | } 104 | 105 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 106 | if ([keyPath isEqual:@"state"]){ 107 | if ([object state] == Error){ 108 | // If the state of one of the sub data models returns an error then 109 | // this data model is in error state too 110 | self.state = Error; 111 | } else { 112 | if ([object class] == [GPSDataModel class]){ 113 | if (self.gpsDataModel.state == Updated){ 114 | [self.locationDataModel update:gpsDataModel]; 115 | [self.currentConditionsDataModel update:gpsDataModel]; 116 | [self.noaaDataModel update:gpsDataModel]; 117 | //[self.hourlyForecastDataModel update:gpsDataModel]; 118 | } 119 | } else if ([object class] == [LocationDataModel class]){ 120 | if (self.locationDataModel.state == Updated){ 121 | done += 1; 122 | } 123 | } else if ([object class] == [CurrentConditionsDataModel class]){ 124 | if (self.currentConditionsDataModel.state == Updated){ 125 | done += 2; 126 | } 127 | } else if ([object class] == [NOAADataModel class]){ 128 | if (self.noaaDataModel.state == Updated){ 129 | done += 4; 130 | } 131 | } else if ([object class] == [NOAADataModel class]){ 132 | if (self.noaaDataModel.state == Updated){ 133 | done += 8; 134 | } 135 | } 136 | 137 | if (done == 7){ 138 | self.state = Updated; 139 | self.elapsedTime = [NSNumber numberWithDouble:([self.startTime timeIntervalSinceNow] * -1.0)]; 140 | } 141 | } 142 | } 143 | } 144 | 145 | #pragma mark - 146 | 147 | - (void)update:(id)dataModel{ 148 | [super update:dataModel]; 149 | [self.gpsDataModel update:nil]; 150 | } 151 | 152 | - (void)refresh{ 153 | [super refresh]; 154 | done = 0; 155 | 156 | [gpsDataModel refresh]; 157 | [locationDataModel refresh]; 158 | [currentConditionsDataModel refresh]; 159 | [noaaDataModel refresh]; 160 | //[hourlyForecastDataModel refresh]; 161 | 162 | [self update:nil]; 163 | } 164 | 165 | @end -------------------------------------------------------------------------------- /Classes/kissxml/DDXMLNode.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @class DDXMLDocument; 5 | 6 | 7 | enum { 8 | DDXMLInvalidKind = 0, 9 | DDXMLDocumentKind = XML_DOCUMENT_NODE, 10 | DDXMLElementKind = XML_ELEMENT_NODE, 11 | DDXMLAttributeKind = XML_ATTRIBUTE_NODE, 12 | DDXMLNamespaceKind = XML_NAMESPACE_DECL, 13 | DDXMLProcessingInstructionKind = XML_PI_NODE, 14 | DDXMLCommentKind = XML_COMMENT_NODE, 15 | DDXMLTextKind = XML_TEXT_NODE, 16 | DDXMLDTDKind = XML_DTD_NODE, 17 | DDXMLEntityDeclarationKind = XML_ENTITY_DECL, 18 | DDXMLAttributeDeclarationKind = XML_ATTRIBUTE_DECL, 19 | DDXMLElementDeclarationKind = XML_ELEMENT_DECL, 20 | DDXMLNotationDeclarationKind = XML_NOTATION_NODE 21 | }; 22 | typedef NSUInteger DDXMLNodeKind; 23 | 24 | enum { 25 | DDXMLNodeOptionsNone = 0, 26 | DDXMLNodeExpandEmptyElement = 1 << 1, 27 | DDXMLNodeCompactEmptyElement = 1 << 2, 28 | DDXMLNodePrettyPrint = 1 << 17, 29 | }; 30 | 31 | /** 32 | * DDXMLNode can represent several underlying types, such as xmlNodePtr, xmlDocPtr, xmlAttrPtr, xmlNsPtr, etc. 33 | * All of these are pointers to structures, and all of those structures start with a pointer, and a type. 34 | * The xmlKind struct is used as a generic structure, and a stepping stone. 35 | * We use it to check the type of a structure, and then perform the appropriate cast. 36 | * 37 | * For example: 38 | * if(genericPtr->type == XML_ATTRIBUTE_NODE) 39 | * { 40 | * xmlAttrPtr attr = (xmlAttrPtr)genericPtr; 41 | * // Do something with attr 42 | * } 43 | **/ 44 | struct _xmlKind { 45 | void * ignore; 46 | xmlElementType type; 47 | }; 48 | typedef struct _xmlKind *xmlKindPtr; 49 | 50 | /** 51 | * Most xml types all start with this standard structure. In fact, all do except the xmlNsPtr. 52 | * We will occasionally take advantage of this to simplify code when the code wouldn't vary from type to type. 53 | * Obviously, you cannnot cast a xmlNsPtr to a xmlStdPtr. 54 | **/ 55 | struct _xmlStd { 56 | void * _private; 57 | xmlElementType type; 58 | const xmlChar *name; 59 | struct _xmlNode *children; 60 | struct _xmlNode *last; 61 | struct _xmlNode *parent; 62 | struct _xmlStd *next; 63 | struct _xmlStd *prev; 64 | struct _xmlDoc *doc; 65 | }; 66 | typedef struct _xmlStd *xmlStdPtr; 67 | 68 | @interface DDXMLNode : NSObject 69 | { 70 | // Every DDXML object is simply a wrapper around an underlying libxml node 71 | xmlKindPtr genericPtr; 72 | 73 | // The xmlNsPtr type doesn't store a reference to it's parent 74 | // This is here to fix that problem, and make this class more compatible with the NSXML classes 75 | xmlNodePtr nsParentPtr; 76 | } 77 | 78 | //- (id)initWithKind:(DDXMLNodeKind)kind; 79 | 80 | //- (id)initWithKind:(DDXMLNodeKind)kind options:(NSUInteger)options; 81 | 82 | //+ (id)document; 83 | 84 | //+ (id)documentWithRootElement:(DDXMLElement *)element; 85 | 86 | + (id)elementWithName:(NSString *)name; 87 | 88 | + (id)elementWithName:(NSString *)name URI:(NSString *)URI; 89 | 90 | + (id)elementWithName:(NSString *)name stringValue:(NSString *)string; 91 | 92 | + (id)elementWithName:(NSString *)name children:(NSArray *)children attributes:(NSArray *)attributes; 93 | 94 | + (id)attributeWithName:(NSString *)name stringValue:(NSString *)stringValue; 95 | 96 | + (id)attributeWithName:(NSString *)name URI:(NSString *)URI stringValue:(NSString *)stringValue; 97 | 98 | + (id)namespaceWithName:(NSString *)name stringValue:(NSString *)stringValue; 99 | 100 | + (id)processingInstructionWithName:(NSString *)name stringValue:(NSString *)stringValue; 101 | 102 | + (id)commentWithStringValue:(NSString *)stringValue; 103 | 104 | + (id)textWithStringValue:(NSString *)stringValue; 105 | 106 | //+ (id)DTDNodeWithXMLString:(NSString *)string; 107 | 108 | #pragma mark --- Properties --- 109 | 110 | - (DDXMLNodeKind)kind; 111 | 112 | - (void)setName:(NSString *)name; 113 | - (NSString *)name; 114 | 115 | //- (void)setObjectValue:(id)value; 116 | //- (id)objectValue; 117 | 118 | - (void)setStringValue:(NSString *)string; 119 | //- (void)setStringValue:(NSString *)string resolvingEntities:(BOOL)resolve; 120 | - (NSString *)stringValue; 121 | 122 | #pragma mark --- Tree Navigation --- 123 | 124 | - (NSUInteger)index; 125 | 126 | - (NSUInteger)level; 127 | 128 | - (DDXMLDocument *)rootDocument; 129 | 130 | - (DDXMLNode *)parent; 131 | - (NSUInteger)childCount; 132 | - (NSArray *)children; 133 | - (DDXMLNode *)childAtIndex:(NSUInteger)index; 134 | 135 | - (DDXMLNode *)previousSibling; 136 | - (DDXMLNode *)nextSibling; 137 | 138 | - (DDXMLNode *)previousNode; 139 | - (DDXMLNode *)nextNode; 140 | 141 | - (void)detach; 142 | 143 | - (NSString *)XPath; 144 | 145 | #pragma mark --- QNames --- 146 | 147 | - (NSString *)localName; 148 | - (NSString *)prefix; 149 | 150 | - (void)setURI:(NSString *)URI; 151 | - (NSString *)URI; 152 | 153 | + (NSString *)localNameForName:(NSString *)name; 154 | + (NSString *)prefixForName:(NSString *)name; 155 | //+ (DDXMLNode *)predefinedNamespaceForPrefix:(NSString *)name; 156 | 157 | #pragma mark --- Output --- 158 | 159 | - (NSString *)description; 160 | - (NSString *)XMLString; 161 | - (NSString *)XMLStringWithOptions:(NSUInteger)options; 162 | //- (NSString *)canonicalXMLStringPreservingComments:(BOOL)comments; 163 | 164 | #pragma mark --- XPath/XQuery --- 165 | 166 | - (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error; 167 | //- (NSArray *)objectsForXQuery:(NSString *)xquery constants:(NSDictionary *)constants error:(NSError **)error; 168 | //- (NSArray *)objectsForXQuery:(NSString *)xquery error:(NSError **)error; 169 | 170 | @end 171 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/text-base/DDXMLNode.h.svn-base: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @class DDXMLDocument; 5 | 6 | 7 | enum { 8 | DDXMLInvalidKind = 0, 9 | DDXMLDocumentKind = XML_DOCUMENT_NODE, 10 | DDXMLElementKind = XML_ELEMENT_NODE, 11 | DDXMLAttributeKind = XML_ATTRIBUTE_NODE, 12 | DDXMLNamespaceKind = XML_NAMESPACE_DECL, 13 | DDXMLProcessingInstructionKind = XML_PI_NODE, 14 | DDXMLCommentKind = XML_COMMENT_NODE, 15 | DDXMLTextKind = XML_TEXT_NODE, 16 | DDXMLDTDKind = XML_DTD_NODE, 17 | DDXMLEntityDeclarationKind = XML_ENTITY_DECL, 18 | DDXMLAttributeDeclarationKind = XML_ATTRIBUTE_DECL, 19 | DDXMLElementDeclarationKind = XML_ELEMENT_DECL, 20 | DDXMLNotationDeclarationKind = XML_NOTATION_NODE 21 | }; 22 | typedef NSUInteger DDXMLNodeKind; 23 | 24 | enum { 25 | DDXMLNodeOptionsNone = 0, 26 | DDXMLNodeExpandEmptyElement = 1 << 1, 27 | DDXMLNodeCompactEmptyElement = 1 << 2, 28 | DDXMLNodePrettyPrint = 1 << 17, 29 | }; 30 | 31 | /** 32 | * DDXMLNode can represent several underlying types, such as xmlNodePtr, xmlDocPtr, xmlAttrPtr, xmlNsPtr, etc. 33 | * All of these are pointers to structures, and all of those structures start with a pointer, and a type. 34 | * The xmlKind struct is used as a generic structure, and a stepping stone. 35 | * We use it to check the type of a structure, and then perform the appropriate cast. 36 | * 37 | * For example: 38 | * if(genericPtr->type == XML_ATTRIBUTE_NODE) 39 | * { 40 | * xmlAttrPtr attr = (xmlAttrPtr)genericPtr; 41 | * // Do something with attr 42 | * } 43 | **/ 44 | struct _xmlKind { 45 | void * ignore; 46 | xmlElementType type; 47 | }; 48 | typedef struct _xmlKind *xmlKindPtr; 49 | 50 | /** 51 | * Most xml types all start with this standard structure. In fact, all do except the xmlNsPtr. 52 | * We will occasionally take advantage of this to simplify code when the code wouldn't vary from type to type. 53 | * Obviously, you cannnot cast a xmlNsPtr to a xmlStdPtr. 54 | **/ 55 | struct _xmlStd { 56 | void * _private; 57 | xmlElementType type; 58 | const xmlChar *name; 59 | struct _xmlNode *children; 60 | struct _xmlNode *last; 61 | struct _xmlNode *parent; 62 | struct _xmlStd *next; 63 | struct _xmlStd *prev; 64 | struct _xmlDoc *doc; 65 | }; 66 | typedef struct _xmlStd *xmlStdPtr; 67 | 68 | @interface DDXMLNode : NSObject 69 | { 70 | // Every DDXML object is simply a wrapper around an underlying libxml node 71 | xmlKindPtr genericPtr; 72 | 73 | // The xmlNsPtr type doesn't store a reference to it's parent 74 | // This is here to fix that problem, and make this class more compatible with the NSXML classes 75 | xmlNodePtr nsParentPtr; 76 | } 77 | 78 | //- (id)initWithKind:(DDXMLNodeKind)kind; 79 | 80 | //- (id)initWithKind:(DDXMLNodeKind)kind options:(NSUInteger)options; 81 | 82 | //+ (id)document; 83 | 84 | //+ (id)documentWithRootElement:(DDXMLElement *)element; 85 | 86 | + (id)elementWithName:(NSString *)name; 87 | 88 | + (id)elementWithName:(NSString *)name URI:(NSString *)URI; 89 | 90 | + (id)elementWithName:(NSString *)name stringValue:(NSString *)string; 91 | 92 | + (id)elementWithName:(NSString *)name children:(NSArray *)children attributes:(NSArray *)attributes; 93 | 94 | + (id)attributeWithName:(NSString *)name stringValue:(NSString *)stringValue; 95 | 96 | + (id)attributeWithName:(NSString *)name URI:(NSString *)URI stringValue:(NSString *)stringValue; 97 | 98 | + (id)namespaceWithName:(NSString *)name stringValue:(NSString *)stringValue; 99 | 100 | + (id)processingInstructionWithName:(NSString *)name stringValue:(NSString *)stringValue; 101 | 102 | + (id)commentWithStringValue:(NSString *)stringValue; 103 | 104 | + (id)textWithStringValue:(NSString *)stringValue; 105 | 106 | //+ (id)DTDNodeWithXMLString:(NSString *)string; 107 | 108 | #pragma mark --- Properties --- 109 | 110 | - (DDXMLNodeKind)kind; 111 | 112 | - (void)setName:(NSString *)name; 113 | - (NSString *)name; 114 | 115 | //- (void)setObjectValue:(id)value; 116 | //- (id)objectValue; 117 | 118 | - (void)setStringValue:(NSString *)string; 119 | //- (void)setStringValue:(NSString *)string resolvingEntities:(BOOL)resolve; 120 | - (NSString *)stringValue; 121 | 122 | #pragma mark --- Tree Navigation --- 123 | 124 | - (NSUInteger)index; 125 | 126 | - (NSUInteger)level; 127 | 128 | - (DDXMLDocument *)rootDocument; 129 | 130 | - (DDXMLNode *)parent; 131 | - (NSUInteger)childCount; 132 | - (NSArray *)children; 133 | - (DDXMLNode *)childAtIndex:(NSUInteger)index; 134 | 135 | - (DDXMLNode *)previousSibling; 136 | - (DDXMLNode *)nextSibling; 137 | 138 | - (DDXMLNode *)previousNode; 139 | - (DDXMLNode *)nextNode; 140 | 141 | - (void)detach; 142 | 143 | - (NSString *)XPath; 144 | 145 | #pragma mark --- QNames --- 146 | 147 | - (NSString *)localName; 148 | - (NSString *)prefix; 149 | 150 | - (void)setURI:(NSString *)URI; 151 | - (NSString *)URI; 152 | 153 | + (NSString *)localNameForName:(NSString *)name; 154 | + (NSString *)prefixForName:(NSString *)name; 155 | //+ (DDXMLNode *)predefinedNamespaceForPrefix:(NSString *)name; 156 | 157 | #pragma mark --- Output --- 158 | 159 | - (NSString *)description; 160 | - (NSString *)XMLString; 161 | - (NSString *)XMLStringWithOptions:(NSUInteger)options; 162 | //- (NSString *)canonicalXMLStringPreservingComments:(BOOL)comments; 163 | 164 | #pragma mark --- XPath/XQuery --- 165 | 166 | - (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error; 167 | //- (NSArray *)objectsForXQuery:(NSString *)xquery constants:(NSDictionary *)constants error:(NSError **)error; 168 | //- (NSArray *)objectsForXQuery:(NSString *)xquery error:(NSError **)error; 169 | 170 | @end 171 | -------------------------------------------------------------------------------- /Classes/kissxml/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 20 5 | http://kissxml.googlecode.com/svn/trunk 6 | http://kissxml.googlecode.com/svn 7 | 8 | 9 | 10 | 2009-09-05T23:44:02.710306Z 11 | 20 12 | deusty 13 | has-props 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | b646154a-8d0a-11dd-abc6-8b02bc135b05 28 | 29 | main.m 30 | file 31 | 32 | 33 | 34 | 35 | 2009-10-22T01:01:17.000000Z 36 | f37c202d30f43541c733701cc0b222f4 37 | 2008-09-29T08:48:45.217633Z 38 | 3 39 | deusty 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 257 62 | 63 | KissXML_Prefix.pch 64 | file 65 | 66 | 67 | 68 | 69 | 2009-10-22T01:01:17.000000Z 70 | 9ea18dcacdf1e00e976b4e44f419c1a4 71 | 2008-09-29T08:48:45.217633Z 72 | 3 73 | deusty 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 145 96 | 97 | Info.plist 98 | file 99 | 100 | 101 | 102 | 103 | 2009-10-22T01:01:17.000000Z 104 | b6afde9abcf8b84bdeea9bc79e596f23 105 | 2008-09-29T08:48:45.217633Z 106 | 3 107 | deusty 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 855 130 | 131 | KissXML.xcodeproj 132 | dir 133 | 134 | DDXMLPrivate.h 135 | file 136 | 137 | 138 | 139 | 140 | 2009-10-22T01:01:17.000000Z 141 | 99ac8e3a7d465f3406c92f7fb87a071d 142 | 2009-05-18T23:00:02.990199Z 143 | 19 144 | deusty 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 2657 167 | 168 | DDXMLTesting.h 169 | file 170 | 171 | 172 | 173 | 174 | 2009-10-22T01:01:17.000000Z 175 | 3e833e624b06bc26abab066cf47a18c4 176 | 2008-09-29T08:48:45.217633Z 177 | 3 178 | deusty 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 90 201 | 202 | NSStringAdditions.h 203 | file 204 | 205 | 206 | 207 | 208 | 2009-10-22T01:01:17.000000Z 209 | bdf5f7290f0677906635e7775dca1b25 210 | 2009-01-06T04:34:35.582354Z 211 | 9 212 | deusty 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 251 235 | 236 | DDXMLDocument.h 237 | file 238 | 239 | 240 | 241 | 242 | 2009-10-22T01:01:17.000000Z 243 | 537d59d2974268eab320a0cbf447a947 244 | 2009-01-12T07:42:06.467037Z 245 | 10 246 | deusty 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 2055 269 | 270 | DDXML.h 271 | file 272 | 273 | 274 | 275 | 276 | 2009-10-22T01:01:17.000000Z 277 | 1afa2d4fa094a7c9fe0d628571259c38 278 | 2008-09-29T08:48:45.217633Z 279 | 3 280 | deusty 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 73 303 | 304 | DDXMLTesting.m 305 | file 306 | 307 | 308 | 309 | 310 | 2009-10-22T01:01:17.000000Z 311 | 1ab023ef7a9a7a3a53d0a6e4f8fdf724 312 | 2009-05-18T23:00:02.990199Z 313 | 19 314 | deusty 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 54797 337 | 338 | AppDelegate.h 339 | file 340 | 341 | 342 | 343 | 344 | 2009-10-22T01:01:17.000000Z 345 | ecd1055d36fdc98932f03f14fcb130ea 346 | 2008-09-29T08:48:45.217633Z 347 | 3 348 | deusty 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 70 371 | 372 | NSStringAdditions.m 373 | file 374 | 375 | 376 | 377 | 378 | 2009-10-22T01:01:17.000000Z 379 | 2b72c3f9bdf95eeb33f7e64018ae6cf1 380 | 2009-01-06T04:34:35.582354Z 381 | 9 382 | deusty 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 373 405 | 406 | DDXMLDocument.m 407 | file 408 | 409 | 410 | 411 | 412 | 2009-10-22T01:01:17.000000Z 413 | b67ed11ae0ee4ea4226931cdf02c3132 414 | 2009-05-18T23:00:02.990199Z 415 | 19 416 | deusty 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 3011 439 | 440 | DDXMLNode.h 441 | file 442 | 443 | 444 | 445 | 446 | 2009-10-22T01:01:17.000000Z 447 | 962e042c58d93c9791351699591e6f7b 448 | 2009-01-06T04:34:35.582354Z 449 | 9 450 | deusty 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 5010 473 | 474 | AppDelegate.m 475 | file 476 | 477 | 478 | 479 | 480 | 2009-10-22T01:01:17.000000Z 481 | 2b71ff02b161a5f4935ddd29a0610307 482 | 2008-09-29T08:48:45.217633Z 483 | 3 484 | deusty 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 207 507 | 508 | DDXMLElementAdditions.h 509 | file 510 | 511 | 512 | 513 | 514 | 2009-10-22T01:01:17.000000Z 515 | 973643a33dce6187e477b800e26dfbf7 516 | 2009-01-21T04:47:49.813935Z 517 | 11 518 | deusty 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 612 541 | 542 | DDXMLElement.h 543 | file 544 | 545 | 546 | 547 | 548 | 2009-10-22T01:01:17.000000Z 549 | b4a22f30b63d5045fa464e96c7eecce0 550 | 2009-02-27T18:16:34.806636Z 551 | 16 552 | deusty 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 1712 575 | 576 | DDXMLNode.m 577 | file 578 | 579 | 580 | 581 | 582 | 2009-10-22T01:01:17.000000Z 583 | 91f21ebbf0553ff63db600b56f913218 584 | 2009-05-18T23:00:02.990199Z 585 | 19 586 | deusty 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 47375 609 | 610 | DDXMLElementAdditions.m 611 | file 612 | 613 | 614 | 615 | 616 | 2009-10-22T01:01:17.000000Z 617 | 835ee07c49772c5179f1a90e726d0aa3 618 | 2009-01-21T04:47:49.813935Z 619 | 11 620 | deusty 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 3101 643 | 644 | DDXMLElement.m 645 | file 646 | 647 | 648 | 649 | 650 | 2009-10-22T01:01:17.000000Z 651 | 221d586a81d9eb73f097ce57a2aa863b 652 | 2009-05-18T23:00:02.990199Z 653 | 19 654 | deusty 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 16450 677 | 678 | English.lproj 679 | dir 680 | 681 | -------------------------------------------------------------------------------- /Classes/ForecastTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ForcastTableViewController.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 9/13/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "ForecastTableViewController.h" 24 | #import "WxDataModel.h" 25 | #import "NOAADataModel.h" 26 | #import "ForecastDay.h" 27 | #import "ForecastPeriod.h" 28 | #import "ForecastTableViewCell.h" 29 | 30 | @implementation ForecastTableViewController 31 | @synthesize activityView, activityIndicator; 32 | 33 | #pragma mark - 34 | #pragma mark NSObject lifecycle methods 35 | 36 | - (id)initWithCoder:(NSCoder *)decoder{ 37 | self = [super initWithCoder:decoder]; 38 | if (self != nil){ 39 | noaaDataModel = [WxDataModel dataModel].noaaDataModel; 40 | 41 | NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Weather Icons" ofType:@"plist"]; 42 | weatherIcons = [[NSDictionary alloc]initWithContentsOfFile:filePath]; 43 | } 44 | return self; 45 | } 46 | 47 | - (void)dealloc { 48 | [activityView release]; 49 | [activityIndicator release]; 50 | [weatherIcons release]; 51 | [noaaDataModel release]; 52 | [super dealloc]; 53 | } 54 | 55 | - (void)didReceiveMemoryWarning{ 56 | DLog(@"memory warning"); 57 | [super didReceiveMemoryWarning]; 58 | } 59 | 60 | #pragma mark - 61 | #pragma mark UIViewController methods 62 | 63 | - (void)viewWillAppear:(BOOL)animated{ 64 | [super viewWillAppear:animated]; 65 | 66 | [noaaDataModel addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptionNew) context:nil]; 67 | 68 | [self.view.superview addSubview:self.activityView]; 69 | [self dataModelUpdating]; 70 | } 71 | 72 | - (void)viewWillDisappear:(BOOL)animated{ 73 | [super viewWillDisappear:animated]; 74 | 75 | [noaaDataModel removeObserver:self forKeyPath:@"state"]; 76 | } 77 | 78 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 79 | if ([keyPath isEqual:@"state"]){ 80 | [self dataModelUpdating]; 81 | } 82 | } 83 | 84 | - (void)dataModelUpdating{ 85 | DLog(@"Start"); 86 | 87 | if (noaaDataModel.state == Updating){ 88 | [self.activityIndicator startAnimating]; 89 | self.activityView.alpha = 0.5; 90 | } else if ((noaaDataModel.state == Updated) || (noaaDataModel.state == Error)){ 91 | if (noaaDataModel.multidayForecast.count != 0){ 92 | [self.tableView reloadData]; 93 | } 94 | [self.activityIndicator stopAnimating]; 95 | self.activityView.alpha = 0.0; 96 | } 97 | 98 | DLog(@"End"); 99 | } 100 | 101 | #pragma mark - 102 | #pragma mark UITableViewDataSource methods 103 | 104 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 105 | NSArray *multidayForecast = noaaDataModel.multidayForecast; 106 | NSUInteger sectionCount = 0; 107 | 108 | if (multidayForecast.count != 0){ 109 | ForecastDay *forecastDay = [multidayForecast objectAtIndex:0]; 110 | sectionCount = multidayForecast.count; 111 | 112 | if (forecastDay.periods.count == 3){ 113 | sectionCount++; 114 | } 115 | } 116 | 117 | return sectionCount; 118 | } 119 | 120 | 121 | // Customize the number of rows in the table view. 122 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 123 | NSArray *multidayForecast = noaaDataModel.multidayForecast; 124 | ForecastDay *forecastDay = [multidayForecast objectAtIndex:0]; 125 | 126 | if (forecastDay.periods.count == 3){ 127 | if (section == 0){ 128 | return 1; 129 | } else if (section == 1){ 130 | return 2; 131 | } else { 132 | forecastDay = [multidayForecast objectAtIndex:section - 1]; 133 | return forecastDay.periods.count; 134 | } 135 | } else { 136 | forecastDay = [multidayForecast objectAtIndex:section]; 137 | return forecastDay.periods.count; 138 | } 139 | } 140 | 141 | 142 | // Customize the appearance of table view cells. 143 | - (UITableViewCell *)tableView:(UITableView *)localTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 144 | 145 | static NSString *CellIdentifier = @"ForecastCell"; 146 | 147 | ForecastTableViewCell *cell = nil; 148 | cell = (ForecastTableViewCell *)[localTableView dequeueReusableCellWithIdentifier:CellIdentifier]; 149 | if (cell == nil) { 150 | NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ForecastTableViewCell" 151 | owner:self 152 | options:nil]; 153 | cell = (ForecastTableViewCell *)[topLevelObjects objectAtIndex:0]; 154 | } 155 | 156 | ForecastPeriod *forecastPeriod = [noaaDataModel period:indexPath]; 157 | 158 | cell.conditionLabel.text = forecastPeriod.shortForecast; 159 | cell.forecastLabel.text = forecastPeriod.longForecast; 160 | cell.tempLabel.text = [NSString stringWithFormat:@"%@°F",forecastPeriod.temp]; 161 | 162 | NSString *imageName = [weatherIcons objectForKey:forecastPeriod.condition]; 163 | cell.periodImageView.image = [UIImage imageNamed:imageName]; 164 | 165 | return cell; 166 | } 167 | 168 | 169 | #pragma mark - 170 | #pragma mark UITableViewDelegate methods 171 | 172 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ 173 | ForecastDay *forecastDay = [noaaDataModel.multidayForecast objectAtIndex:0]; 174 | NSUInteger periodCount = forecastDay.periods.count; 175 | 176 | switch (section) { 177 | case 0: 178 | switch (periodCount){ 179 | case 1: 180 | return @"Tonight"; 181 | break; 182 | case 2: 183 | return @"Today"; 184 | break; 185 | case 3: 186 | return @"Overnight"; 187 | break; 188 | } 189 | break; 190 | case 1: 191 | return @"Tomorrow"; 192 | break; 193 | } 194 | 195 | if (section != noaaDataModel.multidayForecast.count){ 196 | forecastDay = [noaaDataModel.multidayForecast objectAtIndex:section]; 197 | return forecastDay.name; 198 | } else { 199 | NSDateFormatter *dateFormater = [[[NSDateFormatter alloc]init]autorelease]; 200 | dateFormater.dateStyle = NSDateFormatterFullStyle; 201 | 202 | forecastDay = [noaaDataModel.multidayForecast objectAtIndex:(section - 1)]; 203 | NSDate *date = [[[NSDate alloc]initWithTimeInterval:(60*60*24) sinceDate:forecastDay.date]autorelease]; 204 | return [dateFormater stringFromDate:date]; 205 | } 206 | } 207 | 208 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 209 | ForecastPeriod *forecastPeriod = [noaaDataModel period:indexPath]; 210 | NSString *detailText = forecastPeriod.longForecast; 211 | DLog(@"%@",detailText); 212 | 213 | CGSize constrainSize = CGSizeMake(228, 400); 214 | 215 | UIFont *detailFont = [UIFont systemFontOfSize:14]; 216 | 217 | CGFloat detailHeight = [detailText sizeWithFont:detailFont 218 | constrainedToSize:constrainSize 219 | lineBreakMode:UILineBreakModeWordWrap].height; 220 | 221 | CGFloat height = 35 + detailHeight + 13; 222 | 223 | if (height < 88.0 ){ height = 88.0; } 224 | 225 | return height; 226 | } 227 | 228 | @end 229 | -------------------------------------------------------------------------------- /Classes/GraphView.m: -------------------------------------------------------------------------------- 1 | // 2 | // GraphView.m 3 | // WxNow 4 | // 5 | // Created by Ayal Spitz on 7/15/10. 6 | // Copyright 2010 MITRE Corp. All rights reserved. 7 | // 8 | 9 | #import "GraphView.h" 10 | #import "HourForecast.h" 11 | 12 | 13 | @implementation GraphView 14 | 15 | @synthesize debug; 16 | 17 | @synthesize strokeGraph; 18 | @synthesize graphStrokeColor; 19 | @synthesize graphLineWidth; 20 | 21 | @synthesize xAxisLabel; 22 | @synthesize xAxisLabelFormat; 23 | @synthesize xAxisLabelCount; 24 | @synthesize xAxisLabelFont; 25 | @synthesize xAxisLabelColor; 26 | 27 | - (id)initWithFrame:(CGRect)frame { 28 | if ((self = [super initWithFrame:frame])) { 29 | // Initialization code 30 | } 31 | return self; 32 | } 33 | 34 | - (id)initWithCoder:(NSCoder *)aDecoder{ 35 | if ((self = [super initWithCoder:aDecoder])) { 36 | dataArray = nil; 37 | 38 | self.debug = NO; 39 | 40 | self.strokeGraph = YES; 41 | self.graphStrokeColor = [UIColor blackColor].CGColor; 42 | self.graphLineWidth = 2.0; 43 | 44 | self.xAxisLabel = YES; 45 | self.xAxisLabelFormat = @"%d"; 46 | self.xAxisLabelCount = 0; 47 | self.xAxisLabelFont = [UIFont systemFontOfSize:12]; 48 | self.xAxisLabelColor = [UIColor blackColor].CGColor; 49 | } 50 | return self; 51 | } 52 | 53 | - (void)dealloc { 54 | if (dataArray != nil){ 55 | free(dataArray); 56 | } 57 | 58 | [super dealloc]; 59 | } 60 | 61 | - (void)setDataFromArray:(NSArray *)srcArray withKeyPath:(NSString *)keyPath 62 | startAtIndex:(NSUInteger)startIndex withLength:(NSUInteger)len{ 63 | 64 | [srcArray retain]; 65 | 66 | dataMax = -100; 67 | dataMin = 200; 68 | dataLen = len; 69 | 70 | if (dataArray != nil){ 71 | free(dataArray); 72 | } 73 | dataArray = malloc(sizeof(CGPoint) * len); 74 | 75 | id obj; 76 | NSInteger element = 0; 77 | 78 | for (int i=0; i <= len; i++){ 79 | obj = [srcArray objectAtIndex:i + startIndex]; 80 | element = [[obj valueForKeyPath:keyPath] intValue]; 81 | //DLog(@"[%d] temp: %d", i, element); 82 | 83 | if (element > dataMax){ 84 | dataMax = element; 85 | } 86 | if (element < dataMin){ 87 | dataMin = element; 88 | } 89 | 90 | dataArray[i] = CGPointMake(i, element); 91 | //DLog(@"(%f, %f)", dataArray[i].x, dataArray[i].y); 92 | } 93 | 94 | [srcArray release]; 95 | } 96 | 97 | - (void)drawRect:(CGRect)rect { 98 | CGContextRef context = UIGraphicsGetCurrentContext(); 99 | 100 | // Set default values 101 | CGContextSetLineWidth(context, 1.0); 102 | CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor); 103 | CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor); 104 | 105 | // Transform drawing to ensure sharp drawing 106 | CGContextTranslateCTM(context, 0.5, 0.5); 107 | 108 | // If debuging draw red bounding box 109 | if (self.debug){ 110 | CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); 111 | CGContextStrokeRect(context, rect); 112 | CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor); 113 | } 114 | 115 | // Draw x axis labels 116 | NSUInteger maxLabelWidth = 0; 117 | if (self.xAxisLabel){ 118 | maxLabelWidth = [self drawXAxisLabels:context viewSize:rect.size]; 119 | } 120 | 121 | CGRect graphRect = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width - maxLabelWidth, rect.size.height - 1); 122 | 123 | double xScale = 0.0, yScale = 0.0; 124 | 125 | if (dataArray != nil){ 126 | xScale = (graphRect.size.width / dataLen); 127 | yScale = (graphRect.size.height - 20) / (dataMax - dataMin); 128 | 129 | CGPoint pt; 130 | 131 | // Create graph shapes 132 | // Start by creating the open path of the graph 133 | CGMutablePathRef graphShape = CGPathCreateMutable(); 134 | 135 | for (int i=0; i <= dataLen; i++){ 136 | pt = dataArray[i]; 137 | pt.x *= xScale; 138 | pt.y = graphRect.size.height - ((pt.y - dataMin) * yScale + 10); 139 | 140 | if (i == 0){ 141 | CGPathMoveToPoint(graphShape, NULL, pt.x, pt.y); //start point 142 | } else { 143 | CGPathAddLineToPoint(graphShape, NULL, pt.x, pt.y); // end path 144 | } 145 | } 146 | 147 | // Copy the open graph path and make a closed shape of the area above the graph 148 | CGMutablePathRef aboveGraphShape = CGPathCreateMutableCopy(graphShape); 149 | 150 | CGPathAddLineToPoint(aboveGraphShape, NULL, pt.x, 0); 151 | CGPathAddLineToPoint(aboveGraphShape, NULL, 0, 0); // end path 152 | 153 | CGPathCloseSubpath(aboveGraphShape); 154 | 155 | // Copy the open graph path and make a closed shape of the area bellow the graph 156 | CGMutablePathRef bellowGraphShape = CGPathCreateMutableCopy(graphShape); 157 | 158 | CGPathAddLineToPoint(bellowGraphShape, NULL, pt.x, graphRect.size.height); 159 | CGPathAddLineToPoint(bellowGraphShape, NULL, 0, graphRect.size.height); // end path 160 | 161 | CGPathCloseSubpath(bellowGraphShape); 162 | 163 | // Paint the area bellow the graph in a light gray 164 | /*CGContextAddPath(context, bellowGraphShape); 165 | CGContextSetFillColorWithColor(context, [UIColor lightGrayColor].CGColor); 166 | CGContextFillPath(context);*/ 167 | 168 | // Draw hour lines 169 | CGContextSetStrokeColorWithColor(context, [UIColor lightGrayColor].CGColor); 170 | CGContextSetLineWidth(context, 3.0); // this is set from now on until you explicitly change it 171 | 172 | for (int i=0; i <= dataLen; i++){ 173 | //CGContextBeginPath(context); 174 | 175 | CGContextMoveToPoint(context, (int)(i * xScale), 0); //start point 176 | CGContextAddLineToPoint(context, (int)(i * xScale), graphRect.size.height); // end path 177 | 178 | CGContextSetLineWidth(context, 1.0); // this is set from now on until you explicitly change it 179 | 180 | CGContextStrokePath(context); // do actual stroking 181 | } 182 | 183 | 184 | // Erase the hour lines above the graph by painting the area white 185 | CGContextAddPath(context, aboveGraphShape); 186 | CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); 187 | CGContextFillPath(context); 188 | 189 | // Stroke the graph line 190 | if (self.strokeGraph){ 191 | CGContextAddPath(context, graphShape); 192 | CGContextSetStrokeColorWithColor(context, self.graphStrokeColor); 193 | CGContextSetLineWidth(context, self.graphLineWidth); 194 | CGContextStrokePath(context); 195 | 196 | CGContextSetLineWidth(context, 1.0); 197 | } 198 | 199 | // Stroke the bounding rect 200 | CGContextSetStrokeColorWithColor(context, [UIColor lightGrayColor].CGColor); 201 | CGContextStrokeRect(context, graphRect); 202 | 203 | 204 | CGPathRelease(graphShape); 205 | CGPathRelease(aboveGraphShape); 206 | CGPathRelease(bellowGraphShape); 207 | } 208 | } 209 | 210 | - (NSUInteger)drawXAxisLabels:(CGContextRef)context viewSize:(CGSize)viewSize{ 211 | NSMutableArray *labelArray = nil; 212 | NSUInteger maxLabelWidth = 0; 213 | NSInteger labelDataStep = 0; 214 | 215 | NSUInteger textWidth = 0; 216 | CGSize textSize; 217 | NSString *label = nil; 218 | 219 | if (self.xAxisLabelCount == 0){ 220 | self.xAxisLabelCount = (viewSize.height - 20) / (self.xAxisLabelFont.pointSize + 2); 221 | } 222 | 223 | labelDataStep = ((dataMax - dataMin) / self.xAxisLabelCount); 224 | labelArray = [[NSMutableArray alloc]initWithCapacity:self.xAxisLabelCount]; 225 | 226 | for (int i=0; i maxLabelWidth){ 232 | maxLabelWidth = textWidth; 233 | } 234 | } 235 | 236 | CGPoint pt; 237 | NSUInteger labelStep = ((viewSize.height - 20) / (self.xAxisLabelCount - 1)); 238 | NSUInteger graphWidth = viewSize.width - maxLabelWidth; 239 | NSUInteger y = 0; 240 | 241 | for (int i=0; i 12 | #import "DDXML.h" 13 | #import "Period.h" 14 | #import "HourForecast.h" 15 | 16 | @implementation HourlyForecastDataModel 17 | 18 | @synthesize hourlyForecast; 19 | 20 | - (id)init{ 21 | self = [super init]; 22 | if (self != nil) { 23 | [self refresh]; 24 | 25 | dateFormatter = [[NSDateFormatter alloc] init]; 26 | [dateFormatter setDefaultDate:[NSDate date]]; 27 | [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; 28 | [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZ"]; // 2009-09-26T12:00:00-05:00 29 | } 30 | return self; 31 | } 32 | 33 | - (void) dealloc{ 34 | [hourlyForecast release]; 35 | [super dealloc]; 36 | } 37 | 38 | - (void)update:(id)dataModel{ 39 | [super update:dataModel]; 40 | GPSDataModel *gpsDataModel = dataModel; 41 | 42 | NSString *urlString = [[NSString alloc] initWithFormat:@"http://forecast.weather.gov/MapClick.php?lat=%f&lon=%f&FcstType=digitalDWML", 43 | gpsDataModel.location.coordinate.latitude, 44 | gpsDataModel.location.coordinate.longitude]; 45 | DLog(@"%@", urlString); 46 | [self connect:urlString]; 47 | 48 | [urlString release]; 49 | } 50 | 51 | - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ 52 | NSError *error = nil; 53 | DDXMLDocument *xmlDoc = [[DDXMLDocument alloc] initWithData:self.receivedData options:0 error:&error]; 54 | if (error){ 55 | [xmlDoc release]; 56 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:0 errorString:@"There appears to be a problem getting hourly data from NOAA right now"]; 57 | //[self handleError:error]; 58 | return; 59 | } 60 | DDXMLElement *rootElement = [xmlDoc rootElement]; 61 | 62 | NSArray *elements = [rootElement elementsForName:@"data"]; 63 | if ([elements count] == 0){ 64 | [xmlDoc release]; 65 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:1 errorString:@"Unable to extract NOAA hourly data"]; 66 | return; 67 | } 68 | DDXMLElement *dataElement = [elements objectAtIndex:0]; 69 | [self parseTimeLayout:dataElement]; 70 | 71 | elements = [dataElement elementsForName:@"parameters"]; 72 | if ([elements count] == 0){ 73 | [xmlDoc release]; 74 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:1 errorString:@"Unable to extract NOAA hourly data"]; 75 | return; 76 | } 77 | DDXMLElement *parametersElement = [elements objectAtIndex:0]; 78 | [self parseTemperatures:parametersElement]; 79 | [self parseHumdity:parametersElement]; 80 | 81 | self.state = Updated; 82 | [xmlDoc release]; 83 | [super connectionDidFinishLoading:connection]; 84 | } 85 | 86 | - (void)parseTimeLayout:(DDXMLElement *)dataElement{ 87 | DLog(@"Start"); 88 | 89 | NSArray *timeLayouts = [dataElement elementsForName:@"time-layout"]; 90 | if ([timeLayouts count] == 0){ 91 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:3 errorString:@"Unable to extract NOAA hourly data"]; 92 | return; 93 | } 94 | DDXMLElement *timeLayout = [timeLayouts objectAtIndex:0]; 95 | 96 | // Read time layout key 97 | NSArray *elements = [timeLayout elementsForName:@"layout-key"]; 98 | if ([elements count] == 0){ 99 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:3 errorString:@"Unable to extract NOAA hourly data"]; 100 | return; 101 | } 102 | 103 | NSCalendar *calendar = [NSCalendar currentCalendar]; 104 | NSUInteger components = (NSDayCalendarUnit | NSHourCalendarUnit | NSWeekdayCalendarUnit); 105 | 106 | //NSString *key = [[elements objectAtIndex:0] stringValue]; 107 | 108 | // Read all time periods 109 | NSArray *timePeriods = [timeLayout elementsForName:@"start-valid-time"]; 110 | self.hourlyForecast = [[NSMutableArray alloc]initWithCapacity:timePeriods.count]; 111 | HourForecast *hourForecast = nil; 112 | NSString *timeDateString = nil; 113 | Period *period = nil; 114 | 115 | DLog(@"Num of time period elements: %d",timePeriods.count); 116 | for (DDXMLElement *timePeriod in timePeriods){ 117 | hourForecast = [[HourForecast alloc]init]; 118 | [self.hourlyForecast addObject:hourForecast]; 119 | 120 | timeDateString = [timePeriod stringValue]; 121 | hourForecast.period = [[Period alloc] init]; 122 | hourForecast.period.date = [self parseTimeDateString:timeDateString]; 123 | hourForecast.period.dateComponents = [calendar components:components fromDate:period.date]; 124 | DLog(@"%@", hourForecast.period); 125 | 126 | [hourForecast release]; 127 | } 128 | 129 | DLog(@"End"); 130 | } 131 | 132 | - (void)parseTemperatures:(DDXMLElement *)parametersElement{ 133 | DLog(@"Start"); 134 | 135 | NSArray *temperatures = [parametersElement elementsForName:@"temperature"]; 136 | if ([temperatures count] == 0){ 137 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:3 errorString:@"Unable to extract NOAA hourly data"]; 138 | return; 139 | } 140 | DDXMLElement *temperature = [temperatures objectAtIndex:0]; 141 | [self parseTemperatureElements:temperature]; 142 | 143 | temperature = [temperatures objectAtIndex:1]; 144 | [self parseTemperatureElements:temperature]; 145 | 146 | 147 | DLog(@"End"); 148 | } 149 | 150 | - (void)parseTemperatureElements:(DDXMLElement *)temperatureElement{ 151 | DLog(@"Start"); 152 | 153 | NSString *type = [[temperatureElement attributeForName:@"type"] stringValue]; 154 | NSString *key = nil; 155 | 156 | if ([type isEqualToString:@"hourly"]){ 157 | key = @"temperature"; 158 | } else if ([type isEqualToString:@"dew point"]){ 159 | key = @"dewPoint"; 160 | } 161 | 162 | NSArray *elements = [temperatureElement elementsForName:@"value"]; 163 | if ([elements count] == 0){ 164 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:3 errorString:@"Unable to extract NOAA hourly data"]; 165 | return; 166 | } 167 | 168 | HourForecast *hourForecast = nil; 169 | NSUInteger i = 0; 170 | 171 | DLog(@"Num of temp elements: %d",elements.count); 172 | for (DDXMLElement *element in elements){ 173 | hourForecast = [self.hourlyForecast objectAtIndex:i]; 174 | [hourForecast setValue:[NSNumber numberWithInt:[[element stringValue]intValue]] forKey:key]; 175 | i++; 176 | } 177 | 178 | DLog(@"End"); 179 | } 180 | 181 | - (void)parseHumdity:(DDXMLElement *)parametersElement{ 182 | DLog(@"Start"); 183 | 184 | NSArray *humidities = [parametersElement elementsForName:@"humidity"]; 185 | if ([humidities count] == 0){ 186 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:3 errorString:@"Unable to extract NOAA hourly data"]; 187 | return; 188 | } 189 | DDXMLElement *humidity = [humidities objectAtIndex:0]; 190 | 191 | // Read time layout key 192 | NSArray *elements = [humidity elementsForName:@"value"]; 193 | if ([elements count] == 0){ 194 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:3 errorString:@"Unable to extract NOAA hourly data"]; 195 | return; 196 | } 197 | 198 | HourForecast *hourForecast = nil; 199 | NSUInteger i = 0; 200 | 201 | DLog(@"Num of humidity elements: %d",elements.count); 202 | for (DDXMLElement *element in elements){ 203 | hourForecast = [self.hourlyForecast objectAtIndex:i]; 204 | hourForecast.percentHumidity = [[element stringValue]intValue]; 205 | DLog(@"humidity: %d", hourForecast.percentHumidity); 206 | i++; 207 | } 208 | 209 | DLog(@"End"); 210 | } 211 | 212 | - (NSDate *)parseTimeDateString:(NSString *)timeDateString{ 213 | NSMutableString *mutableTimeDateString = [[NSMutableString alloc] initWithString:timeDateString]; 214 | [mutableTimeDateString insertString:@"GMT" atIndex:19]; 215 | NSDate *date = [dateFormatter dateFromString:mutableTimeDateString]; 216 | [mutableTimeDateString release]; 217 | DLog(@"%@",date); 218 | 219 | return date; 220 | } 221 | 222 | - (void)parseValues:(DDXMLElement *)valuesElement{ 223 | DLog(@"Start"); 224 | 225 | NSArray *elements = [valuesElement elementsForName:@"value"]; 226 | if ([elements count] == 0){ 227 | [self bubbleUpError:@"HourlyForecastDataModelErrorDomain" code:3 errorString:@"Unable to extract NOAA hourly data"]; 228 | return; 229 | } 230 | 231 | DLog(@"Num of elements: %d",elements.count); 232 | for (DDXMLElement *element in elements){ 233 | DLog(@"Value: %@", [element stringValue]); 234 | } 235 | 236 | DLog(@"End"); 237 | } 238 | 239 | - (void)refresh{ 240 | [super refresh]; 241 | self.hourlyForecast = [[NSMutableArray alloc]init]; 242 | } 243 | 244 | @end 245 | -------------------------------------------------------------------------------- /Classes/DataViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DataViewController.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 5/19/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "DataViewController.h" 24 | #import "WxDataModel.h" 25 | #import 26 | 27 | @implementation DataViewController 28 | 29 | static const NSUInteger sectionRowArray[] = { 4, 3, 5, 2, /*2,*/ 1}; 30 | 31 | - (id)initWithCoder:(NSCoder *)decoder{ 32 | self = [super initWithCoder:decoder]; 33 | if (self != nil){ 34 | sectionHeaders = [[NSArray alloc]initWithObjects:@"GPS", @"Location", @"Current Condition", 35 | @"Daily Forecasts", /*@"Hourly Forecasts",*/ @"Overall", nil]; 36 | } 37 | return self; 38 | } 39 | 40 | - (void)dealloc { 41 | [sectionHeaders release]; 42 | [super dealloc]; 43 | } 44 | 45 | - (void)didReceiveMemoryWarning{ 46 | DLog(@"memory warning"); 47 | [super didReceiveMemoryWarning]; 48 | } 49 | 50 | 51 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 52 | [self.tableView reloadData]; 53 | } 54 | 55 | #pragma mark - 56 | #pragma mark UIViewController methods 57 | 58 | - (void)viewWillAppear:(BOOL)animated{ 59 | WxDataModel *dataModel = [WxDataModel dataModel]; 60 | [dataModel addObserver:self forKeyPath:@"gpsDataModel.location" options:(NSKeyValueObservingOptionNew) context:nil]; 61 | [dataModel addObserver:self forKeyPath:@"gpsDataModel.elapsedTime" options:(NSKeyValueObservingOptionNew) context:nil]; 62 | [dataModel addObserver:self forKeyPath:@"locationDataModel.elapsedTime" options:(NSKeyValueObservingOptionNew) context:nil]; 63 | [dataModel addObserver:self forKeyPath:@"currentConditionsDataModel.elapsedTime" options:(NSKeyValueObservingOptionNew) context:nil]; 64 | [dataModel addObserver:self forKeyPath:@"noaaDataModel.elapsedTime" options:(NSKeyValueObservingOptionNew) context:nil]; 65 | [dataModel addObserver:self forKeyPath:@"elapsedTime" options:(NSKeyValueObservingOptionNew) context:nil]; 66 | } 67 | 68 | - (void)viewWillDisappear:(BOOL)animated{ 69 | WxDataModel *dataModel = [WxDataModel dataModel]; 70 | [dataModel removeObserver:self forKeyPath:@"gpsDataModel.location"]; 71 | [dataModel removeObserver:self forKeyPath:@"gpsDataModel.elapsedTime"]; 72 | [dataModel removeObserver:self forKeyPath:@"locationDataModel.elapsedTime"]; 73 | [dataModel removeObserver:self forKeyPath:@"currentConditionsDataModel.elapsedTime"]; 74 | [dataModel removeObserver:self forKeyPath:@"noaaDataModel.elapsedTime"]; 75 | [dataModel removeObserver:self forKeyPath:@"elapsedTime"]; 76 | } 77 | 78 | #pragma mark - 79 | #pragma mark UITableViewDelegate Protocol implementation 80 | 81 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 5/*6*/; } 82 | 83 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 84 | if (section < 6){ 85 | return sectionRowArray[section]; 86 | } else { 87 | return 0; 88 | } 89 | } 90 | 91 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 92 | static NSString *CellIdentifier = @"Cell"; 93 | 94 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 95 | if (cell == nil) { 96 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease]; 97 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 98 | } 99 | 100 | WxDataModel *dataModel = [WxDataModel dataModel]; 101 | 102 | switch (indexPath.section){ 103 | case 0: 104 | switch (indexPath.row){ 105 | case 0: 106 | cell.textLabel.text = @"Latitude"; 107 | CLLocation *location = [dataModel valueForKeyPath:@"gpsDataModel.location"]; 108 | cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%g°",location.coordinate.latitude]; 109 | return cell; 110 | case 1: 111 | cell.textLabel.text = @"Longitude"; 112 | location = [dataModel valueForKeyPath:@"gpsDataModel.location"]; 113 | cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%g°",location.coordinate.longitude]; 114 | return cell; 115 | case 2: 116 | cell.textLabel.text = @"Accuracy"; 117 | location = [dataModel valueForKeyPath:@"gpsDataModel.location"]; 118 | cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%gm",location.horizontalAccuracy]; 119 | return cell; 120 | case 3: 121 | cell.textLabel.text = @"Elapsed"; 122 | NSNumber *elapsedTime = [dataModel valueForKeyPath:@"gpsDataModel.elapsedTime"]; 123 | cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%.2f sec",[elapsedTime doubleValue]]; 124 | return cell; 125 | } 126 | break; 127 | case 1: 128 | switch (indexPath.row){ 129 | case 0: 130 | cell.textLabel.text = @"City"; 131 | cell.detailTextLabel.text = [dataModel valueForKeyPath:@"locationDataModel.city"]; 132 | return cell; 133 | case 1: 134 | cell.textLabel.text = @"State"; 135 | cell.detailTextLabel.text = [dataModel valueForKeyPath:@"locationDataModel.stateAbbr"]; 136 | return cell; 137 | case 2: 138 | cell.textLabel.text = @"Elapsed"; 139 | NSNumber *elapsedTime = [dataModel valueForKeyPath:@"locationDataModel.elapsedTime"]; 140 | cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%.2f sec",[elapsedTime doubleValue]]; 141 | return cell; 142 | } 143 | break; 144 | case 2: 145 | switch (indexPath.row){ 146 | case 0: 147 | cell.textLabel.text = @"ICAO"; 148 | cell.detailTextLabel.text = [dataModel valueForKeyPath:@"currentConditionsDataModel.icao"]; 149 | return cell; 150 | case 1: 151 | cell.textLabel.text = @"Location"; 152 | cell.detailTextLabel.text = [dataModel valueForKeyPath:@"currentConditionsDataModel.location"]; 153 | return cell; 154 | case 2: 155 | cell.textLabel.text = @"Temp"; 156 | NSString * value = [dataModel valueForKeyPath:@"currentConditionsDataModel.temperature"]; 157 | if (value != nil){ 158 | value = [[NSString alloc] initWithFormat:@"%@°F",value]; 159 | } 160 | cell.detailTextLabel.text = value; 161 | [value release]; 162 | return cell; 163 | case 3: 164 | cell.textLabel.text = @"Condition"; 165 | cell.detailTextLabel.text = [dataModel valueForKeyPath:@"currentConditionsDataModel.condition"]; 166 | return cell; 167 | case 4: 168 | cell.textLabel.text = @"Elapsed"; 169 | NSNumber *elapsedTime = [dataModel valueForKeyPath:@"currentConditionsDataModel.elapsedTime"]; 170 | cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%.2f sec",[elapsedTime doubleValue]]; 171 | return cell; 172 | } 173 | break; 174 | case 3: 175 | switch (indexPath.row){ 176 | case 0: 177 | cell.textLabel.text = @"Count"; 178 | NSNumber *count = [dataModel valueForKeyPath:@"noaaDataModel.multidayForecast.@count"]; 179 | cell.detailTextLabel.text = [count stringValue]; 180 | return cell; 181 | case 1: 182 | cell.textLabel.text = @"Elapsed"; 183 | NSNumber *elapsedTime = [dataModel valueForKeyPath:@"noaaDataModel.elapsedTime"]; 184 | cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%.2f sec",[elapsedTime doubleValue]]; 185 | return cell; 186 | } 187 | break; 188 | /*case 4: 189 | switch (indexPath.row){ 190 | case 0: 191 | cell.textLabel.text = @"Count"; 192 | //NSNumber *count = [dataModel valueForKeyPath:@"hourlyForecastDataModel.hourlyForecast.@count"]; 193 | //cell.detailTextLabel.text = [count stringValue]; 194 | cell.detailTextLabel.text = @"0"; 195 | return cell; 196 | case 1: 197 | cell.textLabel.text = @"Elapsed"; 198 | //NSNumber *elapsedTime = [dataModel valueForKeyPath:@"hourlyForecastDataModel.elapsedTime"]; 199 | //cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%.2f sec",[elapsedTime doubleValue]]; 200 | cell.detailTextLabel.text = @"0.00 sec"; 201 | 202 | return cell; 203 | } 204 | break;*/ 205 | case 4: 206 | switch (indexPath.row){ 207 | case 0: 208 | cell.textLabel.text = @"Elapsed"; 209 | NSNumber *elapsedTime = [dataModel valueForKeyPath:@"elapsedTime"]; 210 | cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%.2f sec",[elapsedTime doubleValue]]; 211 | return cell; 212 | } 213 | break; 214 | } 215 | 216 | cell.textLabel.text = @""; 217 | cell.detailTextLabel.text = @""; 218 | 219 | return cell; 220 | } 221 | 222 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ 223 | if ((section >= 0) && (section <= 4)){ 224 | return [sectionHeaders objectAtIndex:section]; 225 | } else { 226 | return @"oops"; 227 | } 228 | } 229 | 230 | @end 231 | -------------------------------------------------------------------------------- /Classes/MapViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MapViewController.m 3 | // WxHere 4 | // 5 | // Created by Ayal Spitz on 7/31/09. 6 | // Copyright (C) 2009 Ayal Spitz 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | // 22 | 23 | #import "MapViewController.h" 24 | #import "WxDataModel.h" 25 | #import "GPSDataModel.h" 26 | #import "LocationDataModel.h" 27 | #import "CurrentConditionsDataModel.h" 28 | #import "NOAADataModel.h" 29 | #import "WxHereAppDelegate.h" 30 | #import "WxAnnotation.h" 31 | #import "ForecastDay.h" 32 | #import "ForecastPeriod.h" 33 | 34 | @implementation MapViewController 35 | @synthesize mapView, activityView, activityIndicator; 36 | @synthesize navigationBar; 37 | 38 | @synthesize navigationItem; 39 | 40 | #pragma mark - 41 | #pragma mark UIViewController lifecycle methods 42 | 43 | - (id)initWithCoder:(NSCoder *)decoder{ 44 | self = [super initWithCoder:decoder]; 45 | if (self != nil){ 46 | wxDataModel = [WxDataModel dataModel]; 47 | memoryWarning = NO; 48 | } 49 | return self; 50 | } 51 | 52 | - (void)dealloc { 53 | [mapView release]; 54 | [activityView release]; 55 | [activityIndicator release]; 56 | [wxAnnotationView release]; 57 | [wxAnnotation release]; 58 | [navigationBar release]; 59 | [navigationItem release]; 60 | [wxDataModel release]; 61 | [tweetButton release]; 62 | [rightCalloutButton release]; 63 | 64 | [super dealloc]; 65 | } 66 | 67 | - (void)didReceiveMemoryWarning{ 68 | DLog(@"memory warning"); 69 | memoryWarning = YES; 70 | [super didReceiveMemoryWarning]; 71 | } 72 | 73 | #pragma mark - 74 | 75 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 76 | if ([keyPath isEqual:@"state"]){ 77 | if ([object class] == [GPSDataModel class]){ 78 | [self gpsUpdated]; 79 | } else if ([object class] == [LocationDataModel class]){ 80 | [self locationNameUpdated]; 81 | } else if ([object class] == [CurrentConditionsDataModel class]){ 82 | [self currentConditionsUpdated]; 83 | } else if ([object class] == [NOAADataModel class]){ 84 | [self forecastsUpdated]; 85 | } else if ([object class] == [WxDataModel class]){ 86 | [self dataModelUpdating]; 87 | } 88 | } 89 | } 90 | 91 | - (void)gpsUpdated{ 92 | DLog(@"Start"); 93 | 94 | GPSDataModel *dataModel = wxDataModel.gpsDataModel; 95 | 96 | if (dataModel.state == Updated){ 97 | // Zoom to the users location 98 | CLLocation *currentLocation = dataModel.location; 99 | CLLocationDistance distance = MAX(4*currentLocation.horizontalAccuracy, 500); 100 | MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(currentLocation.coordinate, distance, distance); 101 | [self.mapView setRegion:region animated:YES]; 102 | 103 | // If the annotation exists, make sure to release the old one 104 | if (wxAnnotation != nil){ 105 | [wxAnnotation release]; 106 | wxAnnotation = nil; 107 | } 108 | wxAnnotation = [[WxAnnotation alloc]initWithGPSDataModel:dataModel]; 109 | 110 | // If the annotation view isn't on the screen then we should animate the ping drop 111 | BOOL animatesDrop = (wxAnnotationView == nil); 112 | 113 | // Lets make sure that we create an annotation view so that we have a view to add stuff to 114 | if (wxAnnotationView != nil){ 115 | [wxAnnotationView release]; 116 | wxAnnotationView = nil; 117 | } 118 | wxAnnotationView = [[MKPinAnnotationView alloc]initWithAnnotation:wxAnnotation reuseIdentifier:@"WXAnnotation"]; 119 | wxAnnotationView.pinColor = MKPinAnnotationColorPurple; 120 | wxAnnotationView.animatesDrop = animatesDrop; 121 | // Make sure to set 'canShowCallout' to YES otherwise the callout will not show 122 | wxAnnotationView.canShowCallout = YES; 123 | 124 | // Make sure to add the annotation to the map 125 | [self.mapView addAnnotation:wxAnnotation]; 126 | 127 | // Once we add the annotation to the map we can turn off the users location 128 | //self.mapView.showsUserLocation = NO; 129 | 130 | [self updateAnnotation]; 131 | } 132 | 133 | DLog(@"End"); 134 | } 135 | 136 | - (void)locationNameUpdated{ 137 | DLog(@"Start"); 138 | 139 | self.navigationBar.topItem.title = wxDataModel.locationDataModel.location; 140 | [self.navigationBar setNeedsDisplay]; 141 | 142 | DLog(@"End"); 143 | } 144 | 145 | - (void)currentConditionsUpdated{ 146 | DLog(@"Start"); 147 | 148 | CurrentConditionsDataModel *dataModel = wxDataModel.currentConditionsDataModel; 149 | 150 | if (dataModel.state == Updated){ 151 | [wxAnnotation updateCurrentConditions:dataModel]; 152 | 153 | [wxAnnotationView setLeftCalloutAccessoryView:dataModel.conditionImage]; 154 | [self updateAnnotation]; 155 | } 156 | 157 | DLog(@"End"); 158 | } 159 | 160 | - (void)forecastsUpdated{ 161 | DLog(@"Start"); 162 | 163 | NOAADataModel *dataModel = wxDataModel.noaaDataModel; 164 | 165 | if ((dataModel.state == Updated) && ([dataModel.multidayForecast count] != 0)){ 166 | wxAnnotation.subtitle = [dataModel currentHighLowString]; 167 | /*ForecastDay *forecastDay = [dataModel.multidayForecast objectAtIndex:0]; 168 | NSArray *periods = [forecastDay.periods allValues]; 169 | 170 | NSString *highLow; 171 | ForecastPeriod *period = [forecastDay periodAtIndex:0]; 172 | if ((periods.count == 1) || (periods.count == 3)){ 173 | highLow = [[NSString alloc] initWithFormat:@"Lo:%@°F", period.temp]; 174 | } else if (periods.count == 2){ 175 | ForecastPeriod *amPeriod = [forecastDay periodAtIndex:1]; 176 | highLow = [[NSString alloc] initWithFormat:@"Hi:%@°F - Lo:%@°F", amPeriod.temp, period.temp]; 177 | } 178 | 179 | self.wxAnnotation.subtitle = highLow; 180 | [highLow release];*/ 181 | 182 | // Create and add the right button to the callout 183 | rightCalloutButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 184 | [wxAnnotationView setRightCalloutAccessoryView:rightCalloutButton]; 185 | 186 | [self updateAnnotation]; 187 | 188 | [self crawlViews]; 189 | } 190 | 191 | DLog(@"End"); 192 | } 193 | 194 | - (void)dataModelUpdating{ 195 | DLog(@"Start"); 196 | 197 | if (wxDataModel.state == Updating){ 198 | [self.activityIndicator startAnimating]; 199 | self.activityView.alpha = 0.5; 200 | } else { 201 | [self.activityIndicator stopAnimating]; 202 | self.activityView.alpha = 0.0; 203 | } 204 | 205 | DLog(@"End"); 206 | } 207 | 208 | 209 | #pragma mark - 210 | #pragma mark UIViewController methods 211 | - (void)viewDidLoad { 212 | [super viewDidLoad]; 213 | 214 | NSString *mapType = [[NSUserDefaults standardUserDefaults]stringForKey:@"map_type_preference"]; 215 | if ([mapType isEqualToString:@"Standard"]){ 216 | self.mapView.mapType = MKMapTypeStandard; 217 | } else if ([mapType isEqualToString:@"Satellite"]){ 218 | self.mapView.mapType = MKMapTypeSatellite; 219 | } else if ([mapType isEqualToString:@"Hybrid"]){ 220 | self.mapView.mapType = MKMapTypeHybrid; 221 | } 222 | } 223 | 224 | - (void)viewWillAppear:(BOOL)animated{ 225 | [super viewWillAppear:animated]; 226 | 227 | [wxDataModel.gpsDataModel addObserver:self forKeyPath:@"state" options:0 context:NULL]; 228 | [wxDataModel.locationDataModel addObserver:self forKeyPath:@"state" options:0 context:NULL]; 229 | [wxDataModel.noaaDataModel addObserver:self forKeyPath:@"state" options:0 context:NULL]; 230 | [wxDataModel.currentConditionsDataModel addObserver:self forKeyPath:@"state" options:0 context:NULL]; 231 | 232 | [wxDataModel addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptionNew) context:nil]; 233 | 234 | [self gpsUpdated]; 235 | [self locationNameUpdated]; 236 | [self currentConditionsUpdated]; 237 | [self forecastsUpdated]; 238 | } 239 | 240 | - (void)viewDidAppear:(BOOL)animated{ 241 | [self dataModelUpdating]; 242 | [super viewDidAppear:animated]; 243 | } 244 | 245 | - (void)viewWillDisappear:(BOOL)animated{ 246 | [super viewWillDisappear:animated]; 247 | 248 | [wxDataModel.gpsDataModel removeObserver:self forKeyPath:@"state"]; 249 | [wxDataModel.locationDataModel removeObserver:self forKeyPath:@"state"]; 250 | [wxDataModel.noaaDataModel removeObserver:self forKeyPath:@"state"]; 251 | [wxDataModel.currentConditionsDataModel removeObserver:self forKeyPath:@"state"]; 252 | 253 | [wxDataModel removeObserver:self forKeyPath:@"state"]; 254 | } 255 | 256 | #pragma mark - 257 | #pragma mark MKMapViewDelegate Protocol implementation 258 | 259 | - (void)mapView:(MKMapView *)localMapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { 260 | WxHereAppDelegate *appDelegate = ((WxHereAppDelegate *)([UIApplication sharedApplication].delegate)); 261 | appDelegate.tabBarController.selectedIndex = 1; 262 | } 263 | 264 | - (void)mapView:(MKMapView *)localMapView regionDidChangeAnimated:(BOOL)animated{ 265 | [self updateAnnotation]; 266 | } 267 | 268 | - (void)mapView:(MKMapView *)localMapView didAddAnnotationViews:(NSArray *)views{ 269 | [self.mapView selectAnnotation:wxAnnotation animated:NO]; 270 | 271 | if (memoryWarning){ 272 | memoryWarning = NO; 273 | [self dataModelUpdating]; 274 | [self gpsUpdated]; 275 | [self locationNameUpdated]; 276 | [self currentConditionsUpdated]; 277 | [self forecastsUpdated]; 278 | } 279 | } 280 | 281 | - (MKAnnotationView *)mapView:(MKMapView *)localMapView viewForAnnotation:(id )annotation{ 282 | return wxAnnotationView; 283 | } 284 | 285 | #pragma mark - 286 | 287 | - (void)updateAnnotation{ 288 | if ([self.mapView selectedAnnotations]){ 289 | [self.mapView deselectAnnotation:wxAnnotation animated:NO]; 290 | [self.mapView selectAnnotation:wxAnnotation animated:NO]; 291 | } 292 | } 293 | 294 | - (IBAction)refreshDataModel:(id)sender{ 295 | // Clear the annotation 296 | [self.mapView removeAnnotation:wxAnnotation]; 297 | 298 | if (rightCalloutButton != nil){ 299 | [rightCalloutButton release]; 300 | rightCalloutButton = nil; 301 | } 302 | 303 | if (wxAnnotation != nil){ 304 | [wxAnnotation release]; 305 | wxAnnotation = nil; 306 | } 307 | if (wxAnnotationView != nil){ 308 | [wxAnnotationView release]; 309 | wxAnnotationView = nil; 310 | } 311 | 312 | // Clear the navigation title 313 | self.navigationBar.topItem.title = @""; 314 | [self.navigationBar setNeedsDisplay]; 315 | 316 | // Refresh the data model 317 | [wxDataModel refresh]; 318 | 319 | // Refresh the activity indicator 320 | [self dataModelUpdating]; 321 | } 322 | 323 | - (void)crawlViews{ 324 | UIApplication *app = [UIApplication sharedApplication]; 325 | for (UIView *view in app.windows){ 326 | [self crawlViews:view]; 327 | } 328 | } 329 | 330 | - (void)crawlViews:(UIView *)view{ 331 | DLog(@"view - %@", view); 332 | for(UIView *subview in [view subviews]){ 333 | [self crawlViews:subview]; 334 | } 335 | } 336 | 337 | @end 338 | --------------------------------------------------------------------------------