diff --git a/unit-2-assessment/unit-2-assessment.xcodeproj/project.pbxproj b/unit-2-assessment/unit-2-assessment.xcodeproj/project.pbxproj index 838d4b4..43ab74c 100644 --- a/unit-2-assessment/unit-2-assessment.xcodeproj/project.pbxproj +++ b/unit-2-assessment/unit-2-assessment.xcodeproj/project.pbxproj @@ -7,9 +7,17 @@ objects = { /* Begin PBXBuildFile section */ + 5F70449C1BD2CF9300696575 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F70449B1BD2CF9300696575 /* CoreLocation.framework */; }; + 5FCD93871BD2952B00AB45E1 /* LatLngVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FCD93861BD2952B00AB45E1 /* LatLngVC.m */; }; + 5FCD938A1BD2956900AB45E1 /* WeatherDataTVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FCD93891BD2956900AB45E1 /* WeatherDataTVC.m */; }; + 5FCD938D1BD2958400AB45E1 /* DetailVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FCD938C1BD2958400AB45E1 /* DetailVC.m */; }; + 5FCD93901BD2966600AB45E1 /* APIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FCD938F1BD2966600AB45E1 /* APIManager.m */; }; + 5FCD93931BD2970500AB45E1 /* WeatherSearchResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FCD93921BD2970500AB45E1 /* WeatherSearchResult.m */; }; + 5FCD939D1BD2C15500AB45E1 /* CustomTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FCD939B1BD2C15500AB45E1 /* CustomTableViewCell.m */; }; + 5FCD939E1BD2C15500AB45E1 /* CustomTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5FCD939C1BD2C15500AB45E1 /* CustomTableViewCell.xib */; }; + 8B025465E9CFD2CF7AB886B1 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D09B7098BB7C78E315E95675 /* libPods.a */; }; 8D6765A61BD289BC00B30411 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D6765A51BD289BC00B30411 /* main.m */; }; 8D6765A91BD289BC00B30411 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D6765A81BD289BC00B30411 /* AppDelegate.m */; }; - 8D6765AC1BD289BC00B30411 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D6765AB1BD289BC00B30411 /* ViewController.m */; }; 8D6765AF1BD289BC00B30411 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D6765AD1BD289BC00B30411 /* Main.storyboard */; }; 8D6765B21BD289BC00B30411 /* unit_2_assessment.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 8D6765B01BD289BC00B30411 /* unit_2_assessment.xcdatamodeld */; }; 8D6765B41BD289BC00B30411 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8D6765B31BD289BC00B30411 /* Assets.xcassets */; }; @@ -17,17 +25,32 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 5F70449B1BD2CF9300696575 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + 5FCD93851BD2952B00AB45E1 /* LatLngVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LatLngVC.h; sourceTree = ""; }; + 5FCD93861BD2952B00AB45E1 /* LatLngVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LatLngVC.m; sourceTree = ""; }; + 5FCD93881BD2956900AB45E1 /* WeatherDataTVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeatherDataTVC.h; sourceTree = ""; }; + 5FCD93891BD2956900AB45E1 /* WeatherDataTVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WeatherDataTVC.m; sourceTree = ""; }; + 5FCD938B1BD2958400AB45E1 /* DetailVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailVC.h; sourceTree = ""; }; + 5FCD938C1BD2958400AB45E1 /* DetailVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailVC.m; sourceTree = ""; }; + 5FCD938E1BD2966600AB45E1 /* APIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIManager.h; sourceTree = ""; }; + 5FCD938F1BD2966600AB45E1 /* APIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIManager.m; sourceTree = ""; }; + 5FCD93911BD2970500AB45E1 /* WeatherSearchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeatherSearchResult.h; sourceTree = ""; }; + 5FCD93921BD2970500AB45E1 /* WeatherSearchResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WeatherSearchResult.m; sourceTree = ""; }; + 5FCD939A1BD2C15500AB45E1 /* CustomTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomTableViewCell.h; sourceTree = ""; }; + 5FCD939B1BD2C15500AB45E1 /* CustomTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomTableViewCell.m; sourceTree = ""; }; + 5FCD939C1BD2C15500AB45E1 /* CustomTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CustomTableViewCell.xib; sourceTree = ""; }; 8D6765A11BD289BC00B30411 /* unit-2-assessment.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "unit-2-assessment.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 8D6765A51BD289BC00B30411 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8D6765A71BD289BC00B30411 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 8D6765A81BD289BC00B30411 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 8D6765AA1BD289BC00B30411 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 8D6765AB1BD289BC00B30411 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 8D6765AE1BD289BC00B30411 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 8D6765B11BD289BC00B30411 /* unit_2_assessment.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = unit_2_assessment.xcdatamodel; sourceTree = ""; }; 8D6765B31BD289BC00B30411 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 8D6765B61BD289BC00B30411 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 8D6765B81BD289BC00B30411 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 98CBBD618EAAC847CBCB0D2F /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + D09B7098BB7C78E315E95675 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + F8938A77A36B094C8F848283 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,17 +58,99 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 5F70449C1BD2CF9300696575 /* CoreLocation.framework in Frameworks */, + 8B025465E9CFD2CF7AB886B1 /* libPods.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1EDD5F6705583C65DAE9FE6A /* Pods */ = { + isa = PBXGroup; + children = ( + 98CBBD618EAAC847CBCB0D2F /* Pods.debug.xcconfig */, + F8938A77A36B094C8F848283 /* Pods.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + 57EEB2C397C5D68948476A6D /* Frameworks */ = { + isa = PBXGroup; + children = ( + 5F70449B1BD2CF9300696575 /* CoreLocation.framework */, + D09B7098BB7C78E315E95675 /* libPods.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 5F7044A01BD2D86C00696575 /* User */ = { + isa = PBXGroup; + children = ( + 5FCD93851BD2952B00AB45E1 /* LatLngVC.h */, + 5FCD93861BD2952B00AB45E1 /* LatLngVC.m */, + ); + name = User; + sourceTree = ""; + }; + 5FCD93981BD2C04100AB45E1 /* SimpleWeather */ = { + isa = PBXGroup; + children = ( + 5FCDF8C11BD2DC2500B4EA8A /* APIManager */, + 5F7044A01BD2D86C00696575 /* User */, + 5FCDF8C21BD2DC5100B4EA8A /* WeatherData */, + 5FCDF8C31BD2DC7900B4EA8A /* DetailVC */, + 5FCDF8C41BD2DC8700B4EA8A /* CustomTVCell */, + ); + name = SimpleWeather; + sourceTree = ""; + }; + 5FCDF8C11BD2DC2500B4EA8A /* APIManager */ = { + isa = PBXGroup; + children = ( + 5FCD938E1BD2966600AB45E1 /* APIManager.h */, + 5FCD938F1BD2966600AB45E1 /* APIManager.m */, + ); + name = APIManager; + sourceTree = ""; + }; + 5FCDF8C21BD2DC5100B4EA8A /* WeatherData */ = { + isa = PBXGroup; + children = ( + 5FCD93911BD2970500AB45E1 /* WeatherSearchResult.h */, + 5FCD93921BD2970500AB45E1 /* WeatherSearchResult.m */, + 5FCD93881BD2956900AB45E1 /* WeatherDataTVC.h */, + 5FCD93891BD2956900AB45E1 /* WeatherDataTVC.m */, + ); + name = WeatherData; + sourceTree = ""; + }; + 5FCDF8C31BD2DC7900B4EA8A /* DetailVC */ = { + isa = PBXGroup; + children = ( + 5FCD938B1BD2958400AB45E1 /* DetailVC.h */, + 5FCD938C1BD2958400AB45E1 /* DetailVC.m */, + ); + name = DetailVC; + sourceTree = ""; + }; + 5FCDF8C41BD2DC8700B4EA8A /* CustomTVCell */ = { + isa = PBXGroup; + children = ( + 5FCD939A1BD2C15500AB45E1 /* CustomTableViewCell.h */, + 5FCD939B1BD2C15500AB45E1 /* CustomTableViewCell.m */, + 5FCD939C1BD2C15500AB45E1 /* CustomTableViewCell.xib */, + ); + name = CustomTVCell; + sourceTree = ""; + }; 8D6765981BD289BC00B30411 = { isa = PBXGroup; children = ( 8D6765A31BD289BC00B30411 /* unit-2-assessment */, 8D6765A21BD289BC00B30411 /* Products */, + 57EEB2C397C5D68948476A6D /* Frameworks */, + 1EDD5F6705583C65DAE9FE6A /* Pods */, ); sourceTree = ""; }; @@ -62,8 +167,7 @@ children = ( 8D6765A71BD289BC00B30411 /* AppDelegate.h */, 8D6765A81BD289BC00B30411 /* AppDelegate.m */, - 8D6765AA1BD289BC00B30411 /* ViewController.h */, - 8D6765AB1BD289BC00B30411 /* ViewController.m */, + 5FCD93981BD2C04100AB45E1 /* SimpleWeather */, 8D6765AD1BD289BC00B30411 /* Main.storyboard */, 8D6765B31BD289BC00B30411 /* Assets.xcassets */, 8D6765B51BD289BC00B30411 /* LaunchScreen.storyboard */, @@ -89,9 +193,11 @@ isa = PBXNativeTarget; buildConfigurationList = 8D6765BB1BD289BC00B30411 /* Build configuration list for PBXNativeTarget "unit-2-assessment" */; buildPhases = ( + 749E238488EAA81C920BC049 /* Check Pods Manifest.lock */, 8D67659D1BD289BC00B30411 /* Sources */, 8D67659E1BD289BC00B30411 /* Frameworks */, 8D67659F1BD289BC00B30411 /* Resources */, + 63EB952C19A668D1614DF63F /* Copy Pods Resources */, ); buildRules = ( ); @@ -141,21 +247,60 @@ files = ( 8D6765B71BD289BC00B30411 /* LaunchScreen.storyboard in Resources */, 8D6765B41BD289BC00B30411 /* Assets.xcassets in Resources */, + 5FCD939E1BD2C15500AB45E1 /* CustomTableViewCell.xib in Resources */, 8D6765AF1BD289BC00B30411 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 63EB952C19A668D1614DF63F /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 749E238488EAA81C920BC049 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 8D67659D1BD289BC00B30411 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5FCD93871BD2952B00AB45E1 /* LatLngVC.m in Sources */, 8D6765B21BD289BC00B30411 /* unit_2_assessment.xcdatamodeld in Sources */, - 8D6765AC1BD289BC00B30411 /* ViewController.m in Sources */, 8D6765A91BD289BC00B30411 /* AppDelegate.m in Sources */, + 5FCD938D1BD2958400AB45E1 /* DetailVC.m in Sources */, + 5FCD93901BD2966600AB45E1 /* APIManager.m in Sources */, + 5FCD939D1BD2C15500AB45E1 /* CustomTableViewCell.m in Sources */, + 5FCD93931BD2970500AB45E1 /* WeatherSearchResult.m in Sources */, 8D6765A61BD289BC00B30411 /* main.m in Sources */, + 5FCD938A1BD2956900AB45E1 /* WeatherDataTVC.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -263,6 +408,7 @@ }; 8D6765BC1BD289BC00B30411 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 98CBBD618EAAC847CBCB0D2F /* Pods.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = "unit-2-assessment/Info.plist"; @@ -274,6 +420,7 @@ }; 8D6765BD1BD289BC00B30411 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = F8938A77A36B094C8F848283 /* Pods.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = "unit-2-assessment/Info.plist"; @@ -302,6 +449,7 @@ 8D6765BD1BD289BC00B30411 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ diff --git a/unit-2-assessment/unit-2-assessment/APIManager.h b/unit-2-assessment/unit-2-assessment/APIManager.h new file mode 100644 index 0000000..4a0b446 --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/APIManager.h @@ -0,0 +1,20 @@ +// +// APIManager.h +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import + +@interface APIManager : NSObject + + + ++(void) GETRequestWithURL:(NSURL *)URL + completionHandler:(void(^)(NSData *, NSURLResponse *, NSError *)) +completionBlock; + + +@end diff --git a/unit-2-assessment/unit-2-assessment/APIManager.m b/unit-2-assessment/unit-2-assessment/APIManager.m new file mode 100644 index 0000000..38c0a7c --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/APIManager.m @@ -0,0 +1,29 @@ +// +// APIManager.m +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import "APIManager.h" + +@implementation APIManager + ++(void) GETRequestWithURL:(NSURL *)URL + completionHandler:(void(^)(NSData *, NSURLResponse *, NSError *)) +completionBlock { + + NSURLSession *session = [NSURLSession sharedSession]; + + NSURLSessionDataTask *task = [session dataTaskWithURL:URL completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { + + dispatch_async(dispatch_get_main_queue(), ^ { + completionBlock(data, response, error); + }); + + }]; + [task resume]; +} + +@end diff --git a/unit-2-assessment/unit-2-assessment/Assets.xcassets/Contents.json b/unit-2-assessment/unit-2-assessment/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/unit-2-assessment/unit-2-assessment/Base.lproj/Main.storyboard b/unit-2-assessment/unit-2-assessment/Base.lproj/Main.storyboard index e627b3b..b1c3e67 100644 --- a/unit-2-assessment/unit-2-assessment/Base.lproj/Main.storyboard +++ b/unit-2-assessment/unit-2-assessment/Base.lproj/Main.storyboard @@ -1,26 +1,317 @@ - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + diff --git a/unit-2-assessment/unit-2-assessment/CustomTableViewCell.h b/unit-2-assessment/unit-2-assessment/CustomTableViewCell.h new file mode 100644 index 0000000..294f3da --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/CustomTableViewCell.h @@ -0,0 +1,18 @@ +// +// CustomTableViewCell.h +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import + +@interface CustomTableViewCell : UITableViewCell + +@property (weak, nonatomic) IBOutlet UILabel *dayLabel; +@property (weak, nonatomic) IBOutlet UIImageView *weatherImageView; +@property (weak, nonatomic) IBOutlet UILabel *minTempLabel; +@property (weak, nonatomic) IBOutlet UILabel *maxTempLabel; + +@end diff --git a/unit-2-assessment/unit-2-assessment/CustomTableViewCell.m b/unit-2-assessment/unit-2-assessment/CustomTableViewCell.m new file mode 100644 index 0000000..a121d90 --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/CustomTableViewCell.m @@ -0,0 +1,23 @@ +// +// CustomTableViewCell.m +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import "CustomTableViewCell.h" + +@implementation CustomTableViewCell + +- (void)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/unit-2-assessment/unit-2-assessment/CustomTableViewCell.xib b/unit-2-assessment/unit-2-assessment/CustomTableViewCell.xib new file mode 100644 index 0000000..d9db43a --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/CustomTableViewCell.xib @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/unit-2-assessment/unit-2-assessment/DetailVC.h b/unit-2-assessment/unit-2-assessment/DetailVC.h new file mode 100644 index 0000000..e20cbf6 --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/DetailVC.h @@ -0,0 +1,15 @@ +// +// DetailVC.h +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import + +@interface DetailVC : UIViewController + +@property (nonatomic) NSDictionary *detailWeather; + +@end diff --git a/unit-2-assessment/unit-2-assessment/DetailVC.m b/unit-2-assessment/unit-2-assessment/DetailVC.m new file mode 100644 index 0000000..07421db --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/DetailVC.m @@ -0,0 +1,46 @@ +// +// DetailVC.m +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import "DetailVC.h" + +@interface DetailVC () +@property (weak, nonatomic) IBOutlet UIImageView *detailImage; +@property (weak, nonatomic) IBOutlet UILabel *detailSummary; +@property (weak, nonatomic) IBOutlet UILabel *chanceOfRainLabel; +@property (weak, nonatomic) IBOutlet UILabel *humidityLabel; +@property (weak, nonatomic) IBOutlet UILabel *windLabel; + + +@end + +@implementation DetailVC + +- (void)viewDidLoad { + [super viewDidLoad]; + + + self.detailSummary.text = [self.detailWeather objectForKey:@"summary"]; + self.detailImage.image = [UIImage imageNamed: [self.detailWeather objectForKey:@"icon" ]]; + self.chanceOfRainLabel.text = [NSString stringWithFormat:@"%@ %%", [self.detailWeather objectForKey:@"precipProbability"]]; + self.humidityLabel.text = [NSString stringWithFormat:@"%@ %%",[self.detailWeather objectForKey:@"humidity"]]; + self.windLabel.text = [NSString stringWithFormat:@"%@ mph",[self.detailWeather objectForKey:@"windSpeed"]]; + +} + + +/* +#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/unit-2-assessment/unit-2-assessment/ViewController.h b/unit-2-assessment/unit-2-assessment/LatLngVC.h similarity index 53% rename from unit-2-assessment/unit-2-assessment/ViewController.h rename to unit-2-assessment/unit-2-assessment/LatLngVC.h index e41044a..16406b0 100644 --- a/unit-2-assessment/unit-2-assessment/ViewController.h +++ b/unit-2-assessment/unit-2-assessment/LatLngVC.h @@ -1,14 +1,14 @@ // -// ViewController.h +// LatLngVC.h // unit-2-assessment // -// Created by Michael Kavouras on 10/17/15. +// Created by Zoufishan Mehdi on 10/17/15. // Copyright © 2015 Michael Kavouras. All rights reserved. // #import -@interface ViewController : UIViewController +@interface LatLngVC : UIViewController @end diff --git a/unit-2-assessment/unit-2-assessment/LatLngVC.m b/unit-2-assessment/unit-2-assessment/LatLngVC.m new file mode 100644 index 0000000..c88e6c3 --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/LatLngVC.m @@ -0,0 +1,74 @@ +// +// LatLngVC.m +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import "LatLngVC.h" + +@interface LatLngVC () + +@property (weak, nonatomic) IBOutlet UITextField *latTextField; +@property (weak, nonatomic) IBOutlet UITextField *longTextField; +@property (weak, nonatomic) IBOutlet UILabel *latLabel; +@property (weak, nonatomic) IBOutlet UILabel *longLabel; + + +@end + +@implementation LatLngVC + + +- (IBAction)saveButtonTapped:(UIBarButtonItem *)sender { + + NSLog(@"save lat label****** %@", self.latLabel.text); + NSLog(@"save lng label****** %@", self.longLabel.text); + + + NSString *saveLatString = self.latLabel.text; + NSString *saveLngString = self.longLabel.text; + + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + [defaults setObject:saveLatString forKey:@"stringLatSaved"]; + [defaults setObject:saveLngString forKey:@"stringLongSaved"]; + [defaults synchronize]; + + [self.navigationController popViewControllerAnimated:YES]; + +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:YES]; + + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *latStringAppear = [defaults objectForKey:@"stringSaved"]; + NSString *lngStringAppear = [defaults objectForKey:@"stringSaved"]; + + [self.latLabel setText:latStringAppear]; + [self.longLabel setText:lngStringAppear]; + + + + NSLog(@"will appear lat label %@",self.latLabel.text); + NSLog(@"will appear lng label %@",self.longLabel.text); + +} + +#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/unit-2-assessment/unit-2-assessment/ViewController.m b/unit-2-assessment/unit-2-assessment/ViewController.m deleted file mode 100644 index c1f22e5..0000000 --- a/unit-2-assessment/unit-2-assessment/ViewController.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// ViewController.m -// unit-2-assessment -// -// Created by Michael Kavouras on 10/17/15. -// Copyright © 2015 Michael Kavouras. All rights reserved. -// - -#import "ViewController.h" - -@interface ViewController () - -@end - -@implementation ViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -@end diff --git a/unit-2-assessment/unit-2-assessment/WeatherDataTVC.h b/unit-2-assessment/unit-2-assessment/WeatherDataTVC.h new file mode 100644 index 0000000..163da09 --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/WeatherDataTVC.h @@ -0,0 +1,19 @@ +// +// WeatherDataTVC.h +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import + +@interface WeatherDataTVC : UITableViewController + +@property (nonatomic) NSString *date; +@property (nonatomic) NSString *userLat; +@property (nonatomic) NSString *userLong; + +-(void) makeNewForecastAPIRequestWithLatLong:(NSString *)latitude and:(NSString *)longtitude callBackBlock:(void(^)())block; + +@end diff --git a/unit-2-assessment/unit-2-assessment/WeatherDataTVC.m b/unit-2-assessment/unit-2-assessment/WeatherDataTVC.m new file mode 100644 index 0000000..73835a3 --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/WeatherDataTVC.m @@ -0,0 +1,152 @@ +// +// WeatherDataTVC.m +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import "WeatherDataTVC.h" +#import "APIManager.h" + +#import "WeatherSearchResult.h" +#import "CustomTableViewCell.h" +#import "DetailVC.h" + + +@interface WeatherDataTVC () + + +@property (nonatomic) NSArray *results; +@property (nonatomic) NSMutableArray *searchResults; +@end + + +@implementation WeatherDataTVC + + +- (IBAction)settingsButtonTapped:(UIBarButtonItem *)sender { +} + +- (void)viewDidLoad { + + [super viewDidLoad]; + + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *loadLatString = [defaults objectForKey:@"stringLatSaved"]; + NSString *loadLngString = [defaults objectForKey:@"stringLongSaved"]; + + self.userLat = loadLatString; + self.userLong = loadLngString; + + + NSLog(@"UserInput for Lat: %@ User Input for Long: %@", self.userLat, self.userLong); + + [self makeNewForecastAPIRequestWithLatLong:self.userLat and:self.userLong callBackBlock:^{ + [self.tableView reloadData]; + }]; + +} + + +-(void) makeNewForecastAPIRequestWithLatLong:(NSString *)latitude and:(NSString *)longtitude callBackBlock:(void(^)())block +{ + + NSString *urlString = [NSString stringWithFormat:@"https://api.forecast.io/forecast/8040fc5b15adaaafabbe7de9c3ff5458/%@,%@",latitude, longtitude]; + + //encoded url + NSString *encodedString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + + NSLog(@"urlString %@",encodedString); + + //convert urlString to url + NSURL *url = [NSURL URLWithString:encodedString]; + + + [APIManager GETRequestWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + + if (data != nil) { + + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + + NSDictionary *dailyResults = [json objectForKey:@"daily"]; + + self.results = [dailyResults objectForKey:@"data"]; + self.searchResults = [[NSMutableArray alloc] init]; + + for (NSDictionary *result in self.results) { + NSString *time = [result objectForKey:@"time"]; + NSString *iconName = [result objectForKey: @"icon"]; + NSString *tempMin = [result objectForKey: @"temperatureMin"]; + NSString *tempMax = [result objectForKey: @"temperatureMax"]; + + WeatherSearchResult *weatherObject = [[WeatherSearchResult alloc] init]; + weatherObject.weatherDate = time; + weatherObject.weatherImage = iconName; + weatherObject.weatherMin = tempMin; + weatherObject.weatherMax = tempMax; + + [self.searchResults addObject:weatherObject]; + } + block(); + } + }]; +} + + + +#pragma mark - Table view data source + +-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; + +} + +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.searchResults.count; +} + +-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"weatherCellID" forIndexPath:indexPath]; + + WeatherSearchResult *currentResult = self.searchResults[indexPath.row]; + + + NSTimeInterval convertStringToNSTimeInterval = [currentResult.weatherDate doubleValue]; + + NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:convertStringToNSTimeInterval]; + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"EEEE"]; + self.date = [dateFormatter stringFromDate:date]; + + + cell.dayLabel.text = currentResult.weatherDate; + cell.weatherImageView.image = [UIImage imageNamed:currentResult.weatherImage]; + cell.minTempLabel.text = [NSString stringWithFormat:@"%@", currentResult.weatherMin]; + cell.maxTempLabel.text = [NSString stringWithFormat:@"%@", currentResult.weatherMax]; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + + + return cell; +} + + + +-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + + if ([segue.identifier isEqualToString:@"detailVCSeg"]) { + + NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; + + DetailVC *vc = segue.destinationViewController ; + + NSDictionary *currentWeather = self.results[indexPath.row]; + + vc.detailWeather = currentWeather; + + } + +} +@end + diff --git a/unit-2-assessment/unit-2-assessment/WeatherSearchResult.h b/unit-2-assessment/unit-2-assessment/WeatherSearchResult.h new file mode 100644 index 0000000..087882f --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/WeatherSearchResult.h @@ -0,0 +1,26 @@ +// +// WeatherSearchResult.h +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import + +@interface WeatherSearchResult : NSObject + +//table view +@property (nonatomic) NSString *weatherDate; +@property (nonatomic) NSString *weatherMax; +@property (nonatomic) NSString *weatherMin; +@property (nonatomic) NSString *weatherImage; + + +//detail view +@property (nonatomic) NSString *weatherDescription; +@property (nonatomic) NSNumber *weatherChanceOfRain; +@property (nonatomic) NSNumber *weatherHumidity; +@property (nonatomic) NSNumber *weatherWind; + +@end diff --git a/unit-2-assessment/unit-2-assessment/WeatherSearchResult.m b/unit-2-assessment/unit-2-assessment/WeatherSearchResult.m new file mode 100644 index 0000000..de6d80f --- /dev/null +++ b/unit-2-assessment/unit-2-assessment/WeatherSearchResult.m @@ -0,0 +1,13 @@ +// +// WeatherSearchResult.m +// unit-2-assessment +// +// Created by Zoufishan Mehdi on 10/17/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import "WeatherSearchResult.h" + +@implementation WeatherSearchResult + +@end