diff --git a/CFuWx.xcodeproj/project.pbxproj b/CFuWx.xcodeproj/project.pbxproj index d8d3d6f..46c296d 100644 --- a/CFuWx.xcodeproj/project.pbxproj +++ b/CFuWx.xcodeproj/project.pbxproj @@ -15,6 +15,8 @@ 0180B8361E08F4B000B63BE8 /* HomeViewTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0180B8351E08F4B000B63BE8 /* HomeViewTest.m */; }; 0180B8381E08F4CB00B63BE8 /* SettingsViewTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0180B8371E08F4CB00B63BE8 /* SettingsViewTest.m */; }; 0197C2521E09CE79006D7A29 /* DarkSkyAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = 0197C2511E09CE79006D7A29 /* DarkSkyAPI.m */; }; + 0197C2551E09E661006D7A29 /* TopTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0197C2541E09E661006D7A29 /* TopTableViewCell.m */; }; + 0197C2581E09E66E006D7A29 /* BottomTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0197C2571E09E66E006D7A29 /* BottomTableViewCell.m */; }; 555CD9BF1E08CAC6002E72DA /* ChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 555CD9BD1E08CAC6002E72DA /* ChartViewController.m */; }; 555CD9C31E08CE2F002E72DA /* Altimeter.m in Sources */ = {isa = PBXBuildFile; fileRef = 555CD9C21E08CE2F002E72DA /* Altimeter.m */; }; 555FA1FD1E06FE680036FC1E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 555FA1FC1E06FE680036FC1E /* main.m */; }; @@ -44,6 +46,7 @@ 55DC16601E09E37D00E5A8A6 /* Conversions.m in Sources */ = {isa = PBXBuildFile; fileRef = 55DC165F1E09E37D00E5A8A6 /* Conversions.m */; }; 55F25CA71E09F1C900BAF2FA /* garbage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55F25CA61E09F1C900BAF2FA /* garbage.swift */; }; 55F25CA91E09F24D00BAF2FA /* ConversionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 55F25CA81E09F24D00BAF2FA /* ConversionsTest.m */; }; + 7CF703561E09FEC800354143 /* LocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CF703551E09FEC800354143 /* LocationManager.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -81,6 +84,10 @@ 0180B8371E08F4CB00B63BE8 /* SettingsViewTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewTest.m; sourceTree = ""; }; 0197C2501E09CE79006D7A29 /* DarkSkyAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DarkSkyAPI.h; sourceTree = ""; }; 0197C2511E09CE79006D7A29 /* DarkSkyAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DarkSkyAPI.m; sourceTree = ""; }; + 0197C2531E09E661006D7A29 /* TopTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopTableViewCell.h; sourceTree = ""; }; + 0197C2541E09E661006D7A29 /* TopTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopTableViewCell.m; sourceTree = ""; }; + 0197C2561E09E66E006D7A29 /* BottomTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BottomTableViewCell.h; sourceTree = ""; }; + 0197C2571E09E66E006D7A29 /* BottomTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BottomTableViewCell.m; sourceTree = ""; }; 555CD9B81E08C4DE002E72DA /* CFuWx-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CFuWx-Bridging-Header.h"; sourceTree = ""; }; 555CD9BC1E08CAC6002E72DA /* ChartViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartViewController.h; sourceTree = ""; }; 555CD9BD1E08CAC6002E72DA /* ChartViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChartViewController.m; sourceTree = ""; }; @@ -109,7 +116,6 @@ 555FA2371E0701C40036FC1E /* ForecastViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ForecastViewController.m; sourceTree = ""; }; 555FA23A1E0701CF0036FC1E /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; }; 555FA23B1E0701CF0036FC1E /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; }; - 55DC16501E09C3B100E5A8A6 /* Credentials.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Credentials.h; sourceTree = ""; }; 55DC16511E09C70800E5A8A6 /* Bolts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Bolts.framework; path = Carthage/Build/iOS/Bolts.framework; sourceTree = ""; }; 55DC16521E09C70800E5A8A6 /* Charts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Charts.framework; path = Carthage/Build/iOS/Charts.framework; sourceTree = ""; }; 55DC16531E09C70800E5A8A6 /* Parse.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Parse.framework; path = Carthage/Build/iOS/Parse.framework; sourceTree = ""; }; @@ -117,6 +123,9 @@ 55DC165F1E09E37D00E5A8A6 /* Conversions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Conversions.m; sourceTree = ""; }; 55F25CA61E09F1C900BAF2FA /* garbage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = garbage.swift; sourceTree = ""; }; 55F25CA81E09F24D00BAF2FA /* ConversionsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConversionsTest.m; sourceTree = ""; }; + 7C008A401E09EA0300040CB9 /* Credentials.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Credentials.h; sourceTree = ""; }; + 7CF703541E09FEC800354143 /* LocationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocationManager.h; sourceTree = ""; }; + 7CF703551E09FEC800354143 /* LocationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocationManager.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -183,7 +192,7 @@ 555FA1FB1E06FE680036FC1E /* Supporting Files */ = { isa = PBXGroup; children = ( - 55DC16501E09C3B100E5A8A6 /* Credentials.h */, + 7C008A401E09EA0300040CB9 /* Credentials.h */, 555CD9B81E08C4DE002E72DA /* CFuWx-Bridging-Header.h */, 0180B82B1E088C5E00B63BE8 /* forecast.JSON */, 555FA1FE1E06FE680036FC1E /* AppDelegate.h */, @@ -214,11 +223,15 @@ 555FA2251E0700890036FC1E /* View */ = { isa = PBXGroup; children = ( + 0197C2531E09E661006D7A29 /* TopTableViewCell.h */, + 0197C2541E09E661006D7A29 /* TopTableViewCell.m */, 555FA22C1E0701380036FC1E /* About.storyboard */, 555FA2281E0700E90036FC1E /* Forecast.storyboard */, 555FA2041E06FE680036FC1E /* Main.storyboard */, 555FA22A1E0701110036FC1E /* Settings.storyboard */, 555FA20C1E06FE680036FC1E /* LaunchScreen.storyboard */, + 0197C2561E09E66E006D7A29 /* BottomTableViewCell.h */, + 0197C2571E09E66E006D7A29 /* BottomTableViewCell.m */, ); name = View; sourceTree = ""; @@ -226,6 +239,8 @@ 555FA2261E0700B80036FC1E /* Model */ = { isa = PBXGroup; children = ( + 7CF703541E09FEC800354143 /* LocationManager.h */, + 7CF703551E09FEC800354143 /* LocationManager.m */, 55F25CA61E09F1C900BAF2FA /* garbage.swift */, 55DC165E1E09E37D00E5A8A6 /* Conversions.h */, 55DC165F1E09E37D00E5A8A6 /* Conversions.m */, @@ -386,6 +401,7 @@ buildActionMask = 2147483647; files = ( 555FA2001E06FE680036FC1E /* AppDelegate.m in Sources */, + 0197C2581E09E66E006D7A29 /* BottomTableViewCell.m in Sources */, 555FA2381E0701C40036FC1E /* ForecastViewController.m in Sources */, 0197C2521E09CE79006D7A29 /* DarkSkyAPI.m in Sources */, 555CD9C31E08CE2F002E72DA /* Altimeter.m in Sources */, @@ -393,10 +409,12 @@ 555FA1FD1E06FE680036FC1E /* main.m in Sources */, 55DC16601E09E37D00E5A8A6 /* Conversions.m in Sources */, 555FA2091E06FE680036FC1E /* CFuWx.xcdatamodeld in Sources */, + 0197C2551E09E661006D7A29 /* TopTableViewCell.m in Sources */, 555FA2301E0701A70036FC1E /* HomeViewController.m in Sources */, 55F25CA71E09F1C900BAF2FA /* garbage.swift in Sources */, 555CD9BF1E08CAC6002E72DA /* ChartViewController.m in Sources */, 555FA23C1E0701CF0036FC1E /* SettingsViewController.m in Sources */, + 7CF703561E09FEC800354143 /* LocationManager.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -546,6 +564,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; DEVELOPMENT_TEAM = 4YFWUVNT8L; + ENABLE_BITCODE = YES; FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/Carthage/Build/iOS/"; INFOPLIST_FILE = CFuWx/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.1; @@ -565,6 +584,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; DEVELOPMENT_TEAM = 4YFWUVNT8L; + ENABLE_BITCODE = YES; FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/Carthage/Build/iOS/"; INFOPLIST_FILE = CFuWx/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.1; diff --git a/CFuWx/AboutViewController.m b/CFuWx/AboutViewController.m index 5ae4985..e6c2538 100644 --- a/CFuWx/AboutViewController.m +++ b/CFuWx/AboutViewController.m @@ -24,14 +24,5 @@ - (void)didReceiveMemoryWarning { // Dispose of any resources that can be recreated. } -/* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ @end diff --git a/CFuWx/AppDelegate.m b/CFuWx/AppDelegate.m index 1d0a979..62fa1a4 100644 --- a/CFuWx/AppDelegate.m +++ b/CFuWx/AppDelegate.m @@ -9,6 +9,7 @@ #import "AppDelegate.h" #import "Credentials.h" +#import "DarkSkyAPI.h" @interface AppDelegate () @@ -20,7 +21,7 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id _Nonnull configuration) { - configuration.applicationId = kDarkSkyAPIKey; + configuration.applicationId = kApplicationID; configuration.clientKey = kMasterKey; configuration.server = kServerURL; }]]; @@ -55,7 +56,7 @@ -(void)bootstrapApp{ NSNumber *latitude = responseObj[@"latitude"]; NSNumber *longitude = responseObj[@"longitude"]; - NSLog(@"Time: %@, Latitude: %f, Longtitude: %f", time, latitude.floatValue, longitude.floatValue); +// NSLog(@"Time: %@, Latitude: %f, Longtitude: %f", time, latitude.floatValue, longitude.floatValue); //write method to convert time to readable format, write method to retrieve 'TIMEZONE' from json// diff --git a/CFuWx/Base.lproj/Main.storyboard b/CFuWx/Base.lproj/Main.storyboard index 3a67e0f..836a70c 100644 --- a/CFuWx/Base.lproj/Main.storyboard +++ b/CFuWx/Base.lproj/Main.storyboard @@ -1,11 +1,12 @@ - - + + + - + @@ -31,16 +32,18 @@ - + - + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + diff --git a/CFuWx/BottomTableViewCell.h b/CFuWx/BottomTableViewCell.h new file mode 100644 index 0000000..855ace2 --- /dev/null +++ b/CFuWx/BottomTableViewCell.h @@ -0,0 +1,18 @@ +// +// BottomTableViewCell.h +// CFuWx +// +// Created by Corey Malek on 12/20/16. +// Copyright © 2016 Erica Winberry. All rights reserved. +// + +#import + +@interface BottomTableViewCell : UITableViewCell + + +@property (weak, nonatomic) IBOutlet UILabel *pressure; + + + +@end diff --git a/CFuWx/BottomTableViewCell.m b/CFuWx/BottomTableViewCell.m new file mode 100644 index 0000000..b3da217 --- /dev/null +++ b/CFuWx/BottomTableViewCell.m @@ -0,0 +1,24 @@ +// +// BottomTableViewCell.m +// CFuWx +// +// Created by Corey Malek on 12/20/16. +// Copyright © 2016 Erica Winberry. All rights reserved. +// + +#import "BottomTableViewCell.h" + +@implementation BottomTableViewCell + +- (void)awakeFromNib { + [super awakeFromNib]; + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/CFuWx/ChartViewController.m b/CFuWx/ChartViewController.m index 2b338d6..2e72cf8 100644 --- a/CFuWx/ChartViewController.m +++ b/CFuWx/ChartViewController.m @@ -7,7 +7,7 @@ // #import "ChartViewController.h" -#import "CFuWx-Swift.h" +//#import "CFuWx-Swift.h" @import Charts; @import CoreMotion; diff --git a/CFuWx/Conversions.h b/CFuWx/Conversions.h index 3c14c55..f4be713 100644 --- a/CFuWx/Conversions.h +++ b/CFuWx/Conversions.h @@ -10,14 +10,12 @@ @interface Conversions : NSObject - // Pressure Conversions from kPa +(NSString *)convertToInchesHg:(double)pressure; +(NSString *)convertToMillimetersHg:(double)pressure; +(NSString *)convertToPSI:(double)pressure; +(NSString *)convertToHectoPascal:(double)pressure; - //// Height Conversions from Meters //+(double)convertToFeet:(double)height; //+(double)convertToMiles:(double)height; @@ -38,4 +36,5 @@ // //// Convert Time //+(NSString *)convertToReadableTime:(NSDate *)date; + @end diff --git a/CFuWx/Conversions.m b/CFuWx/Conversions.m index b9b061c..1656c03 100644 --- a/CFuWx/Conversions.m +++ b/CFuWx/Conversions.m @@ -10,7 +10,6 @@ @implementation Conversions - +(NSString *)formattedNumber:(double)numberToFormat { NSNumberFormatter *formatter = [[NSNumberFormatter alloc]init]; formatter = [[NSNumberFormatter alloc]init]; @@ -101,5 +100,4 @@ +(NSString *)convertToHectoPascal:(double)pressure { // //} - @end diff --git a/CFuWx/DarkSkyAPI.h b/CFuWx/DarkSkyAPI.h index 5881027..d834dbf 100644 --- a/CFuWx/DarkSkyAPI.h +++ b/CFuWx/DarkSkyAPI.h @@ -5,7 +5,7 @@ // Created by Corey Malek on 12/20/16. // Copyright © 2016 Erica Winberry. All rights reserved. // - +#import #import @class DarkSkyAPI; @@ -18,7 +18,9 @@ //public method: @interface DarkSkyAPI : NSObject --(void)httpRequest:(NSURL *)url; +//-(void)httpRequest:(NSURL *)url; +// +//+(void)fetchForecast:(CGFloat)latitude andLong:(CGFloat)longitude; @property(weak, nonatomic) id delegate; diff --git a/CFuWx/DarkSkyAPI.m b/CFuWx/DarkSkyAPI.m index 65648f8..07648fb 100644 --- a/CFuWx/DarkSkyAPI.m +++ b/CFuWx/DarkSkyAPI.m @@ -7,8 +7,12 @@ // #import "DarkSkyAPI.h" +#import "Credentials.h" +#import "AppDelegate.h" +#import "HomeViewController.h" +@import CoreLocation; -@interface DarkSkyAPI() +@interface DarkSkyAPI() @property(strong, nonatomic) NSMutableData *receivedData; @property(strong, nonatomic) NSURLConnection *requestURL; @@ -18,9 +22,22 @@ @interface DarkSkyAPI() @implementation DarkSkyAPI +//+(void)fetchForecast:(CLLocationCoordinate2D) coordinate{ +// +// NSString *baseURL = @"https://api.darkysky.net/forecast/"; +// NSString *requestURL = [NSString stringWithFormat:@"%@%@/%f,%f", baseURL,kDarkSkyAPIKey, coordinate.latitude, coordinate.longitude]; +// +// NSLog(@"%@", requestURL); +// +//} + + + -(NSMutableData *)receivedData { if(!_receivedData){ _receivedData = [[NSMutableData alloc]init]; + +// [HomeViewController ] } return _receivedData; } @@ -33,17 +50,18 @@ -(NSURLConnection *)requestURL { } --(void)httpRequest:(NSURL *)url{ - NSURLSession *session = [NSURLSession sharedSession]; - [session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { - if(!error){ - [self.delegate fetchData:data sender:self]; - self.delegate = nil; - } else { - NSLog(@"Error Fetching Data"); - } - }]; -} +//-(void)httpRequest:(NSURL *)url{ +// NSURLSession *session = [NSURLSession sharedSession]; +// [session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { +// if(!error){ +// [self.delegate fetchData:data sender:self]; +// self.delegate = nil; +// } else { +// NSLog(@"Error Fetching Data"); +// +// } +// }]; +//} @@ -53,20 +71,11 @@ -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ - - - - - - -//-(void)connectionDidFinishLoading:(NSURLConnection *)connection{ -// -// [self.delegate fetchData:self.receivedData sender:self]; -// //setting to 'nil' will ensure that once the method makes connection to API, it will refresh and instantiate again when needed (see setter methods) -// self.delegate = nil; -// self.receivedData = nil; -// self.requestURL = nil; -//} +-(void)connectionDidFinishLoading:(NSURLConnection *)connection{ + //setting to 'nil' will ensure that once the method makes connection to API, it will refresh and instantiate again when needed (see setter methods) + self.receivedData = nil; + self.requestURL = nil; +} diff --git a/CFuWx/HomeViewController.h b/CFuWx/HomeViewController.h index 1ddc23d..d498ebe 100644 --- a/CFuWx/HomeViewController.h +++ b/CFuWx/HomeViewController.h @@ -7,8 +7,15 @@ // #import +#import "TopTableViewCell.h" +#import "BottomTableViewCell.h" + +@import CoreLocation; @interface HomeViewController : UIViewController +@property(strong, nonatomic) NSString *currentCity; +@property(strong, nonatomic) UITableView *tableView; + @end diff --git a/CFuWx/HomeViewController.m b/CFuWx/HomeViewController.m index c7befb4..27d4b38 100644 --- a/CFuWx/HomeViewController.m +++ b/CFuWx/HomeViewController.m @@ -7,16 +7,15 @@ // #import "HomeViewController.h" +#import "LocationManager.h" #import "Altimeter.h" @import CoreLocation; @interface HomeViewController () -@property(strong, nonatomic)Altimeter *altimeter; -@property(strong, nonatomic)CLLocationManager *locationManager; -//@property(strong, nonatomic)CLGeocoder *gecoder; -@property(strong, nonatomic)CLPlacemark *placemark; +@property(strong, nonatomic)Altimeter *homeAltimeter; +//@property(strong, nonatomic) LocationManager *locationManager; @end @@ -26,59 +25,16 @@ - (void)viewDidLoad { [super viewDidLoad]; // Core Location request permission for user's current location - [self requestPermissions]; - [self getCurrentLocationWithCoordinatesAndAltitude]; + [[LocationManager sharedManager] requestPermissions]; + [[LocationManager sharedManager] getCurrentLocationWithCoordinatesAndAltitude]; - [self reverseGeocode:self.locationManager.location]; - - Altimeter *altimeter = [[Altimeter alloc]init]; - [altimeter getAltitudeChange]; + // [[[LocationManager sharedManager] reverseGeocode:[LocationManager sharedManager] locationManager]; + CLLocation *location = [[CLLocation alloc]init]; + [[LocationManager sharedManager] reverseGeocode:location]; + NSLog(@"%@", location); + Altimeter * homeAltimeter = [[Altimeter alloc]init]; + [ homeAltimeter getAltitudeChange]; } --(void)requestPermissions { - if ( ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) || ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted) || ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) ) { - NSLog(@"not authorized for location services"); - [self.locationManager requestWhenInUseAuthorization]; - //[self setLocationManager:[[CLLocationManager alloc]init]]; - //[CLLocationManager locationServicesEnabled]; - } else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse) { - NSLog(@"authorized for location services"); - [self setLocationManager:[[CLLocationManager alloc]init]]; - [CLLocationManager locationServicesEnabled]; - } -} --(NSString *)getCurrentLocationWithCoordinatesAndAltitude { - self.locationManager.distanceFilter = kCLDistanceFilterNone; - self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; - [self.locationManager startUpdatingLocation]; - - NSString *currentLocation = [NSString stringWithFormat:@"latitude: %f longitude: %f altitude: %f city: %@", self.locationManager.location.coordinate.latitude, self.locationManager.location.coordinate.longitude, self.locationManager.location.altitude, [self reverseGeocode:self.locationManager.location]]; //putting coordinates(lat/long) and altitude as floats into string - - NSLog(@"%@", currentLocation); - - return currentLocation; -} - --(NSString *)reverseGeocode:(CLLocation *)location { - CLGeocoder *geocoder = [[CLGeocoder alloc]init]; - //CLLocation *location = self.locationManager.location; - - [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { - //NSLog(@"Found placemarks: %@, error: %@", placemarks, error); - - if (error == nil && [placemarks count] > 0) { - _placemark = [placemarks lastObject]; - - NSLog(@"city: %@", _placemark.locality); //city name - NSLog(@"timeZone: %@", _placemark.timeZone); //time zone - NSLog(@"region: %@", _placemark.region); //CLCircularRegion(lat, long, radius(of region)) - NSLog(@"state: %@", _placemark.administrativeArea); //state - NSLog(@"county: %@", _placemark.subAdministrativeArea); //county - NSLog(@"country: %@", _placemark.country); //country - NSLog(@"zip: %@", _placemark.postalCode); //zip code - } - }]; - return _placemark.locality; -} @end diff --git a/CFuWx/LocationManager.h b/CFuWx/LocationManager.h new file mode 100644 index 0000000..954e8f5 --- /dev/null +++ b/CFuWx/LocationManager.h @@ -0,0 +1,25 @@ +// +// LocationManager.h +// CFuWx +// +// Created by Jacob Dobson on 12/20/16. +// Copyright © 2016 Erica Winberry. All rights reserved. +// + +#import + +@import CoreLocation; + +@interface LocationManager : NSObject + ++(instancetype)sharedManager; + +-(void)requestPermissions; + +-(NSString *)getCurrentLocationWithCoordinatesAndAltitude; + +//-(CLLocationCoordinate2D)returnCoordinate; + +-(NSString *)reverseGeocode:(CLLocation *)location; + +@end diff --git a/CFuWx/LocationManager.m b/CFuWx/LocationManager.m new file mode 100644 index 0000000..94e7fae --- /dev/null +++ b/CFuWx/LocationManager.m @@ -0,0 +1,87 @@ +// +// LocationManager.m +// CFuWx +// +// Created by Jacob Dobson on 12/20/16. +// Copyright © 2016 Erica Winberry. All rights reserved. +// + +#import "LocationManager.h" + +@interface LocationManager() + +@property(strong, nonatomic)CLLocationManager *locationManager; +@property(strong, nonatomic)CLPlacemark *placemark; +@property(strong, nonatomic)CLLocation *coordinateLocation; + +@end + + +@implementation LocationManager + ++(instancetype)sharedManager { + static LocationManager *sharedManager; + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedManager = [[LocationManager alloc]init]; + }); + return sharedManager; +} + +-(void)requestPermissions { + if ( ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) || ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted) || ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) ) { + NSLog(@"not authorized for location services"); + [self.locationManager requestWhenInUseAuthorization]; + //[self setLocationManager:[[CLLocationManager alloc]init]]; + //[CLLocationManager locationServicesEnabled]; + } else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse) { + NSLog(@"authorized for location services"); + [self setLocationManager:[[CLLocationManager alloc]init]]; + [CLLocationManager locationServicesEnabled]; + } +} + +-(NSString *)getCurrentLocationWithCoordinatesAndAltitude { + self.locationManager.distanceFilter = kCLDistanceFilterNone; + self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; + [self.locationManager startUpdatingLocation]; + + NSString *currentLocation = [NSString stringWithFormat:@"latitude: %f longitude: %f altitude: %f city: %@", self.locationManager.location.coordinate.latitude, self.locationManager.location.coordinate.longitude, self.locationManager.location.altitude, [self reverseGeocode:self.locationManager.location]]; //putting coordinates(lat/long) and altitude as floats into string + + NSLog(@"%@", currentLocation); + + return currentLocation; +} + +//-(CLLocationCoordinate2D)returnCoordinate { +// CLLocationCoordinate2D coordinate = +// [CLLocationCoordinate2DMake([LocationManager sharedManager] locationManager.location.coordinate.latitude], ; +// return coordinate; +//} + + + +-(NSString *)reverseGeocode:(CLLocation *)location { + CLGeocoder *geocoder = [[CLGeocoder alloc]init]; + //CLLocation *location = self.locationManager.location; + + [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { + //NSLog(@"Found placemarks: %@, error: %@", placemarks, error); + + if (error == nil && [placemarks count] > 0) { + _placemark = [placemarks lastObject]; + + NSLog(@"city: %@", _placemark.locality); //city name + NSLog(@"timeZone: %@", _placemark.timeZone); //time zone + NSLog(@"region: %@", _placemark.region); //CLCircularRegion(lat, long, radius(of region)) + NSLog(@"state: %@", _placemark.administrativeArea); //state + NSLog(@"county: %@", _placemark.subAdministrativeArea); //county + NSLog(@"country: %@", _placemark.country); //country + NSLog(@"zip: %@", _placemark.postalCode); //zip code + } + }]; + return _placemark.locality; +} + +@end diff --git a/CFuWx/TopTableViewCell.h b/CFuWx/TopTableViewCell.h new file mode 100644 index 0000000..a286459 --- /dev/null +++ b/CFuWx/TopTableViewCell.h @@ -0,0 +1,25 @@ +// +// TopTableViewCell.h +// CFuWx +// +// Created by Corey Malek on 12/20/16. +// Copyright © 2016 Erica Winberry. All rights reserved. +// + +#import +#import "HomeViewController.h" + +@interface TopTableViewCell : UITableViewCell + + + + +@property (weak, nonatomic) IBOutlet UILabel *time; + +@property (weak, nonatomic) IBOutlet UILabel *date; + +@property (weak, nonatomic) IBOutlet UILabel *location; + +@property (weak, nonatomic) IBOutlet UILabel *temperature; + +@end diff --git a/CFuWx/TopTableViewCell.m b/CFuWx/TopTableViewCell.m new file mode 100644 index 0000000..94002fe --- /dev/null +++ b/CFuWx/TopTableViewCell.m @@ -0,0 +1,37 @@ +// +// TopTableViewCell.m +// CFuWx +// +// Created by Corey Malek on 12/20/16. +// Copyright © 2016 Erica Winberry. All rights reserved. +// + +#import "TopTableViewCell.h" +@interface TopTableViewCell() + +@property(strong, nonatomic) HomeViewController *homeViewController; + + +@end + +@implementation TopTableViewCell + + + + + + +- (void)awakeFromNib { + [super awakeFromNib]; + _location.text = _homeViewController.currentCity; + + NSLog(@"%@", _homeViewController.currentCity); +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/CFuWxTests/ConversionsTest.m b/CFuWxTests/ConversionsTest.m index 46cc331..3378ff2 100644 --- a/CFuWxTests/ConversionsTest.m +++ b/CFuWxTests/ConversionsTest.m @@ -41,7 +41,7 @@ -(void)testConvertToPSI { } -(void)testConvertToHectoPascal { - XCTAssert([[Conversions convertToHectoPascal:1.0] isEqualToString:@"0.15"], @"Value returned from conversion is %@, NOT 0.15!", [Conversions convertToPSI:1.0]); + XCTAssert([[Conversions convertToHectoPascal:1.0] isEqualToString:@"0.15"], @"Value returned from conversion is %@, NOT 0.15!", [Conversions convertToHectoPascal:1.0]); } diff --git a/garbage.swift b/garbage.swift deleted file mode 100644 index ba2952d..0000000 --- a/garbage.swift +++ /dev/null @@ -1,9 +0,0 @@ -// -// garbage.swift -// CFuWx -// -// Created by Adam Wallraff on 12/20/16. -// Copyright © 2016 Erica Winberry. All rights reserved. -// - -import Foundation