From 49f26baa32b0d8534aeee8abf590799d97e21aa7 Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 12:31:15 -0400 Subject: [PATCH 01/11] Initial project setup. Bringing in 3 cocoa pod libraries, a prefix header with common helper functions and variables and setup the project structure. --- Philly Bike Share.xcodeproj/project.pbxproj | 135 ++++++++++++++++-- Philly Bike Share/AppDelegate.h | 2 +- Philly Bike Share/AppDelegate.m | 2 +- .../Common/PhillyBikeSharePrefixHeader.pch | 95 ++++++++++++ Philly Bike Share/ViewController.h | 15 -- Philly Bike Share/ViewController.m | 27 ---- Philly Bike Share/main.m | 2 +- .../Philly_Bike_ShareTests.m | 2 +- Podfile | 4 + Podfile.lock | 69 +++++++++ 10 files changed, 296 insertions(+), 57 deletions(-) create mode 100644 Philly Bike Share/Common/PhillyBikeSharePrefixHeader.pch delete mode 100644 Philly Bike Share/ViewController.h delete mode 100644 Philly Bike Share/ViewController.m diff --git a/Philly Bike Share.xcodeproj/project.pbxproj b/Philly Bike Share.xcodeproj/project.pbxproj index b47d4b6..10b765c 100644 --- a/Philly Bike Share.xcodeproj/project.pbxproj +++ b/Philly Bike Share.xcodeproj/project.pbxproj @@ -7,9 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 23647F8F8EF06A39E0D53163 /* libPods-Philly Bike Share.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4422DC82572FB8DD5A765C64 /* libPods-Philly Bike Share.a */; }; 2D192E811B112B170002EB0D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D192E801B112B170002EB0D /* main.m */; }; 2D192E841B112B170002EB0D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D192E831B112B170002EB0D /* AppDelegate.m */; }; - 2D192E871B112B180002EB0D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D192E861B112B180002EB0D /* ViewController.m */; }; 2D192E8A1B112B180002EB0D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2D192E881B112B180002EB0D /* Main.storyboard */; }; 2D192E8C1B112B180002EB0D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2D192E8B1B112B180002EB0D /* Images.xcassets */; }; 2D192E8F1B112B180002EB0D /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2D192E8D1B112B180002EB0D /* LaunchScreen.xib */; }; @@ -32,14 +32,16 @@ 2D192E801B112B170002EB0D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 2D192E821B112B170002EB0D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 2D192E831B112B170002EB0D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 2D192E851B112B170002EB0D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 2D192E861B112B180002EB0D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 2D192E891B112B180002EB0D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 2D192E8B1B112B180002EB0D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 2D192E8E1B112B180002EB0D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 2D192E941B112B180002EB0D /* Philly Bike ShareTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Philly Bike ShareTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 2D192E991B112B180002EB0D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 2D192E9A1B112B180002EB0D /* Philly_Bike_ShareTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Philly_Bike_ShareTests.m; sourceTree = ""; }; + 2D192EAA1B1231E20002EB0D /* PhillyBikeSharePrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PhillyBikeSharePrefixHeader.pch; path = Common/PhillyBikeSharePrefixHeader.pch; sourceTree = ""; }; + 4422DC82572FB8DD5A765C64 /* libPods-Philly Bike Share.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Philly Bike Share.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 8AA9DBB8754381674E9BF027 /* Pods-Philly Bike Share.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.debug.xcconfig"; sourceTree = ""; }; + B25ABDC59BBA56BBABCCB414 /* Pods-Philly Bike Share.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.release.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -47,6 +49,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 23647F8F8EF06A39E0D53163 /* libPods-Philly Bike Share.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -66,6 +69,8 @@ 2D192E7D1B112B170002EB0D /* Philly Bike Share */, 2D192E971B112B180002EB0D /* Philly Bike ShareTests */, 2D192E7C1B112B170002EB0D /* Products */, + DEB81FD0ADEA9B8FE8AC56FA /* Pods */, + A6900DFFF5F389F079AE999C /* Frameworks */, ); sourceTree = ""; }; @@ -81,13 +86,12 @@ 2D192E7D1B112B170002EB0D /* Philly Bike Share */ = { isa = PBXGroup; children = ( - 2D192E821B112B170002EB0D /* AppDelegate.h */, - 2D192E831B112B170002EB0D /* AppDelegate.m */, - 2D192E851B112B170002EB0D /* ViewController.h */, - 2D192E861B112B180002EB0D /* ViewController.m */, - 2D192E881B112B180002EB0D /* Main.storyboard */, - 2D192E8B1B112B180002EB0D /* Images.xcassets */, - 2D192E8D1B112B180002EB0D /* LaunchScreen.xib */, + 2D192EA91B12316F0002EB0D /* Common */, + 2D192EA81B1231570002EB0D /* Models */, + 2D192EA71B12314E0002EB0D /* Managers & Helpers */, + 2D192EA61B1231470002EB0D /* Views */, + 2D192EA51B1231420002EB0D /* Controllers */, + 2D192EA41B1231300002EB0D /* Assets */, 2D192E7E1B112B170002EB0D /* Supporting Files */, ); path = "Philly Bike Share"; @@ -96,6 +100,8 @@ 2D192E7E1B112B170002EB0D /* Supporting Files */ = { isa = PBXGroup; children = ( + 2D192E821B112B170002EB0D /* AppDelegate.h */, + 2D192E831B112B170002EB0D /* AppDelegate.m */, 2D192E7F1B112B170002EB0D /* Info.plist */, 2D192E801B112B170002EB0D /* main.m */, ); @@ -119,6 +125,69 @@ name = "Supporting Files"; sourceTree = ""; }; + 2D192EA41B1231300002EB0D /* Assets */ = { + isa = PBXGroup; + children = ( + 2D192E8B1B112B180002EB0D /* Images.xcassets */, + 2D192E8D1B112B180002EB0D /* LaunchScreen.xib */, + ); + name = Assets; + sourceTree = ""; + }; + 2D192EA51B1231420002EB0D /* Controllers */ = { + isa = PBXGroup; + children = ( + ); + name = Controllers; + sourceTree = ""; + }; + 2D192EA61B1231470002EB0D /* Views */ = { + isa = PBXGroup; + children = ( + 2D192E881B112B180002EB0D /* Main.storyboard */, + ); + name = Views; + sourceTree = ""; + }; + 2D192EA71B12314E0002EB0D /* Managers & Helpers */ = { + isa = PBXGroup; + children = ( + ); + name = "Managers & Helpers"; + sourceTree = ""; + }; + 2D192EA81B1231570002EB0D /* Models */ = { + isa = PBXGroup; + children = ( + ); + name = Models; + sourceTree = ""; + }; + 2D192EA91B12316F0002EB0D /* Common */ = { + isa = PBXGroup; + children = ( + 2D192EAA1B1231E20002EB0D /* PhillyBikeSharePrefixHeader.pch */, + ); + name = Common; + sourceTree = ""; + }; + A6900DFFF5F389F079AE999C /* Frameworks */ = { + isa = PBXGroup; + children = ( + 4422DC82572FB8DD5A765C64 /* libPods-Philly Bike Share.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + DEB81FD0ADEA9B8FE8AC56FA /* Pods */ = { + isa = PBXGroup; + children = ( + 8AA9DBB8754381674E9BF027 /* Pods-Philly Bike Share.debug.xcconfig */, + B25ABDC59BBA56BBABCCB414 /* Pods-Philly Bike Share.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -126,9 +195,11 @@ isa = PBXNativeTarget; buildConfigurationList = 2D192E9E1B112B180002EB0D /* Build configuration list for PBXNativeTarget "Philly Bike Share" */; buildPhases = ( + 2EA0D3729700DB27C3A78FAD /* Check Pods Manifest.lock */, 2D192E771B112B170002EB0D /* Sources */, 2D192E781B112B170002EB0D /* Frameworks */, 2D192E791B112B170002EB0D /* Resources */, + 59C3EFE43E0B17339A54F3EE /* Copy Pods Resources */, ); buildRules = ( ); @@ -214,12 +285,44 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 2EA0D3729700DB27C3A78FAD /* 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; + }; + 59C3EFE43E0B17339A54F3EE /* 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-Philly Bike Share/Pods-Philly Bike Share-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 2D192E771B112B170002EB0D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2D192E871B112B180002EB0D /* ViewController.m in Sources */, 2D192E841B112B170002EB0D /* AppDelegate.m in Sources */, 2D192E811B112B170002EB0D /* main.m in Sources */, ); @@ -347,9 +450,13 @@ }; 2D192E9F1B112B180002EB0D /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8AA9DBB8754381674E9BF027 /* Pods-Philly Bike Share.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Philly Bike Share/Common/PhillyBikeSharePrefixHeader.pch"; INFOPLIST_FILE = "Philly Bike Share/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -357,9 +464,13 @@ }; 2D192EA01B112B180002EB0D /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = B25ABDC59BBA56BBABCCB414 /* Pods-Philly Bike Share.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Philly Bike Share/Common/PhillyBikeSharePrefixHeader.pch"; INFOPLIST_FILE = "Philly Bike Share/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -418,6 +529,7 @@ 2D192EA01B112B180002EB0D /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 2D192EA11B112B180002EB0D /* Build configuration list for PBXNativeTarget "Philly Bike ShareTests" */ = { isa = XCConfigurationList; @@ -426,6 +538,7 @@ 2D192EA31B112B180002EB0D /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/Philly Bike Share/AppDelegate.h b/Philly Bike Share/AppDelegate.h index d9d4b47..9f48b50 100644 --- a/Philly Bike Share/AppDelegate.h +++ b/Philly Bike Share/AppDelegate.h @@ -2,7 +2,7 @@ // AppDelegate.h // Philly Bike Share // -// Created by Morgis, Matthew (ELS-PHI) on 5/23/15. +// Created by Morgis, Matthew on 5/23/15. // Copyright (c) 2015 Rappid Development. All rights reserved. // diff --git a/Philly Bike Share/AppDelegate.m b/Philly Bike Share/AppDelegate.m index a41b6c6..5bdfcc0 100644 --- a/Philly Bike Share/AppDelegate.m +++ b/Philly Bike Share/AppDelegate.m @@ -2,7 +2,7 @@ // AppDelegate.m // Philly Bike Share // -// Created by Morgis, Matthew (ELS-PHI) on 5/23/15. +// Created by Morgis, Matthew on 5/23/15. // Copyright (c) 2015 Rappid Development. All rights reserved. // diff --git a/Philly Bike Share/Common/PhillyBikeSharePrefixHeader.pch b/Philly Bike Share/Common/PhillyBikeSharePrefixHeader.pch new file mode 100644 index 0000000..6361c4d --- /dev/null +++ b/Philly Bike Share/Common/PhillyBikeSharePrefixHeader.pch @@ -0,0 +1,95 @@ +// +// PhillyBikeSharePrefixHeader.pch +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#ifndef Philly_Bike_Share_PhillyBikeSharePrefixHeader_pch +#define Philly_Bike_Share_PhillyBikeSharePrefixHeader_pch + +#ifdef DEBUG +#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__]) +#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__] +#else +#define DLog(...) do { } while (0) +#define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__]) + +#ifndef NS_BLOCK_ASSERTIONS +#define NS_BLOCK_ASSERTIONS +#endif +#endif + +// printing out frame, bounds, and point +#define printFrame(uiview) DLog(@"%@", [NSString stringWithFormat:@"frame: origin_x: %f, origin_y: %f size_width: %f, size_height: %f", uiview.frame.origin.x, uiview.frame.origin.y, uiview.frame.size.width, uiview.frame.size.height]) + +#define printRect(cgrect) DLog(@"%@", [NSString stringWithFormat:@"rect: origin_x: %f, origin_y: %f size_width: %f, size_height: %f", cgrect.origin.x, cgrect.origin.y, cgrect.size.width, cgrect.size.height]) + +#define printBounds(uiview) DLog(@"%@", [NSString stringWithFormat:@"frame: origin_x: %f, origin_y: %f size_width: %f, size_height: %f", uiview.bounds.origin.x, uiview.bounds.origin.y, uiview.bounds.size.width, uiview.bounds.size.height]) +#define printPoint(cgpoint) DLog(@"%@", [NSString stringWithFormat:@"point: origin_x: %f, origin_y: %f", cgpoint.x, cgpoint.y]) + +#define alertFeatureNotYetImplemented() [[[UIAlertView alloc ] initWithTitle:@"Feature Not Implemented" message:@"This feature is not implemented yet." delegate:self cancelButtonTitle:@"Okay"otherButtonTitles:nil] show]; + +#define IS_IOS_ABOVE_7 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) + +// when termining the platform type, use these helpers +#define PlatformType UI_USER_INTERFACE_IDIOM() +#define iPad UIUserInterfaceIdiomPad +#define iPhone UIUserInterfaceIdiomPhone + +// Object defines +#define ApplicationDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate]) +#define UserDefaults [NSUserDefaults standardUserDefaults] +#define NotificationCenter [NSNotificationCenter defaultCenter] +#define SharedApplication [UIApplication sharedApplication] +#define Bundle [NSBundle mainBundle] +#define MainScreen [UIScreen mainScreen] +#define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES +#define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO +#define NetworkActivityIndicatorVisible(x) [UIApplication sharedApplication].networkActivityIndicatorVisible = x +#define NavBar self.navigationController.navigationBar +#define TabBar self.tabBarController.tabBar +#define NavBarHeight self.navigationController.navigationBar.bounds.size.height +#define TabBarHeight self.tabBarController.tabBar.bounds.size.height +#define ScreenWidth [[UIScreen mainScreen] bounds].size.width +#define ScreenHeight [[UIScreen mainScreen] bounds].size.height +#define TouchHeightDefault 44 +#define TouchHeightSmall 32 + +// View getter functions +#define ViewWidth(v) v.frame.size.width +#define ViewHeight(v) v.frame.size.height +#define ViewX(v) v.frame.origin.x +#define ViewY(v) v.frame.origin.y +#define SelfViewWidth self.view.bounds.size.width +#define SelfViewHeight self.view.bounds.size.height + +// Frame getter functions +#define RectX(f) f.origin.x +#define RectY(f) f.origin.y +#define RectWidth(f) f.size.width +#define RectHeight(f) f.size.height + +// Frame settings functions +#define RectSetWidth(f, w) CGRectMake(RectX(f), RectY(f), w, RectHeight(f)) +#define RectSetHeight(f, h) CGRectMake(RectX(f), RectY(f), RectWidth(f), h) +#define RectShiftXBy(f, deltaX) CGRectMake(RectX(f)+deltaX, RectY(f), RectWidth(f), RectHeight(f)) +#define RectShiftYBy(f, deltaY) CGRectMake(RectX(f), RectY(f)+deltaY, RectWidth(f), RectHeight(f)) +#define RectSetX(f, x) CGRectMake(x, RectY(f), RectWidth(f), RectHeight(f)) +#define RectSetY(f, y) CGRectMake(RectX(f), y, RectWidth(f), RectHeight(f)) +#define RectSetSize(f, w, h) CGRectMake(RectX(f), RectY(f), w, h) +#define RectSetOrigin(f, x, y) CGRectMake(x, y, RectWidth(f), RectHeight(f)) + +// Date functions +#define DATE_COMPONENTS NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit +#define TIME_COMPONENTS NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit +#define FlushPool(p) [p drain]; p = [[NSAutoreleasePool alloc] init] + +// Color functions +#define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] +#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a] +#define HEXCOLOR(c) [UIColor colorWithRed:((c>>16)&0xFF)/255.0 green:((c>>8)&0xFF)/255.0 blue:(c&0xFF)/255.0 alpha:1.0]; +#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] + +#endif \ No newline at end of file diff --git a/Philly Bike Share/ViewController.h b/Philly Bike Share/ViewController.h deleted file mode 100644 index c276a1d..0000000 --- a/Philly Bike Share/ViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// ViewController.h -// Philly Bike Share -// -// Created by Morgis, Matthew (ELS-PHI) on 5/23/15. -// Copyright (c) 2015 Rappid Development. All rights reserved. -// - -#import - -@interface ViewController : UIViewController - - -@end - diff --git a/Philly Bike Share/ViewController.m b/Philly Bike Share/ViewController.m deleted file mode 100644 index aee70df..0000000 --- a/Philly Bike Share/ViewController.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// ViewController.m -// Philly Bike Share -// -// Created by Morgis, Matthew (ELS-PHI) on 5/23/15. -// Copyright (c) 2015 Rappid Development. 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/Philly Bike Share/main.m b/Philly Bike Share/main.m index ff7ead7..f94810b 100644 --- a/Philly Bike Share/main.m +++ b/Philly Bike Share/main.m @@ -2,7 +2,7 @@ // main.m // Philly Bike Share // -// Created by Morgis, Matthew (ELS-PHI) on 5/23/15. +// Created by Morgis, Matthew on 5/23/15. // Copyright (c) 2015 Rappid Development. All rights reserved. // diff --git a/Philly Bike ShareTests/Philly_Bike_ShareTests.m b/Philly Bike ShareTests/Philly_Bike_ShareTests.m index 45cbc0e..8965b90 100644 --- a/Philly Bike ShareTests/Philly_Bike_ShareTests.m +++ b/Philly Bike ShareTests/Philly_Bike_ShareTests.m @@ -2,7 +2,7 @@ // Philly_Bike_ShareTests.m // Philly Bike ShareTests // -// Created by Morgis, Matthew (ELS-PHI) on 5/23/15. +// Created by Morgis, Matthew on 5/23/15. // Copyright (c) 2015 Rappid Development. All rights reserved. // diff --git a/Podfile b/Podfile index 5b77cb1..e1f9d60 100644 --- a/Podfile +++ b/Podfile @@ -2,6 +2,10 @@ # platform :ios, '6.0' target 'Philly Bike Share' do + +pod 'AFNetworking', '~> 2.0' +pod 'SWRevealViewController', '~> 2.3' +pod 'libextobjc', '0.4.1' end diff --git a/Podfile.lock b/Podfile.lock index 0966e2a..e4ac598 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1 +1,70 @@ +PODS: + - AFNetworking (2.5.4): + - AFNetworking/NSURLConnection (= 2.5.4) + - AFNetworking/NSURLSession (= 2.5.4) + - AFNetworking/Reachability (= 2.5.4) + - AFNetworking/Security (= 2.5.4) + - AFNetworking/Serialization (= 2.5.4) + - AFNetworking/UIKit (= 2.5.4) + - AFNetworking/NSURLConnection (2.5.4): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/NSURLSession (2.5.4): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (2.5.4) + - AFNetworking/Security (2.5.4) + - AFNetworking/Serialization (2.5.4) + - AFNetworking/UIKit (2.5.4): + - AFNetworking/NSURLConnection + - AFNetworking/NSURLSession + - libextobjc (0.4.1): + - libextobjc/EXTADT (= 0.4.1) + - libextobjc/EXTConcreteProtocol (= 0.4.1) + - libextobjc/EXTKeyPathCoding (= 0.4.1) + - libextobjc/EXTNil (= 0.4.1) + - libextobjc/EXTSafeCategory (= 0.4.1) + - libextobjc/EXTScope (= 0.4.1) + - libextobjc/EXTSelectorChecking (= 0.4.1) + - libextobjc/EXTSynthesize (= 0.4.1) + - libextobjc/NSInvocation+EXT (= 0.4.1) + - libextobjc/NSMethodSignature+EXT (= 0.4.1) + - libextobjc/RuntimeExtensions (= 0.4.1) + - libextobjc/UmbrellaHeader (= 0.4.1) + - libextobjc/EXTADT (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/EXTConcreteProtocol (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/EXTKeyPathCoding (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/EXTNil (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/EXTSafeCategory (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/EXTScope (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/EXTSelectorChecking (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/EXTSynthesize (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/NSInvocation+EXT (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/NSMethodSignature+EXT (0.4.1): + - libextobjc/RuntimeExtensions + - libextobjc/RuntimeExtensions (0.4.1) + - libextobjc/UmbrellaHeader (0.4.1) + - SWRevealViewController (2.3.0) + +DEPENDENCIES: + - AFNetworking (~> 2.0) + - libextobjc (= 0.4.1) + - SWRevealViewController (~> 2.3) + +SPEC CHECKSUMS: + AFNetworking: 05edc0ac4c4c8cf57bcf4b84be5b0744b6d8e71e + libextobjc: a650fc1bf489a3d3a9bc2e621efa3e1006fc5471 + SWRevealViewController: 6d3fd97f70112fd7cef9de14df4260eacce4c63a + COCOAPODS: 0.37.1 From f987431a00bb3576f9358038d54316f55380ed30 Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 12:46:19 -0400 Subject: [PATCH 02/11] Adding a networking protocol --- Philly Bike Share.xcodeproj/project.pbxproj | 10 ++++++++++ .../PhillyBikeShareNetworkCommandProtocol.h | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h diff --git a/Philly Bike Share.xcodeproj/project.pbxproj b/Philly Bike Share.xcodeproj/project.pbxproj index 10b765c..e68033d 100644 --- a/Philly Bike Share.xcodeproj/project.pbxproj +++ b/Philly Bike Share.xcodeproj/project.pbxproj @@ -39,6 +39,7 @@ 2D192E991B112B180002EB0D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 2D192E9A1B112B180002EB0D /* Philly_Bike_ShareTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Philly_Bike_ShareTests.m; sourceTree = ""; }; 2D192EAA1B1231E20002EB0D /* PhillyBikeSharePrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PhillyBikeSharePrefixHeader.pch; path = Common/PhillyBikeSharePrefixHeader.pch; sourceTree = ""; }; + 2D4688B51B12377400293A09 /* PhillyBikeShareNetworkCommandProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareNetworkCommandProtocol.h; path = "Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h"; sourceTree = ""; }; 4422DC82572FB8DD5A765C64 /* libPods-Philly Bike Share.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Philly Bike Share.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 8AA9DBB8754381674E9BF027 /* Pods-Philly Bike Share.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.debug.xcconfig"; sourceTree = ""; }; B25ABDC59BBA56BBABCCB414 /* Pods-Philly Bike Share.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.release.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.release.xcconfig"; sourceTree = ""; }; @@ -152,6 +153,7 @@ 2D192EA71B12314E0002EB0D /* Managers & Helpers */ = { isa = PBXGroup; children = ( + 2D4688B61B12377A00293A09 /* Networking */, ); name = "Managers & Helpers"; sourceTree = ""; @@ -171,6 +173,14 @@ name = Common; sourceTree = ""; }; + 2D4688B61B12377A00293A09 /* Networking */ = { + isa = PBXGroup; + children = ( + 2D4688B51B12377400293A09 /* PhillyBikeShareNetworkCommandProtocol.h */, + ); + name = Networking; + sourceTree = ""; + }; A6900DFFF5F389F079AE999C /* Frameworks */ = { isa = PBXGroup; children = ( diff --git a/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h new file mode 100644 index 0000000..8ac4cf3 --- /dev/null +++ b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h @@ -0,0 +1,15 @@ +// +// PhillyBikeShareNetworkCommandProtocol.h +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#import + +@protocol PhillyBikeShareNetworkCommandProtocol + +- (void)execute; + +@end \ No newline at end of file From 63c50ee05f362813343988ec961cbedb10dbc9ff Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 12:48:43 -0400 Subject: [PATCH 03/11] Adding AFNetworking block definitions --- .../Networking/PhillyBikeShareNetworkCommandProtocol.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h index 8ac4cf3..b481b62 100644 --- a/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h +++ b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h @@ -7,6 +7,13 @@ // #import +#import + +/** + * Block definitions + */ +typedef void (^AFHTTPRequestOperationSuccessBlock) (AFHTTPRequestOperation *operation, id responseObject); +typedef void (^AFHTTPRequestOperationFailureBlock) (AFHTTPRequestOperation *operation, NSError *error); @protocol PhillyBikeShareNetworkCommandProtocol From d071c5d4731ffbe9d779d6cf66525ead8ee04520 Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 12:57:56 -0400 Subject: [PATCH 04/11] Creating a basic networking command with AFNetworking --- Philly Bike Share.xcodeproj/project.pbxproj | 6 ++ .../PhillyBikeShareNetworkCommand.h | 26 +++++ .../PhillyBikeShareNetworkCommand.m | 102 ++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.h create mode 100644 Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m diff --git a/Philly Bike Share.xcodeproj/project.pbxproj b/Philly Bike Share.xcodeproj/project.pbxproj index e68033d..0e5fcd8 100644 --- a/Philly Bike Share.xcodeproj/project.pbxproj +++ b/Philly Bike Share.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 2D192E8C1B112B180002EB0D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2D192E8B1B112B180002EB0D /* Images.xcassets */; }; 2D192E8F1B112B180002EB0D /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2D192E8D1B112B180002EB0D /* LaunchScreen.xib */; }; 2D192E9B1B112B180002EB0D /* Philly_Bike_ShareTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D192E9A1B112B180002EB0D /* Philly_Bike_ShareTests.m */; }; + 2D4688B91B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688B81B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -40,6 +41,8 @@ 2D192E9A1B112B180002EB0D /* Philly_Bike_ShareTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Philly_Bike_ShareTests.m; sourceTree = ""; }; 2D192EAA1B1231E20002EB0D /* PhillyBikeSharePrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PhillyBikeSharePrefixHeader.pch; path = Common/PhillyBikeSharePrefixHeader.pch; sourceTree = ""; }; 2D4688B51B12377400293A09 /* PhillyBikeShareNetworkCommandProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareNetworkCommandProtocol.h; path = "Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h"; sourceTree = ""; }; + 2D4688B71B1237FD00293A09 /* PhillyBikeShareNetworkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareNetworkCommand.h; path = "Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.h"; sourceTree = ""; }; + 2D4688B81B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhillyBikeShareNetworkCommand.m; path = "Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m"; sourceTree = ""; }; 4422DC82572FB8DD5A765C64 /* libPods-Philly Bike Share.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Philly Bike Share.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 8AA9DBB8754381674E9BF027 /* Pods-Philly Bike Share.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.debug.xcconfig"; sourceTree = ""; }; B25ABDC59BBA56BBABCCB414 /* Pods-Philly Bike Share.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.release.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.release.xcconfig"; sourceTree = ""; }; @@ -177,6 +180,8 @@ isa = PBXGroup; children = ( 2D4688B51B12377400293A09 /* PhillyBikeShareNetworkCommandProtocol.h */, + 2D4688B71B1237FD00293A09 /* PhillyBikeShareNetworkCommand.h */, + 2D4688B81B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m */, ); name = Networking; sourceTree = ""; @@ -334,6 +339,7 @@ buildActionMask = 2147483647; files = ( 2D192E841B112B170002EB0D /* AppDelegate.m in Sources */, + 2D4688B91B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m in Sources */, 2D192E811B112B170002EB0D /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.h b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.h new file mode 100644 index 0000000..39095cd --- /dev/null +++ b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.h @@ -0,0 +1,26 @@ +// +// PhillyBikeShareNetworkCommand.h +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#import +#import "PhillyBikeShareNetworkCommandProtocol.h" + +@interface PhillyBikeShareNetworkCommand : NSObject + +- (instancetype)initWithUrl:(NSString *)url + andParameters:(NSDictionary *)parameters + andSuccessBlock:(AFHTTPRequestOperationSuccessBlock)success + andFailureBlock:(AFHTTPRequestOperationFailureBlock)failure; + +- (instancetype)initWithUrl:(NSString *)url + andMethod:(NSString *)method + andJsonRequest:(BOOL)jsonRequest + andParameters:(NSDictionary *)parameters + andSuccessBlock:(AFHTTPRequestOperationSuccessBlock)success + andFailureBlock:(AFHTTPRequestOperationFailureBlock)failure; + +@end diff --git a/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m new file mode 100644 index 0000000..2468d50 --- /dev/null +++ b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m @@ -0,0 +1,102 @@ +// +// PhillyBikeShareNetworkCommand.m +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#import "PhillyBikeShareNetworkCommand.h" +#import +#import + +@interface PhillyBikeShareNetworkCommand() + +@property (nonatomic, copy) AFHTTPRequestOperationSuccessBlock successHandler; +@property (nonatomic, copy) AFHTTPRequestOperationFailureBlock failureHandler; +@property (nonatomic, strong) NSString *url; +@property (nonatomic, strong) NSDictionary *parameters; +@property (nonatomic, strong) NSString *method; +@property (nonatomic, assign) BOOL jsonRequest; + +@end + +@implementation PhillyBikeShareNetworkCommand + +- (instancetype)initWithUrl:(NSString *)url + andParameters:(NSDictionary *)parameters + andSuccessBlock:(AFHTTPRequestOperationSuccessBlock)success + andFailureBlock:(AFHTTPRequestOperationFailureBlock)failure { + self = [super init]; + + if (!self) { + return nil; + } + + self.successHandler = [success copy]; + self.failureHandler = [failure copy]; + self.parameters = parameters; + self.url = url; + + if (!self.method) { + self.method = @"POST"; + } + + return self; +} + +- (instancetype)initWithUrl:(NSString *)url + andMethod:(NSString *)method + andJsonRequest:(BOOL)jsonRequest + andParameters:(NSDictionary *)parameters + andSuccessBlock:(AFHTTPRequestOperationSuccessBlock)success + andFailureBlock:(AFHTTPRequestOperationFailureBlock)failure { + + self.method = method; + self.jsonRequest = jsonRequest; + + return [self initWithUrl:url andParameters:parameters andSuccessBlock:success andFailureBlock:failure]; +} + +- (void)execute { + + // setup the manager + AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; + + if (self.jsonRequest) { + AFJSONRequestSerializer *requestSerializer = [AFJSONRequestSerializer serializer]; + [requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; + [manager setRequestSerializer:requestSerializer]; + } else { + AFJSONRequestSerializer *requestSerializer = [AFJSONRequestSerializer serializer]; + [requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; + [manager setRequestSerializer:requestSerializer]; + } + + SEL methodSelector = NSSelectorFromString([[NSString alloc] + initWithFormat:@"%@:%@", self.method,@"parameters:success:failure:"]); + + NSMethodSignature *signature = [manager methodSignatureForSelector:methodSelector]; + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature ]; + [invocation setSelector:methodSelector]; + [invocation setArgument:&_url atIndex:2]; + [invocation setArgument:&_parameters atIndex:3]; + + // define the success and failure blocks to pass to the manager + void (^successBlock)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) { + self.successHandler(operation, responseObject); + }; + + void (^failureBlock)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) { + self.failureHandler(operation, error); + }; + successBlock = [successBlock copy]; + failureBlock = [failureBlock copy]; + [invocation setArgument:&successBlock atIndex:4]; + [invocation setArgument:&failureBlock atIndex:5]; + + // Invoke the method + [invocation invokeWithTarget:manager]; +} + +@end \ No newline at end of file From 87691683b39a637cdc5cfa0620dbabf778d87383 Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 13:08:11 -0400 Subject: [PATCH 05/11] Adding a network command to get the bike share data --- Philly Bike Share.xcodeproj/project.pbxproj | 14 ++++++ .../PhillyBikeShareGetAllDataCommand.h | 17 +++++++ .../PhillyBikeShareGetAllDataCommand.m | 50 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 Philly Bike Share/Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.h create mode 100644 Philly Bike Share/Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.m diff --git a/Philly Bike Share.xcodeproj/project.pbxproj b/Philly Bike Share.xcodeproj/project.pbxproj index 0e5fcd8..87f2363 100644 --- a/Philly Bike Share.xcodeproj/project.pbxproj +++ b/Philly Bike Share.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 2D192E8F1B112B180002EB0D /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2D192E8D1B112B180002EB0D /* LaunchScreen.xib */; }; 2D192E9B1B112B180002EB0D /* Philly_Bike_ShareTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D192E9A1B112B180002EB0D /* Philly_Bike_ShareTests.m */; }; 2D4688B91B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688B81B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m */; }; + 2D4688BD1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688BC1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -43,6 +44,8 @@ 2D4688B51B12377400293A09 /* PhillyBikeShareNetworkCommandProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareNetworkCommandProtocol.h; path = "Managers & Helpers/Networking/PhillyBikeShareNetworkCommandProtocol.h"; sourceTree = ""; }; 2D4688B71B1237FD00293A09 /* PhillyBikeShareNetworkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareNetworkCommand.h; path = "Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.h"; sourceTree = ""; }; 2D4688B81B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhillyBikeShareNetworkCommand.m; path = "Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m"; sourceTree = ""; }; + 2D4688BB1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareGetAllDataCommand.h; path = "Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.h"; sourceTree = ""; }; + 2D4688BC1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhillyBikeShareGetAllDataCommand.m; path = "Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.m"; sourceTree = ""; }; 4422DC82572FB8DD5A765C64 /* libPods-Philly Bike Share.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Philly Bike Share.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 8AA9DBB8754381674E9BF027 /* Pods-Philly Bike Share.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.debug.xcconfig"; sourceTree = ""; }; B25ABDC59BBA56BBABCCB414 /* Pods-Philly Bike Share.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.release.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.release.xcconfig"; sourceTree = ""; }; @@ -179,6 +182,7 @@ 2D4688B61B12377A00293A09 /* Networking */ = { isa = PBXGroup; children = ( + 2D4688BA1B123A9B00293A09 /* Commands */, 2D4688B51B12377400293A09 /* PhillyBikeShareNetworkCommandProtocol.h */, 2D4688B71B1237FD00293A09 /* PhillyBikeShareNetworkCommand.h */, 2D4688B81B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m */, @@ -186,6 +190,15 @@ name = Networking; sourceTree = ""; }; + 2D4688BA1B123A9B00293A09 /* Commands */ = { + isa = PBXGroup; + children = ( + 2D4688BB1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.h */, + 2D4688BC1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m */, + ); + name = Commands; + sourceTree = ""; + }; A6900DFFF5F389F079AE999C /* Frameworks */ = { isa = PBXGroup; children = ( @@ -341,6 +354,7 @@ 2D192E841B112B170002EB0D /* AppDelegate.m in Sources */, 2D4688B91B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m in Sources */, 2D192E811B112B170002EB0D /* main.m in Sources */, + 2D4688BD1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Philly Bike Share/Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.h b/Philly Bike Share/Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.h new file mode 100644 index 0000000..430f5fb --- /dev/null +++ b/Philly Bike Share/Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.h @@ -0,0 +1,17 @@ +// +// PhillyBikeShareGetAllDataCommand.h +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#import +#import "PhillyBikeShareNetworkCommandProtocol.h" + +@interface PhillyBikeShareGetAllDataCommand : NSObject + +- (instancetype)initWithSuccessBlock:(AFHTTPRequestOperationSuccessBlock)success + andFailureBlock:(AFHTTPRequestOperationFailureBlock)failure; + +@end diff --git a/Philly Bike Share/Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.m b/Philly Bike Share/Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.m new file mode 100644 index 0000000..5fd690d --- /dev/null +++ b/Philly Bike Share/Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.m @@ -0,0 +1,50 @@ +// +// PhillyBikeShareGetAllDataCommand.m +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#import "PhillyBikeShareGetAllDataCommand.h" +#import "PhillyBikeShareNetworkCommand.h" + +@interface PhillyBikeShareGetAllDataCommand() + +@property (nonatomic, copy) AFHTTPRequestOperationSuccessBlock successHandler; +@property (nonatomic, copy) AFHTTPRequestOperationFailureBlock failureHandler; + +@end + +@implementation PhillyBikeShareGetAllDataCommand + +- (instancetype)initWithSuccessBlock:(AFHTTPRequestOperationSuccessBlock)success andFailureBlock:(AFHTTPRequestOperationFailureBlock)failure { + + self = [super init]; + + if (!self) { + return nil; + } + + self.successHandler = [success copy]; + self.failureHandler = [failure copy]; + + return self; +} + +- (void)execute { + + NSString *url = @"https://api.phila.gov/bike-share-stations/v1"; + NSString *method = @"GET"; + + PhillyBikeShareNetworkCommand *command = [[PhillyBikeShareNetworkCommand alloc] initWithUrl:url andMethod:method andJsonRequest:YES andParameters:nil andSuccessBlock:^(AFHTTPRequestOperation *operation, id responseObject) { + + self.successHandler(operation, responseObject); + } andFailureBlock:^(AFHTTPRequestOperation *operation, NSError *error) { + self.failureHandler(operation, error); + }]; + + [command execute]; +} + +@end From 51c9254d245d07f3aaf3a5dfb286fba763029949 Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 13:39:01 -0400 Subject: [PATCH 06/11] Setting the response serializer to accept text/plain context to work with the bike share API --- .../Networking/PhillyBikeShareNetworkCommand.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m index 2468d50..e139735 100644 --- a/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m +++ b/Philly Bike Share/Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m @@ -67,6 +67,9 @@ - (void)execute { AFJSONRequestSerializer *requestSerializer = [AFJSONRequestSerializer serializer]; [requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [manager setRequestSerializer:requestSerializer]; + manager.responseSerializer = [AFJSONResponseSerializer serializer]; + //Needed because the API doesn't technically return JSON data. + manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"]; } else { AFJSONRequestSerializer *requestSerializer = [AFJSONRequestSerializer serializer]; [requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; @@ -99,4 +102,4 @@ - (void)execute { [invocation invokeWithTarget:manager]; } -@end \ No newline at end of file +@end From 5b96c03715549d1dfe31001015b3c81d0eea66df Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 13:47:11 -0400 Subject: [PATCH 07/11] Creating a BikeShareLocation object --- Philly Bike Share.xcodeproj/project.pbxproj | 6 +++++ .../Models/PhillyBikeShareLocation.h | 24 +++++++++++++++++++ .../Models/PhillyBikeShareLocation.m | 13 ++++++++++ 3 files changed, 43 insertions(+) create mode 100644 Philly Bike Share/Models/PhillyBikeShareLocation.h create mode 100644 Philly Bike Share/Models/PhillyBikeShareLocation.m diff --git a/Philly Bike Share.xcodeproj/project.pbxproj b/Philly Bike Share.xcodeproj/project.pbxproj index 87f2363..d9a9487 100644 --- a/Philly Bike Share.xcodeproj/project.pbxproj +++ b/Philly Bike Share.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 2D192E9B1B112B180002EB0D /* Philly_Bike_ShareTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D192E9A1B112B180002EB0D /* Philly_Bike_ShareTests.m */; }; 2D4688B91B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688B81B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m */; }; 2D4688BD1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688BC1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m */; }; + 2D4688C01B1244FC00293A09 /* PhillyBikeShareLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688BF1B1244FC00293A09 /* PhillyBikeShareLocation.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -46,6 +47,8 @@ 2D4688B81B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhillyBikeShareNetworkCommand.m; path = "Managers & Helpers/Networking/PhillyBikeShareNetworkCommand.m"; sourceTree = ""; }; 2D4688BB1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareGetAllDataCommand.h; path = "Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.h"; sourceTree = ""; }; 2D4688BC1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhillyBikeShareGetAllDataCommand.m; path = "Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.m"; sourceTree = ""; }; + 2D4688BE1B1244FC00293A09 /* PhillyBikeShareLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareLocation.h; path = Models/PhillyBikeShareLocation.h; sourceTree = ""; }; + 2D4688BF1B1244FC00293A09 /* PhillyBikeShareLocation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhillyBikeShareLocation.m; path = Models/PhillyBikeShareLocation.m; sourceTree = ""; }; 4422DC82572FB8DD5A765C64 /* libPods-Philly Bike Share.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Philly Bike Share.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 8AA9DBB8754381674E9BF027 /* Pods-Philly Bike Share.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.debug.xcconfig"; sourceTree = ""; }; B25ABDC59BBA56BBABCCB414 /* Pods-Philly Bike Share.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.release.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.release.xcconfig"; sourceTree = ""; }; @@ -167,6 +170,8 @@ 2D192EA81B1231570002EB0D /* Models */ = { isa = PBXGroup; children = ( + 2D4688BE1B1244FC00293A09 /* PhillyBikeShareLocation.h */, + 2D4688BF1B1244FC00293A09 /* PhillyBikeShareLocation.m */, ); name = Models; sourceTree = ""; @@ -352,6 +357,7 @@ buildActionMask = 2147483647; files = ( 2D192E841B112B170002EB0D /* AppDelegate.m in Sources */, + 2D4688C01B1244FC00293A09 /* PhillyBikeShareLocation.m in Sources */, 2D4688B91B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m in Sources */, 2D192E811B112B170002EB0D /* main.m in Sources */, 2D4688BD1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m in Sources */, diff --git a/Philly Bike Share/Models/PhillyBikeShareLocation.h b/Philly Bike Share/Models/PhillyBikeShareLocation.h new file mode 100644 index 0000000..ddfbec0 --- /dev/null +++ b/Philly Bike Share/Models/PhillyBikeShareLocation.h @@ -0,0 +1,24 @@ +// +// PhillyBikeShareLocation.h +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#import + +@interface PhillyBikeShareLocation : NSObject + +@property (strong, nonatomic) NSNumber *kioskId; +@property (strong, nonatomic) NSString *name; +@property (nonatomic) float latitude; +@property (nonatomic) float longitude; +@property (strong, nonatomic) NSString *addressStreet; +@property (strong, nonatomic) NSString *addressCity; +@property (strong, nonatomic) NSString *addressZipCode; +@property (strong, nonatomic) NSNumber *bikesAvailable; +@property (strong, nonatomic) NSNumber *docksAvailable; +@property (strong, nonatomic) NSNumber *totalDocs; + +@end \ No newline at end of file diff --git a/Philly Bike Share/Models/PhillyBikeShareLocation.m b/Philly Bike Share/Models/PhillyBikeShareLocation.m new file mode 100644 index 0000000..fbe9b0a --- /dev/null +++ b/Philly Bike Share/Models/PhillyBikeShareLocation.m @@ -0,0 +1,13 @@ +// +// PhillyBikeShareLocation.m +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#import "PhillyBikeShareLocation.h" + +@implementation PhillyBikeShareLocation + +@end From c0a35555d4564f60782530b8e9d38ff5109818a0 Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 14:04:26 -0400 Subject: [PATCH 08/11] Creating the LocationManager singleton that will handle fetching and storing the data and feeding it to the views as needed. --- Philly Bike Share.xcodeproj/project.pbxproj | 6 ++ .../PhillyBikeShareLocationManager.h | 21 ++++++ .../PhillyBikeShareLocationManager.m | 65 +++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.h create mode 100644 Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m diff --git a/Philly Bike Share.xcodeproj/project.pbxproj b/Philly Bike Share.xcodeproj/project.pbxproj index d9a9487..8e5ae7b 100644 --- a/Philly Bike Share.xcodeproj/project.pbxproj +++ b/Philly Bike Share.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 2D4688B91B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688B81B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m */; }; 2D4688BD1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688BC1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m */; }; 2D4688C01B1244FC00293A09 /* PhillyBikeShareLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688BF1B1244FC00293A09 /* PhillyBikeShareLocation.m */; }; + 2D4688C31B12464500293A09 /* PhillyBikeShareLocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4688C21B12464500293A09 /* PhillyBikeShareLocationManager.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -49,6 +50,8 @@ 2D4688BC1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhillyBikeShareGetAllDataCommand.m; path = "Managers & Helpers/Networking/Commands/PhillyBikeShareGetAllDataCommand.m"; sourceTree = ""; }; 2D4688BE1B1244FC00293A09 /* PhillyBikeShareLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareLocation.h; path = Models/PhillyBikeShareLocation.h; sourceTree = ""; }; 2D4688BF1B1244FC00293A09 /* PhillyBikeShareLocation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhillyBikeShareLocation.m; path = Models/PhillyBikeShareLocation.m; sourceTree = ""; }; + 2D4688C11B12464500293A09 /* PhillyBikeShareLocationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhillyBikeShareLocationManager.h; path = "Managers & Helpers/PhillyBikeShareLocationManager.h"; sourceTree = ""; }; + 2D4688C21B12464500293A09 /* PhillyBikeShareLocationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhillyBikeShareLocationManager.m; path = "Managers & Helpers/PhillyBikeShareLocationManager.m"; sourceTree = ""; }; 4422DC82572FB8DD5A765C64 /* libPods-Philly Bike Share.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Philly Bike Share.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 8AA9DBB8754381674E9BF027 /* Pods-Philly Bike Share.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.debug.xcconfig"; sourceTree = ""; }; B25ABDC59BBA56BBABCCB414 /* Pods-Philly Bike Share.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Philly Bike Share.release.xcconfig"; path = "Pods/Target Support Files/Pods-Philly Bike Share/Pods-Philly Bike Share.release.xcconfig"; sourceTree = ""; }; @@ -163,6 +166,8 @@ isa = PBXGroup; children = ( 2D4688B61B12377A00293A09 /* Networking */, + 2D4688C11B12464500293A09 /* PhillyBikeShareLocationManager.h */, + 2D4688C21B12464500293A09 /* PhillyBikeShareLocationManager.m */, ); name = "Managers & Helpers"; sourceTree = ""; @@ -360,6 +365,7 @@ 2D4688C01B1244FC00293A09 /* PhillyBikeShareLocation.m in Sources */, 2D4688B91B1237FD00293A09 /* PhillyBikeShareNetworkCommand.m in Sources */, 2D192E811B112B170002EB0D /* main.m in Sources */, + 2D4688C31B12464500293A09 /* PhillyBikeShareLocationManager.m in Sources */, 2D4688BD1B123ADB00293A09 /* PhillyBikeShareGetAllDataCommand.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.h b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.h new file mode 100644 index 0000000..5dfcc33 --- /dev/null +++ b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.h @@ -0,0 +1,21 @@ +// +// PhillyBikeShareLocationManager.h +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#import + +typedef void (^PhillyBikeShareSuccessBlock) (NSArray *locations); +typedef void (^PhillyBikeShareFailureBlock) (NSError *error); + +@interface PhillyBikeShareLocationManager : NSObject + ++ (instancetype)sharedInstance; + +- (void)fetchAllLocationsWithSuccessBlock:(PhillyBikeShareSuccessBlock)successBlock + andFailureBlock:(PhillyBikeShareFailureBlock)failureBlock; + +@end diff --git a/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m new file mode 100644 index 0000000..cb976f3 --- /dev/null +++ b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m @@ -0,0 +1,65 @@ +// +// PhillyBikeShareLocationManager.m +// Philly Bike Share +// +// Created by Morgis, Matthew on 5/24/15. +// Copyright (c) 2015 Rappid Development. All rights reserved. +// + +#import "PhillyBikeShareLocationManager.h" +#import "PhillyBikeShareGetAllDataCommand.h" + +@interface PhillyBikeShareLocationManager() + +@property (strong, nonatomic) NSArray *phillyBikeShareLocations; +@property (atomic) BOOL isRefreshing; + +@end + +@implementation PhillyBikeShareLocationManager + +//Return singleton instance ++ (instancetype) sharedInstance { + static dispatch_once_t once; + static id sharedInstance; + dispatch_once(&once, ^{ + sharedInstance = [[self alloc] initPrivate]; + }); + return sharedInstance; +} + + +//If a programmer calls this method, scold him with an exception (use sharedInstance initializer only) +- (instancetype)init +{ + @throw [NSException exceptionWithName:@"Singleton" reason:@"Use +[PhillyBikeShareLocationManager sharedInstance]" userInfo:nil]; + return nil; +} + +//Return privately initialized instance +- (instancetype)initPrivate +{ + self = [super init]; + if(self) { + self.phillyBikeShareLocations = [[NSArray alloc]init]; + } + return self; +} + +- (void)fetchAllLocationsWithSuccessBlock:(PhillyBikeShareSuccessBlock)successBlock + andFailureBlock:(PhillyBikeShareFailureBlock)failureBlock { + + PhillyBikeShareGetAllDataCommand *getAllDataCommand = [[PhillyBikeShareGetAllDataCommand alloc]initWithSuccessBlock:^(AFHTTPRequestOperation *operation, id responseObject) { + DLog(@"Successssss"); + DLog(@"%@", responseObject); + //TODO: Handle JSON parsing here; + successBlock(responseObject); + } andFailureBlock:^(AFHTTPRequestOperation *operation, NSError *error) { + DLog(@"Failure"); + DLog(@"%@", error.localizedDescription); + failureBlock(error); + }]; + [getAllDataCommand execute]; +} + +@end \ No newline at end of file From 09208de9ccb732d53e7fc55063aadef7e2f567ac Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 14:41:04 -0400 Subject: [PATCH 09/11] Adding a constructor to the PhillyBikeShareLocation model and adjusting property types --- .../Models/PhillyBikeShareLocation.h | 21 +++++++++--- .../Models/PhillyBikeShareLocation.m | 33 ++++++++++++++++++- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/Philly Bike Share/Models/PhillyBikeShareLocation.h b/Philly Bike Share/Models/PhillyBikeShareLocation.h index ddfbec0..435a3e7 100644 --- a/Philly Bike Share/Models/PhillyBikeShareLocation.h +++ b/Philly Bike Share/Models/PhillyBikeShareLocation.h @@ -10,15 +10,28 @@ @interface PhillyBikeShareLocation : NSObject -@property (strong, nonatomic) NSNumber *kioskId; +@property (nonatomic) NSInteger kioskId; @property (strong, nonatomic) NSString *name; @property (nonatomic) float latitude; @property (nonatomic) float longitude; @property (strong, nonatomic) NSString *addressStreet; @property (strong, nonatomic) NSString *addressCity; +@property (strong , nonatomic) NSString *addressState; @property (strong, nonatomic) NSString *addressZipCode; -@property (strong, nonatomic) NSNumber *bikesAvailable; -@property (strong, nonatomic) NSNumber *docksAvailable; -@property (strong, nonatomic) NSNumber *totalDocs; +@property (nonatomic) NSInteger bikesAvailable; +@property (nonatomic) NSInteger docksAvailable; +@property (nonatomic) NSInteger totalDocs; + +- (instancetype) initWithKioskId:(NSInteger)kioskId + andName:(NSString *)name + andLatitude:(float)latitude + andLongtiude:(float)longitude + andAddressStreet:(NSString *)addressStreet + andAddressCity:(NSString *)addressCity + andAddressState:(NSString *)addressState + andAddresZipCode:(NSString *)addressZipCode + andBikesAvailable:(NSInteger)bikesAvailable + andDocksAvailable:(NSInteger)docksAvailable + andTotalDocks:(NSInteger)totalDocs; @end \ No newline at end of file diff --git a/Philly Bike Share/Models/PhillyBikeShareLocation.m b/Philly Bike Share/Models/PhillyBikeShareLocation.m index fbe9b0a..1c801cd 100644 --- a/Philly Bike Share/Models/PhillyBikeShareLocation.m +++ b/Philly Bike Share/Models/PhillyBikeShareLocation.m @@ -10,4 +10,35 @@ @implementation PhillyBikeShareLocation -@end +- (instancetype) initWithKioskId:(NSInteger)kioskId + andName:(NSString *)name + andLatitude:(float)latitude + andLongtiude:(float)longitude + andAddressStreet:(NSString *)addressStreet + andAddressCity:(NSString *)addressCity + andAddressState:(NSString *)addressState + andAddresZipCode:(NSString *)addressZipCode + andBikesAvailable:(NSInteger)bikesAvailable + andDocksAvailable:(NSInteger)docksAvailable + andTotalDocks:(NSInteger)totalDocs { + + self = [super init]; + + if (self) { + self.kioskId = kioskId; + self.name = name; + self.latitude = latitude; + self.longitude = longitude; + self.addressStreet = addressStreet; + self.addressCity = addressCity; + self.addressState = addressState; + self.addressZipCode = addressZipCode; + self.bikesAvailable = bikesAvailable; + self.docksAvailable = docksAvailable; + self.totalDocs = totalDocs; + } + + return self; +} + +@end \ No newline at end of file From 4e1a8c8afad0d064d2a6ce697a75cf8219e58bea Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 14:41:30 -0400 Subject: [PATCH 10/11] Creating my PhillyBikeShareLocation objects within the location manager --- .../PhillyBikeShareLocationManager.m | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m index cb976f3..62a429e 100644 --- a/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m +++ b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m @@ -7,6 +7,7 @@ // #import "PhillyBikeShareLocationManager.h" +#import "PhillyBikeShareLocation.h" #import "PhillyBikeShareGetAllDataCommand.h" @interface PhillyBikeShareLocationManager() @@ -50,10 +51,41 @@ - (void)fetchAllLocationsWithSuccessBlock:(PhillyBikeShareSuccessBlock)successBl andFailureBlock:(PhillyBikeShareFailureBlock)failureBlock { PhillyBikeShareGetAllDataCommand *getAllDataCommand = [[PhillyBikeShareGetAllDataCommand alloc]initWithSuccessBlock:^(AFHTTPRequestOperation *operation, id responseObject) { - DLog(@"Successssss"); - DLog(@"%@", responseObject); - //TODO: Handle JSON parsing here; - successBlock(responseObject); + + NSArray *locations = [responseObject objectForKey:@"features"]; + NSMutableArray *mutablePhillyBikeShareLocations = [NSMutableArray array]; + + for (id location in locations) { + id geometry = [location objectForKey:@"geometry"]; + NSArray *coordinates = [geometry objectForKey:@"coordinates"]; + id properties = [location objectForKey:@"properties"]; + + NSInteger kioskId = [[properties objectForKey:@"kioskId"]intValue]; + NSString *name = [properties objectForKey:@"name"]; + float latitude = [[coordinates objectAtIndex:0]floatValue]; + float longitude = [[coordinates objectAtIndex:1]floatValue]; + NSString *addressStreet = [properties objectForKey:@"addressStreet"]; + NSString *addressState = [properties objectForKey:@"addressState"]; + NSString *addressCity = [properties objectForKey:@"addressCity"]; + NSString *addressZipCode = [properties objectForKey:@"addressZipCode"]; + NSInteger bikesAvailable = [[properties objectForKey:@"bikesAvailable"]intValue]; + NSInteger docksAvailable = [[properties objectForKey:@"docksAvailable"]intValue]; + NSInteger totalDocks = [[properties objectForKey:@"totalDocks"]intValue]; + + PhillyBikeShareLocation *phillyBikeShareLocation = [[PhillyBikeShareLocation alloc]initWithKioskId:kioskId + andName:name + andLatitude:latitude + andLongtiude:longitude andAddressStreet:addressStreet andAddressCity:addressCity + andAddressState:addressState + andAddresZipCode:addressZipCode + andBikesAvailable:bikesAvailable + andDocksAvailable:docksAvailable + andTotalDocks:totalDocks]; + + [mutablePhillyBikeShareLocations addObject:phillyBikeShareLocation]; + } + self.phillyBikeShareLocations = mutablePhillyBikeShareLocations; + successBlock(self.phillyBikeShareLocations); } andFailureBlock:^(AFHTTPRequestOperation *operation, NSError *error) { DLog(@"Failure"); DLog(@"%@", error.localizedDescription); From 723c20257a5421a84f08f3eb39cc4bfd809991f2 Mon Sep 17 00:00:00 2001 From: Matt Morgis Date: Sun, 24 May 2015 14:55:46 -0400 Subject: [PATCH 11/11] Adding a method to return a single PhillyShareLocaiton object by Id --- .../PhillyBikeShareLocationManager.h | 2 ++ .../PhillyBikeShareLocationManager.m | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.h b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.h index 5dfcc33..adda0d9 100644 --- a/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.h +++ b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.h @@ -18,4 +18,6 @@ typedef void (^PhillyBikeShareFailureBlock) (NSError *error); - (void)fetchAllLocationsWithSuccessBlock:(PhillyBikeShareSuccessBlock)successBlock andFailureBlock:(PhillyBikeShareFailureBlock)failureBlock; +- (id)getPhillyBikeShareLocationById:(NSInteger)phillyBikeShareLocationId; + @end diff --git a/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m index 62a429e..aeed945 100644 --- a/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m +++ b/Philly Bike Share/Managers & Helpers/PhillyBikeShareLocationManager.m @@ -94,4 +94,15 @@ - (void)fetchAllLocationsWithSuccessBlock:(PhillyBikeShareSuccessBlock)successBl [getAllDataCommand execute]; } +- (id)getPhillyBikeShareLocationById:(NSInteger)phillyBikeShareLocationId { + + for (PhillyBikeShareLocation *location in self.phillyBikeShareLocations) { + if (location.kioskId == phillyBikeShareLocationId) { + return location; + } + } + + return nil; +} + @end \ No newline at end of file