diff --git a/Classes/CycleAtlantaAppDelegate.h b/Classes/CycleAtlantaAppDelegate.h index 761e1dc..3b1a13e 100644 --- a/Classes/CycleAtlantaAppDelegate.h +++ b/Classes/CycleAtlantaAppDelegate.h @@ -39,6 +39,7 @@ #import #import #import "ProgressView.h" +#import "OBARegionHelper.h" @class TripManager; @class NoteManager; @@ -68,10 +69,22 @@ @property (nonatomic, assign) BOOL isRecording; @property (nonatomic, strong) CLLocationManager *locationManager; @property (nonatomic, strong) ProgressView *storeLoadingView; +@property (nonatomic, strong) OBARegionHelper *regionHelper; +@property (nonatomic, strong) id regionObserver; + +- (void) regionSelected; +- (void) showRegionListViewController; + +/** + * Abstracts OBAModelDAO setters / getters and calls the appropriate analytics methods. + */ +- (void)writeSetRegionAutomatically:(BOOL) setRegionAutomatically; +- (BOOL)readSetRegionAutomatically; - (NSString *)applicationDocumentsDirectory; - (void)initUniqueIDHash; +- (void) showRegionSelectMessage; @end diff --git a/Classes/CycleAtlantaAppDelegate.m b/Classes/CycleAtlantaAppDelegate.m index 7e1b39b..59ecc17 100644 --- a/Classes/CycleAtlantaAppDelegate.m +++ b/Classes/CycleAtlantaAppDelegate.m @@ -54,6 +54,8 @@ #import "NoteManager.h" #import #import "ProgressView.h" +#import "OBAApplication.h" + #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) @@ -63,6 +65,8 @@ @implementation CycleAtlantaAppDelegate + + @synthesize window; @synthesize tabBarController; @synthesize uniqueIDHash; @@ -86,7 +90,36 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application [window makeKeyAndVisible]; [self performSelectorInBackground:@selector(loadPersistentStore) withObject:nil]; */ +} + +- (id)init { + self = [super init]; + if (self) { + [[OBAApplication sharedApplication] start]; + self.regionHelper = [[OBARegionHelper alloc] init]; + [self.regionHelper updateNearestRegion]; + } + return self; +} + +- (void) showRegionSelectMessage { + UIAlertController* alert = [UIAlertController + alertControllerWithTitle:@"Alert" + message:@"Region couldn't be found. Please select a region from settings." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction* defaultAction = [UIAlertAction + actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainWindow" bundle:nil]; + PersonalInfoViewController *myVC = (PersonalInfoViewController *)[storyboard instantiateViewControllerWithIdentifier:@"personalInfo"]; + [myVC setHideViews]; + [self.window.rootViewController presentViewController:myVC animated:YES completion:nil]; + + }]; + + [alert addAction:defaultAction]; + [self.window.rootViewController presentViewController:alert animated:YES completion:nil]; } -(void)loadPersistentStore @@ -395,6 +428,35 @@ - (NSString *) applicationDocumentsDirectory { return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; } +- (void)writeSetRegionAutomatically:(BOOL)setRegionAutomatically { + [[OBAApplication sharedApplication].modelDao writeSetRegionAutomatically:setRegionAutomatically]; + +} + +- (BOOL)readSetRegionAutomatically { + BOOL readSetRegionAuto = [OBAApplication sharedApplication].modelDao.readSetRegionAutomatically; + + return readSetRegionAuto; +} + +- (void)regionSelected { +// [_regionNavigationController removeFromParentViewController]; +// _regionNavigationController = nil; +// _regionListViewController = nil; +// +// [[OBAApplication sharedApplication] refreshSettings]; +// +// self.window.rootViewController = self.tabBarController; +// [_window makeKeyAndVisible]; +} + +- (void)showRegionListViewController { +// _regionListViewController = [[OBARegionListViewController alloc] init]; +// _regionNavigationController = [[UINavigationController alloc] initWithRootViewController:_regionListViewController]; +// +// self.window.rootViewController = _regionNavigationController; +} + #pragma mark - #pragma mark Memory management @@ -402,8 +464,6 @@ - (NSString *) applicationDocumentsDirectory { - (void)dealloc { self.isRecording = nil; - - } diff --git a/Classes/JsonUrlFetcherImpl.h b/Classes/JsonUrlFetcherImpl.h new file mode 100644 index 0000000..9f29c71 --- /dev/null +++ b/Classes/JsonUrlFetcherImpl.h @@ -0,0 +1,18 @@ +// +// JsonUrlFetcherImpl.h +// OneBusAwaySDK +// +// Created by Aaron Brethorst on 12/16/15. +// Copyright © 2015 One Bus Away. All rights reserved. +// + +#import +#import "OBADataSource.h" + +@interface JsonUrlFetcherImpl : NSObject +@property (nonatomic, copy) OBADataSourceCompletion completionBlock; +@property (nonatomic, copy) OBADataSourceProgress progressBlock; + +- (instancetype)initWithCompletionBlock:(OBADataSourceCompletion)completion progressBlock:(OBADataSourceProgress)progress; +- (void)loadRequest:(NSURLRequest *)request; +@end \ No newline at end of file diff --git a/Classes/JsonUrlFetcherImpl.m b/Classes/JsonUrlFetcherImpl.m new file mode 100644 index 0000000..dcacb88 --- /dev/null +++ b/Classes/JsonUrlFetcherImpl.m @@ -0,0 +1,61 @@ +// +// JsonUrlFetcherImpl.m +// OneBusAwaySDK +// +// Created by Aaron Brethorst on 12/16/15. +// Copyright © 2015 One Bus Away. All rights reserved. +// + +#import "JsonUrlFetcherImpl.h" + +@interface JsonUrlFetcherImpl () +@property(nonatomic,strong) NSURLSessionDataTask *task; +@end + +@implementation JsonUrlFetcherImpl + +- (instancetype)initWithCompletionBlock:(OBADataSourceCompletion)completion progressBlock:(OBADataSourceProgress)progress { + self = [super init]; + + if (self) { + _completionBlock = completion; + _progressBlock = progress; + } + + return self; +} + +- (void)loadRequest:(NSURLRequest *)request { + + self.task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + id responseObject = nil; + + NSURL *url = [NSURL URLWithString:@"https://script.google.com/macros/s/AKfycbxpN47XZQGAoh-N5wQtBETp51tznG3JnOrWsAVNy0xGJOkD8ibS/exec"]; + NSMutableURLRequest *request2 = [NSMutableURLRequest requestWithURL:url]; + NSURLResponse * response2; + data = [NSURLConnection sendSynchronousRequest:request2 returningResponse:&response error:&error]; + + if (data.length) { + NSError *jsonError = nil; + responseObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonError]; + + if (!responseObject && jsonError) { + error = jsonError; + } + } + + dispatch_async(dispatch_get_main_queue(), ^{ + self.completionBlock(responseObject, ((NSHTTPURLResponse*)response).statusCode, error); + }); + }]; + + + + [self.task resume]; +} + +- (void)cancel { + [self.task cancel]; +} + +@end diff --git a/Classes/NSArray+OBAAdditions.h b/Classes/NSArray+OBAAdditions.h new file mode 100644 index 0000000..c67c7ff --- /dev/null +++ b/Classes/NSArray+OBAAdditions.h @@ -0,0 +1,15 @@ +// +// NSArray+OBAAdditions.h +// org.onebusaway.iphone +// +// Created by Aaron Brethorst on 2/16/16. +// Copyright © 2016 OneBusAway. All rights reserved. +// + +#import + +@interface NSArray (OBAAdditions) + +- (NSArray*)oba_pickFirst:(NSUInteger)count; +- (NSArray*)oba_subarrayFromIndex:(NSUInteger)index; +@end diff --git a/Classes/NSArray+OBAAdditions.m b/Classes/NSArray+OBAAdditions.m new file mode 100644 index 0000000..26c0f62 --- /dev/null +++ b/Classes/NSArray+OBAAdditions.m @@ -0,0 +1,36 @@ +// +// NSArray+OBAAdditions.m +// org.onebusaway.iphone +// +// Created by Aaron Brethorst on 2/16/16. +// Copyright © 2016 OneBusAway. All rights reserved. +// + +#import "NSArray+OBAAdditions.h" + +@implementation NSArray (OBAAdditions) + +- (NSArray*)oba_pickFirst:(NSUInteger)count +{ + if (self.count == 0) + { + return self; + } + + if (self.count < count) + { + count = self.count; + } + + return [self subarrayWithRange:NSMakeRange(0, count)]; +} + +- (NSArray*)oba_subarrayFromIndex:(NSUInteger)index { + if (index >= self.count) { + return @[]; + } + + return [self subarrayWithRange:NSMakeRange(index, self.count - index)]; +} + +@end diff --git a/Classes/OBAAgencyV2.h b/Classes/OBAAgencyV2.h new file mode 100755 index 0000000..2a428a8 --- /dev/null +++ b/Classes/OBAAgencyV2.h @@ -0,0 +1,13 @@ +#import "OBAHasReferencesV2.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBAAgencyV2 : OBAHasReferencesV2 + +@property (nonatomic, strong) NSString *agencyId; +@property (nonatomic, strong) NSString *url; +@property (nonatomic, strong) NSString *name; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAAgencyV2.m b/Classes/OBAAgencyV2.m new file mode 100755 index 0000000..2ed490c --- /dev/null +++ b/Classes/OBAAgencyV2.m @@ -0,0 +1,36 @@ +#import "OBAAgencyV2.h" + + +@implementation OBAAgencyV2 + +#pragma mark - NSCoding + +- (instancetype)initWithCoder:(NSCoder *)aDecoder { + self = [super init]; + + if (self) { + _agencyId = [aDecoder decodeObjectForKey:@"agencyId"]; + _url = [aDecoder decodeObjectForKey:@"url"]; + _name = [aDecoder decodeObjectForKey:@"name"]; + } + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:_agencyId forKey:@"agencyId"]; + [aCoder encodeObject:_url forKey:@"url"]; + [aCoder encodeObject:_name forKey:@"name"]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + OBAAgencyV2 *agency = [[self.class alloc] init]; + agency->_agencyId = [_agencyId copyWithZone:zone]; + agency->_url = [_url copyWithZone:zone]; + agency->_name = [_name copyWithZone:zone]; + + return agency; +} + +@end diff --git a/Classes/OBAApplication.h b/Classes/OBAApplication.h new file mode 100644 index 0000000..4fa814f --- /dev/null +++ b/Classes/OBAApplication.h @@ -0,0 +1,78 @@ +// +// OBAApplication.h +// OneBusAwaySDK +// +// Created by Dima Belov on 4/25/15. +// +// Copyright (c) 2015 Dima Belov +// Copyright Sebastian Kießling +// Copyright Ben Bodenmiller +// Copyright Aaron Brethorst +// Copyright Caitlin Bonnar +// Copyright Jon Bell +// Copyright Andrew Sullivan +// Copyright Aengus McMillin +// + +#import +#import "OBAModelDAO.h" +#import "OBAModelService.h" +#import "OBALocationManager.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + * This notification is posted in refernce to a specific refreshSettings event, specifically when modelDao does not have an assigned region. + */ +extern NSString *const kOBAApplicationSettingsRegionRefreshNotification; + +@interface OBAApplication : NSObject + +@property (nonatomic, strong, readonly) OBAReferencesV2 *references; +@property (nonatomic, strong, readonly) OBAModelDAO *modelDao; +@property (nonatomic, strong, readonly) OBAModelService *modelService; +@property (nonatomic, strong, readonly) OBALocationManager *locationManager; + +@property(nonatomic,strong,nullable) OBARegionV2 *region; +@property(nonatomic, retain) NSArray *allRegions; + +/** + * This method should always be used to get an instance of this class. This class should not be initialized directly. + * + * @return singleton. Thread safe. + */ ++ (instancetype)sharedApplication; + +/** + * Call this when the object has been fully configured. + */ +- (void)start; + +/** + * Refreshes the internal in-memory state by reading the latest persisted data. + */ +- (void)refreshSettings; + +/** + * Returns YES if the user has enabled darker system colors or reduced transparency. + */ +- (BOOL)useHighContrastUI; + +/** + * e.g. "2.4.2" + */ +- (NSString*)formattedAppVersion; + +/** + * e.g. "20151218.18" + */ +- (NSString*)formattedAppBuild; + +/** + * e.g. "2.4.2 (20151218.18)" + */ +- (NSString*)fullAppVersionString; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAApplication.m b/Classes/OBAApplication.m new file mode 100644 index 0000000..5dcb0df --- /dev/null +++ b/Classes/OBAApplication.m @@ -0,0 +1,133 @@ +// +// OBAApplication.m +// OneBusAwaySDK +// +// Created by Dima Belov on 4/25/15. +// Copyright (c) 2015 One Bus Away. All rights reserved. +// + +#import "OBAApplication.h" +#import "OBAModelDAOUserPreferencesImpl.h" + +static NSString *const kOBAHiddenPreferenceUserId = @"OBAApplicationUserId"; +static NSString *const kOBADefaultRegionApiServerName = @"script.google.com/macros/s/AKfycbxpN47XZQGAoh-N5wQtBETp51tznG3JnOrWsAVNy0xGJOkD8ibS/exec"; + +NSString *const kOBAApplicationSettingsRegionRefreshNotification = @"kOBAApplicationSettingsRegionRefreshNotification"; + +@interface OBAApplication () +@property (nonatomic, strong, readwrite) OBAReferencesV2 *references; +@property (nonatomic, strong, readwrite) OBAModelDAO *modelDao; +@property (nonatomic, strong, readwrite) OBAModelService *modelService; +@property (nonatomic, strong, readwrite) OBALocationManager *locationManager; + +@end + +@implementation OBAApplication + +@synthesize allRegions; + ++ (instancetype)sharedApplication { + static OBAApplication *oba; + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + oba = [[OBAApplication alloc] init]; + }); + + return oba; +} + +- (void)start { + self.references = [[OBAReferencesV2 alloc] init]; + id persistence = [[OBAModelDAOUserPreferencesImpl alloc] init]; + self.modelDao = [[OBAModelDAO alloc] initWithModelPersistenceLayer:persistence]; + self.locationManager = [[OBALocationManager alloc] initWithModelDao:self.modelDao]; + + self.modelService = [[OBAModelService alloc] init]; + self.modelService.references = self.references; + self.modelService.modelDao = self.modelDao; + + OBAModelFactory *modelFactory = [[OBAModelFactory alloc] initWithReferences:self.references]; + self.modelService.modelFactory = modelFactory; + + self.modelService.locationManager = self.locationManager; + + [self refreshSettings]; +} + +#pragma mark - OS Settings + +- (BOOL)useHighContrastUI { + return UIAccessibilityDarkerSystemColorsEnabled() || UIAccessibilityIsReduceTransparencyEnabled(); +} + +#pragma mark - Bundle Settings + +- (NSString*)formattedAppVersion { + return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; +} + +- (NSString*)formattedAppBuild { + return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]; +} + +- (NSString*)fullAppVersionString { + return [NSString stringWithFormat:@"%@ (%@)", [self formattedAppVersion], [self formattedAppBuild]]; +} + +#pragma mark - Crazy App State Refresh Thing + +- (void)refreshSettings { + NSString *apiServerName = [self.modelDao normalizedAPIServerURL]; + + if (!apiServerName) { + [[NSNotificationCenter defaultCenter] postNotificationName:kOBAApplicationSettingsRegionRefreshNotification object:nil]; + } + + NSDictionary *obaArgs = @{ @"key": @"org.onebusaway.iphone", + @"app_uid": [self userIdFromDefaults:[NSUserDefaults standardUserDefaults]], + @"app_ver": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"], + @"version": @"2"}; + + OBADataSourceConfig *obaDataSourceConfig = [[OBADataSourceConfig alloc] initWithURL:[NSURL URLWithString:apiServerName] args:obaArgs]; + OBAJsonDataSource *obaJsonDataSource = [[OBAJsonDataSource alloc] initWithConfig:obaDataSourceConfig]; + _modelService.obaJsonDataSource = obaJsonDataSource; + + OBADataSourceConfig *googleMapsDataSourceConfig = [[OBADataSourceConfig alloc] initWithURL:[NSURL URLWithString:@"https://maps.googleapis.com"] args:@{@"sensor": @"true"}]; + OBAJsonDataSource *googleMapsJsonDataSource = [[OBAJsonDataSource alloc] initWithConfig:googleMapsDataSourceConfig]; + _modelService.googleMapsJsonDataSource = googleMapsJsonDataSource; + + NSString *regionApiServerName = [[NSUserDefaults standardUserDefaults] objectForKey:@"oba_region_api_server"]; + + if (regionApiServerName.length == 0) { + regionApiServerName = kOBADefaultRegionApiServerName; + } + + regionApiServerName = [NSString stringWithFormat:@"https://%@", regionApiServerName]; + + OBADataSourceConfig *obaRegionDataSourceConfig = [[OBADataSourceConfig alloc] initWithURL:[NSURL URLWithString:regionApiServerName] args:nil]; + OBAJsonDataSource *obaRegionJsonDataSource = [[OBAJsonDataSource alloc] initWithConfig:obaRegionDataSourceConfig]; + _modelService.obaRegionJsonDataSource = obaRegionJsonDataSource; +} + +- (NSString *)userIdFromDefaults:(NSUserDefaults *)userDefaults { + NSString *userId = [userDefaults stringForKey:kOBAHiddenPreferenceUserId]; + + if (!userId) { + CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault); + + if (theUUID) { + userId = CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, theUUID)); + CFRelease(theUUID); + [userDefaults setObject:userId forKey:kOBAHiddenPreferenceUserId]; + [userDefaults synchronize]; + } + else { + userId = @"anonymous"; + } + } + + return userId; +} + +@end diff --git a/Classes/OBACallMethodJsonDigesterRule.h b/Classes/OBACallMethodJsonDigesterRule.h new file mode 100755 index 0000000..9335579 --- /dev/null +++ b/Classes/OBACallMethodJsonDigesterRule.h @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAJsonDigester.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBACallMethodJsonDigesterRule : NSObject { + SEL _selector; +} + +- (id) initWithSelector:(SEL)selector; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBACallMethodJsonDigesterRule.m b/Classes/OBACallMethodJsonDigesterRule.m new file mode 100755 index 0000000..7d700ec --- /dev/null +++ b/Classes/OBACallMethodJsonDigesterRule.m @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBACallMethodJsonDigesterRule.h" + +@implementation OBACallMethodJsonDigesterRule + +- (id)initWithSelector:(SEL)selector { + if (self = [super init]) { + _selector = selector; + } + return self; +} + +- (void) begin:(id)context name:(NSString*)name value:(id)value { + + NSObject * top = [context peek:0]; + + if (!top) { + return; + } + +// note: this is gross. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + [top performSelector:_selector withObject:value]; +#pragma clang diagnostic pop +} + +@end diff --git a/Classes/OBACommon.h b/Classes/OBACommon.h new file mode 100755 index 0000000..86d9081 --- /dev/null +++ b/Classes/OBACommon.h @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@import Foundation; +@import UIKit; +#import "OBALogger.h" + +NS_ASSUME_NONNULL_BEGIN + +extern NSString * const OBAErrorDomain; +extern const NSInteger kOBAErrorDuplicateEntity; +extern const NSInteger kOBAErrorMissingFieldInData; + +@interface NSString (OBAConvenienceMethods) +- (NSComparisonResult) compareUsingNumberSearch:(NSString*)aString; +@end + +@interface UIView (OBAConvenienceMethods) +- (void) setOrigin:(CGPoint)point; +@end + + +@interface OBACommon : NSObject + ++ (NSString*) getTimeAsString; ++ (NSString*) getBestNameFirst:(NSString*)firstName second:(NSString*)secondName; ++ (NSString*) getBestNameFirst:(NSString*)firstName second:(NSString*)secondName third:(NSString*)thirdName; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBACommon.m b/Classes/OBACommon.m new file mode 100755 index 0000000..f28e5c9 --- /dev/null +++ b/Classes/OBACommon.m @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBACommon.h" +#import "OBADateHelpers.h" + +NSString * const OBAErrorDomain = @"org.onebusaway.iphone2"; + +const NSInteger kOBAErrorDuplicateEntity = 1000; +const NSInteger kOBAErrorMissingFieldInData = 1001; + +@implementation NSString (OBAConvenienceMethods) + +- (NSComparisonResult) compareUsingNumberSearch:(NSString*)aString { + return [self compare:aString options:NSNumericSearch]; +} + +@end + +@implementation UIView (OBAConvenienceMethods) + +- (void) setOrigin:(CGPoint)point { + CGRect rect = self.bounds; + rect.origin = point; + [self setFrame:rect]; +} + +@end + + +@implementation OBACommon + ++ (NSString*) getTimeAsString { + return [OBADateHelpers formatShortTimeNoDate:[NSDate date]]; +} + ++ (NSString*) getBestNameFirst:(NSString*)firstName second:(NSString*)secondName { + if( firstName && [firstName length] > 0 ) + return firstName; + return secondName; +} + ++ (NSString*) getBestNameFirst:(NSString*)firstName second:(NSString*)secondName third:(NSString*)thirdName { + if( firstName && [firstName length] > 0 ) + return firstName; + if( secondName && [secondName length] > 0 ) + return secondName; + return thirdName; +} +@end + + diff --git a/Classes/OBACommonV1.h b/Classes/OBACommonV1.h new file mode 100644 index 0000000..928278a --- /dev/null +++ b/Classes/OBACommonV1.h @@ -0,0 +1,15 @@ +@import Foundation; + +typedef NS_ENUM(NSInteger, OBANavigationTargetType) { + OBANavigationTargetTypeRoot=0, + OBANavigationTargetTypeSearch, + OBANavigationTargetTypeSearchResults, + OBANavigationTargetTypeBookmarks, + OBANavigationTargetTypeRecentStops, + OBANavigationTargetTypeStop, + OBANavigationTargetTypeEditBookmark, + OBANavigationTargetTypeEditStopPreferences, + OBANavigationTargetTypeSettings, + OBANavigationTargetTypeContactUs, + OBANavigationTargetTypeAgencies, +}; \ No newline at end of file diff --git a/Classes/OBACoordinateBounds.h b/Classes/OBACoordinateBounds.h new file mode 100755 index 0000000..00c300c --- /dev/null +++ b/Classes/OBACoordinateBounds.h @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import Foundation; +@import MapKit; + +NS_ASSUME_NONNULL_BEGIN + +@interface OBACoordinateBounds : NSObject + +- (id) initWithBounds:(OBACoordinateBounds*)bounds; +- (id) initWithRegion:(MKCoordinateRegion)region; ++ (id) bounds; + +@property (nonatomic,readonly) BOOL empty; +@property (nonatomic) double minLatitude; +@property (nonatomic) double maxLatitude; +@property (nonatomic) double minLongitude; +@property (nonatomic) double maxLongitude; +@property (nonatomic,readonly) MKCoordinateRegion region; +@property (nonatomic,readonly) CLLocationCoordinate2D center; +@property (nonatomic,readonly) MKCoordinateSpan span; + +- (void) addLat:(double)lat lon:(double)lon; +- (void) addCoordinate:(CLLocationCoordinate2D)coordinate; +- (void) addLocation:(CLLocation*)location; +- (void) addLocations:(NSArray*)locations; +- (void) addRegion:(MKCoordinateRegion)region; + +- (void) expandByRatio:(double)ratio; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBACoordinateBounds.m b/Classes/OBACoordinateBounds.m new file mode 100755 index 0000000..bafa3f3 --- /dev/null +++ b/Classes/OBACoordinateBounds.m @@ -0,0 +1,151 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBACoordinateBounds.h" + + +@implementation OBACoordinateBounds + +- (id) init { + self = [super init]; + if( self ) { + _empty = YES; + } + return self; +} + +- (id) initWithBounds:(OBACoordinateBounds*)bounds { + self = [super init]; + if (self) { + _empty = bounds.empty; + _minLatitude = bounds.minLatitude; + _maxLatitude = bounds.maxLatitude; + _minLongitude = bounds.minLongitude; + _maxLongitude = bounds.maxLongitude; + } + return self; +} + +- (id) initWithRegion:(MKCoordinateRegion)region { + self = [super init]; + if( self ) { + _empty = YES; + [self addRegion:region]; + } + return self; +} + +- (id) initWithCoder:(NSCoder*)coder { + self = [super init]; + if( self ) { + _empty = [coder decodeBoolForKey:@"empty"]; + _minLatitude = [coder decodeDoubleForKey:@"minLatitude"]; + _maxLatitude = [coder decodeDoubleForKey:@"maxLatitude"]; + _minLongitude = [coder decodeDoubleForKey:@"minLongitude"]; + _maxLongitude = [coder decodeDoubleForKey:@"maxLongitude"]; + } + return self; +} + ++ (id) bounds { + return [[OBACoordinateBounds alloc] init]; +} + +- (MKCoordinateRegion) region { + return MKCoordinateRegionMake([self center],[self span]); +} + +- (CLLocationCoordinate2D) center { + CLLocationCoordinate2D center = {0.0,0.0}; + if( ! _empty ) { + center.latitude = (_minLatitude + _maxLatitude)/2; + center.longitude = (_minLongitude + _maxLongitude)/2; + } + return center; +} + +- (MKCoordinateSpan) span { + MKCoordinateSpan span = MKCoordinateSpanMake(0.0,0.0); + if( ! _empty ) { + span.latitudeDelta = _maxLatitude - _minLatitude; + span.longitudeDelta = _maxLongitude - _minLongitude; + } + return span; +} + +- (void) addRegion:(MKCoordinateRegion)region { + CLLocationCoordinate2D c = region.center; + MKCoordinateSpan span = region.span; + [self addLat:c.latitude-span.latitudeDelta/2 lon:c.longitude-span.longitudeDelta/2]; + [self addLat:c.latitude+span.latitudeDelta/2 lon:c.longitude+span.longitudeDelta/2]; +} + +- (void) addLocations:(NSArray*)locations { + for( CLLocation * location in locations) + [self addLocation:location]; +} + +- (void) addLocation:(CLLocation*)location { + [self addCoordinate:location.coordinate]; +} + +- (void) addCoordinate:(CLLocationCoordinate2D)coordinate { + [self addLat:coordinate.latitude lon:coordinate.longitude]; +} + +- (void) addLat:(double)lat lon:(double)lon { + if( _empty ) { + _empty = NO; + + _minLatitude = lat; + _maxLatitude = lat; + _minLongitude = lon; + _maxLongitude = lon; + } + else { + _minLatitude = MIN(_minLatitude,lat); + _maxLatitude = MAX(_maxLatitude,lat); + _minLongitude = MIN(_minLongitude,lon); + _maxLongitude = MAX(_maxLongitude,lon); + } +} + +- (void) expandByRatio:(double)ratio { + if( _empty ) + return; + double latDelta = (_maxLatitude - _minLatitude) * ratio / 2; + double lonDelta = (_maxLongitude - _minLongitude) * ratio / 2; + _maxLatitude += latDelta; + _minLatitude -= latDelta; + _maxLongitude += lonDelta; + _minLongitude -= lonDelta; +} + +- (NSString*) description { + return [NSString stringWithFormat:@"%f %f %f %f",_minLatitude,_minLongitude,_maxLatitude,_maxLongitude]; +} + +#pragma mark NSCoder Methods + +- (void) encodeWithCoder: (NSCoder *)coder { + [coder encodeBool:_empty forKey:@"empty"]; + [coder encodeDouble:_minLatitude forKey:@"minLatitude"]; + [coder encodeDouble:_maxLatitude forKey:@"maxLatitude"]; + [coder encodeDouble:_minLongitude forKey:@"minLongitude"]; + [coder encodeDouble:_maxLongitude forKey:@"maxLongitude"]; +} + +@end diff --git a/Classes/OBACreateObjectJsonDigesterRule.h b/Classes/OBACreateObjectJsonDigesterRule.h new file mode 100755 index 0000000..d7d9c0f --- /dev/null +++ b/Classes/OBACreateObjectJsonDigesterRule.h @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAJsonDigester.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBACreateObjectJsonDigesterRule : NSObject { + Class _objectClass; +} + +- (id) initWithObjectClass:(Class)objectClass; + +@property (nonatomic) BOOL onlyIfNotNull; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBACreateObjectJsonDigesterRule.m b/Classes/OBACreateObjectJsonDigesterRule.m new file mode 100755 index 0000000..e5dc89c --- /dev/null +++ b/Classes/OBACreateObjectJsonDigesterRule.m @@ -0,0 +1,58 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBACreateObjectJsonDigesterRule.h" +#import "OBALogger.h" + +@interface OBACreateObjectJsonDigesterRule () +- (BOOL)shouldDigestValue:(id)value; +@end + +@implementation OBACreateObjectJsonDigesterRule + +- (id) initWithObjectClass:(Class)objectClass { + if( self = [super init] ) { + _objectClass = objectClass; + _onlyIfNotNull = YES; + } + return self; +} + +#pragma mark OBAJsonDigesterRule Methods + +- (void) begin:(id)context name:(NSString*)name value:(id)value { + if([self shouldDigestValue:value]) { + id obj = [[_objectClass alloc] init]; + [context pushValue:obj]; + if( context.verbose ) + OBALogDebug(@"Creating object: class=%@",[_objectClass description]); + } +} + +- (void) end:(id)context name:(NSString*)name value:(id)value { + if([self shouldDigestValue:value]) { + [context popValue]; + } +} + +- (BOOL)shouldDigestValue:(id)value { + BOOL valueIsNull = (!value || CFEqual((__bridge CFTypeRef)(value), kCFNull)); + return !(_onlyIfNotNull && valueIsNull); +} + + + +@end diff --git a/Classes/OBADataSource.h b/Classes/OBADataSource.h new file mode 100755 index 0000000..f7e5c49 --- /dev/null +++ b/Classes/OBADataSource.h @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@import UIKit; + +NS_ASSUME_NONNULL_BEGIN + +typedef void (^OBADataSourceCompletion)(_Nullable id responseData, NSUInteger responseCode, NSError * error); +typedef void (^OBADataSourceProgress)(CGFloat progress); + +@protocol OBADataSourceConnection +- (void) cancel; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBADataSourceConfig.h b/Classes/OBADataSourceConfig.h new file mode 100755 index 0000000..8ac05c4 --- /dev/null +++ b/Classes/OBADataSourceConfig.h @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import Foundation; + +NS_ASSUME_NONNULL_BEGIN + +@interface OBADataSourceConfig : NSObject +- (instancetype)initWithURL:(NSURL*)baseURL args:(nullable NSDictionary*)args; +- (NSURL*)constructURL:(NSString*)path withArgs:(nullable NSDictionary*)args; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBADataSourceConfig.m b/Classes/OBADataSourceConfig.m new file mode 100755 index 0000000..352b471 --- /dev/null +++ b/Classes/OBADataSourceConfig.m @@ -0,0 +1,77 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBADataSourceConfig.h" +#import "OBAMacros.h" + +@interface OBADataSourceConfig () +@property(nonatomic,copy) NSURL* baseURL; +@property(nonatomic,copy) NSDictionary* defaultArgs; +@end + +@implementation OBADataSourceConfig + +- (instancetype)initWithURL:(NSURL*)baseURL args:(nullable NSDictionary*)args { + self = [super init]; + + if (self) { + _baseURL = [baseURL copy]; + _defaultArgs = [args copy]; + } + return self; +} + +- (NSURL*)constructURL:(NSString*)path withArgs:(NSDictionary*)args { + NSMutableString *constructedURL = [NSMutableString string]; + + if (self.baseURL) { + [constructedURL appendString:self.baseURL.absoluteString]; + } + + [constructedURL appendString:path]; + + NSMutableArray *queryItems = [[NSMutableArray alloc] init]; + + for (NSString* key in self.defaultArgs) { + NSURLQueryItem *item = [[NSURLQueryItem alloc] initWithName:key value:[self.defaultArgs[key] description]]; + [queryItems addObject:item]; + } + + for (NSString* key in args) { + NSURLQueryItem *item = [[NSURLQueryItem alloc] initWithName:key value:[args[key] description]]; + [queryItems addObject:item]; + } + + NSURL *URLWithPath = [self.baseURL URLByAppendingPathComponent:path]; + + OBAGuard(URLWithPath) else { + return nil; + } + + NSURLComponents *components = [[NSURLComponents alloc] initWithURL:URLWithPath resolvingAgainstBaseURL:NO]; + + if (queryItems.count > 0) { + components.queryItems = queryItems; + } + + NSURL *fullURL = components.URL; + + NSLog(@"url=%@",fullURL); + + return fullURL; +} + +@end diff --git a/Classes/OBADateHelpers.h b/Classes/OBADateHelpers.h new file mode 100644 index 0000000..e90bb4a --- /dev/null +++ b/Classes/OBADateHelpers.h @@ -0,0 +1,17 @@ +// +// OBADateHelpers.h +// org.onebusaway.iphone +// +// Created by Aaron Brethorst on 3/11/15. +// Copyright (c) 2015 OneBusAway. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface OBADateHelpers : NSObject ++ (NSString*)formatShortTimeNoDate:(NSDate*)date; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBADateHelpers.m b/Classes/OBADateHelpers.m new file mode 100644 index 0000000..5f1e112 --- /dev/null +++ b/Classes/OBADateHelpers.m @@ -0,0 +1,26 @@ +// +// OBADateHelpers.m +// org.onebusaway.iphone +// +// Created by Aaron Brethorst on 3/11/15. +// Copyright (c) 2015 OneBusAway. All rights reserved. +// + +#import "OBADateHelpers.h" + +@implementation OBADateHelpers + ++ (NSString*)formatShortTimeNoDate:(NSDate*)date +{ + static NSDateFormatter *formatter = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + formatter = [[NSDateFormatter alloc] init]; + formatter.timeStyle = NSDateFormatterShortStyle; + formatter.dateStyle = NSDateFormatterNoStyle; + }); + + return [formatter stringFromDate:date]; +} + +@end diff --git a/Classes/OBAHasReferencesV2.h b/Classes/OBAHasReferencesV2.h new file mode 100755 index 0000000..c88494c --- /dev/null +++ b/Classes/OBAHasReferencesV2.h @@ -0,0 +1,12 @@ +#import "OBAReferencesV2.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBAHasReferencesV2 : NSObject +@property(nonatomic,strong) OBAReferencesV2 *references; + +- (instancetype)initWithReferences:(OBAReferencesV2*)refs; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAHasReferencesV2.m b/Classes/OBAHasReferencesV2.m new file mode 100755 index 0000000..2903334 --- /dev/null +++ b/Classes/OBAHasReferencesV2.m @@ -0,0 +1,17 @@ +#import "OBAHasReferencesV2.h" + +@implementation OBAHasReferencesV2 + +- (instancetype)init { + return [self initWithReferences:[[OBAReferencesV2 alloc] init]]; +} + +- (instancetype)initWithReferences:(OBAReferencesV2*)refs { + self = [super init]; + if (self) { + _references = refs; + } + return self; +} + +@end diff --git a/Classes/OBAImageHelpers.h b/Classes/OBAImageHelpers.h new file mode 100644 index 0000000..fc3630e --- /dev/null +++ b/Classes/OBAImageHelpers.h @@ -0,0 +1,34 @@ +// +// OBAImageHelpers.h +// org.onebusaway.iphone +// +// Created by Aaron Brethorst on 2/28/16. +// Copyright © 2016 OneBusAway. All rights reserved. +// + +#import + +@interface OBAImageHelpers : NSObject + +/** + Overlays the image parameter with the specified color using the multiply blend mode. + + @param image The image object that will have a color overlay applied to it. + @param color The color that will be overlayed on top of the image. + + @return A new image object with the specified color applied on top of it. + */ ++ (UIImage*)colorizeImage:(UIImage *)image withColor:(UIColor *)color; + +/** + Draws one image on top of another at the specified location. + + @param image The image that is drawn on top of the baseImage. + @param baseImage The image upon which new content is drawn. + @param point The point in the base image that the image is drawn at. + + @return The new composite image. + */ ++ (UIImage*)draw:(UIImage*)image onto:(UIImage*)baseImage atPoint:(CGPoint)point; + +@end \ No newline at end of file diff --git a/Classes/OBAJsonDataSource.h b/Classes/OBAJsonDataSource.h new file mode 100755 index 0000000..1f47822 --- /dev/null +++ b/Classes/OBAJsonDataSource.h @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@import Foundation; +@import UIKit; + +#import "OBADataSource.h" +#import "OBADataSourceConfig.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBAJsonDataSource : NSObject + +- (id)initWithConfig:(OBADataSourceConfig*)config; + +- (id)requestWithPath:(NSString*)path + withArgs:(nullable NSDictionary*)args + completionBlock:(OBADataSourceCompletion) completion + progressBlock:(nullable OBADataSourceProgress) progress; + +- (void)cancelOpenConnections; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAJsonDataSource.m b/Classes/OBAJsonDataSource.m new file mode 100755 index 0000000..c982c38 --- /dev/null +++ b/Classes/OBAJsonDataSource.m @@ -0,0 +1,62 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAJsonDataSource.h" +#import "OBALogger.h" +#import "JsonUrlFetcherImpl.h" + +@interface OBAJsonDataSource () +@property(nonatomic,strong) OBADataSourceConfig *config; +@property(nonatomic,strong) NSHashTable *openConnections; +@end + +@implementation OBAJsonDataSource + +- (id)initWithConfig:(OBADataSourceConfig *)config { + if (self = [super init]) { + _config = config; + _openConnections = [NSHashTable weakObjectsHashTable]; + } + + return self; +} + +- (void)dealloc { + [self cancelOpenConnections]; +} + +- (id)requestWithPath:(NSString *)path withArgs:(NSDictionary *)args completionBlock:(OBADataSourceCompletion)completion progressBlock:(OBADataSourceProgress)progress { + + NSURL *feedURL = [self.config constructURL:path withArgs:args]; + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:feedURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20]; +// [request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; + + JsonUrlFetcherImpl *fetcher = [[JsonUrlFetcherImpl alloc] initWithCompletionBlock:completion progressBlock:progress]; + [self.openConnections addObject:fetcher]; + [fetcher loadRequest:request]; + + return fetcher; +} + +- (void)cancelOpenConnections { + for (JsonUrlFetcherImpl *fetcher in self.openConnections) { + [fetcher cancel]; + } + + [self.openConnections removeAllObjects]; +} + +@end diff --git a/Classes/OBAJsonDigester.h b/Classes/OBAJsonDigester.h new file mode 100755 index 0000000..046693b --- /dev/null +++ b/Classes/OBAJsonDigester.h @@ -0,0 +1,73 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol OBAJsonDigesterContext + +-(void) pushValue:(id)value; +-(id) peek:(NSUInteger)index; +-(void) popValue; + +- (id) getParameterForKey:(id)key; +- (void) setParamter:(id)value forKey:(id)key; + +@property (nonatomic,strong) NSError * error; +@property (nonatomic,readonly) BOOL verbose; + +@end + +@protocol OBAJsonDigesterRule + +@optional + +- (void) begin:(id)context name:(NSString*)name value:(id)value; +- (void) end:(id)context name:(NSString*)name value:(id)value; + +@end + + +typedef NS_ENUM(NSInteger, OBAJsonDigesterRuleTarget) { + OBAJsonDigesterRuleTargetBegin, + OBAJsonDigesterRuleTargetEnd +}; + + +@interface OBAJsonDigester : NSObject { + NSMutableDictionary * _rulesByPrefix; +} + +- (BOOL) parse:(id)jsonRoot withRoot:(id)rootObject error:(NSError**)error; +- (BOOL) parse:(id)jsonRoot withRoot:(id)rootObject parameters:(NSDictionary*)parameters error:(NSError**)error; + +- (void) addRule:(id)rule forPrefix:(NSString*)prefix; +- (void) addObjectCreateRule:(Class)objectClass forPrefix:(NSString*)prefix; +- (void) addCallMethodRule:(SEL)selector forPrefix:(NSString*)prefix; +- (void) addSetPropertyRule:(NSString*)property forPrefix:(NSString*)prefix; +- (void) addSetOptionalPropertyRule:(NSString*)property forPrefix:(NSString*)prefix; +- (void) addSetPropertyIfNeededRule:(NSString*)property forPrefix:(NSString*)prefix; +- (void) addSetNext:(SEL)selector forPrefix:(NSString*)prefix; +- (void) addTarget:(NSObject*)target selector:(SEL)selector forRuleTarget:(OBAJsonDigesterRuleTarget)ruleTarget prefix:(NSString*)prefix; + +-(NSString*) extendPrefix:(NSString*)prefix withValue:(NSString*)value; + +@property (nonatomic) BOOL verbose; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAJsonDigester.m b/Classes/OBAJsonDigester.m new file mode 100755 index 0000000..8bcb56b --- /dev/null +++ b/Classes/OBAJsonDigester.m @@ -0,0 +1,260 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAJsonDigester.h" +#import "OBACreateObjectJsonDigesterRule.h" +#import "OBACallMethodJsonDigesterRule.h" +#import "OBASetPropertyJsonDigesterRule.h" +#import "OBASetNextOBAJsonDigesterRule.h" +#import "OBASelectorJsonDigesterRule.h" +#import "OBALogger.h" + + +#pragma mark OBAJsonDigesterContextImpl Interface + +@interface OBAJsonDigesterContextImpl : NSObject +{ + NSMutableArray * _stack; + NSMutableDictionary * _parameters; + NSError * _error; + BOOL _verbose; +} + +- (id) initWithVerbose:(BOOL)verbose; + +@end + + +#pragma mark OBAJsonDigester Private Interface + +@interface OBAJsonDigester (Private) + +-(void) recursivelyParse:(OBAJsonDigesterContextImpl*)context jsonValue:(id)value prefix:(NSString*)prefix name:(NSString*)name; + +@end + + +#pragma mark OBAJsonDigester Implementation + +@implementation OBAJsonDigester + +- (id) init { + self = [super init]; + if( self ) { + _rulesByPrefix = [[NSMutableDictionary alloc] init]; + _verbose = NO; + } + return self; +} + + +- (void) addRule:(id)rule forPrefix:(NSString*)prefix { + NSMutableArray * rules = _rulesByPrefix[prefix]; + if( ! rules ) { + rules = [NSMutableArray array]; + _rulesByPrefix[prefix] = rules; + } + [rules addObject:rule]; +} + +- (void) addObjectCreateRule:(Class)objectClass forPrefix:(NSString*)prefix { + OBACreateObjectJsonDigesterRule * rule = [[OBACreateObjectJsonDigesterRule alloc] initWithObjectClass:objectClass]; + [self addRule:rule forPrefix:prefix]; +} + +- (void) addCallMethodRule:(SEL)selector forPrefix:(NSString*)prefix { + OBACallMethodJsonDigesterRule * rule = [[OBACallMethodJsonDigesterRule alloc] initWithSelector:selector]; + [self addRule:rule forPrefix:prefix]; +} + +- (void) addSetPropertyRule:(NSString*)property forPrefix:(NSString*)prefix { + OBASetPropertyJsonDigesterRule * rule = [[OBASetPropertyJsonDigesterRule alloc] initWithPropertyName:property]; + [self addRule:rule forPrefix:prefix]; +} + +- (void) addSetOptionalPropertyRule:(NSString*)property forPrefix:(NSString*)prefix { + OBASetPropertyJsonDigesterRule * rule = [[OBASetPropertyJsonDigesterRule alloc] initWithPropertyName:property]; + rule.optional = YES; + [self addRule:rule forPrefix:prefix]; +} + + +- (void) addSetPropertyIfNeededRule:(NSString*)property forPrefix:(NSString*)prefix { + OBASetPropertyJsonDigesterRule * rule = [[OBASetPropertyJsonDigesterRule alloc] initWithPropertyName:property onlyIfNeeded:YES]; + [self addRule:rule forPrefix:prefix]; + +} + +- (void) addSetNext:(SEL)selector forPrefix:(NSString*)prefix { + OBASetNextOBAJsonDigesterRule * rule = [[OBASetNextOBAJsonDigesterRule alloc] initWithSelector:selector]; + [self addRule:rule forPrefix:prefix]; +} + +- (void) addTarget:(NSObject*)target selector:(SEL)selector forRuleTarget:(OBAJsonDigesterRuleTarget)ruleTarget prefix:(NSString*)prefix { + OBASelectorJsonDigesterRule * rule = [[OBASelectorJsonDigesterRule alloc] initWithTarget:target selector:selector ruleTarget:ruleTarget]; + [self addRule:rule forPrefix:prefix]; +} + +- (BOOL) parse:(id)jsonRoot withRoot:(id)rootObject error:(NSError**)error { + return [self parse:jsonRoot withRoot:rootObject parameters:@{} error:error]; +} + +- (BOOL)parse:(id)jsonRoot withRoot:(id)rootObject parameters:(NSDictionary*)parameters error:(NSError**)error { + + OBAJsonDigesterContextImpl * context = [[OBAJsonDigesterContextImpl alloc] initWithVerbose:_verbose]; + + for (id key in parameters) { + [context setParamter:parameters[key] forKey:key]; + } + + if (rootObject) { + [context pushValue:rootObject]; + } + + [self recursivelyParse:context jsonValue:jsonRoot prefix:@"" name:@"/"]; + + NSError * err = context.error; + + if (err && error) { + (*error) = err; + } + return (err != nil); +} + +-(NSString*) extendPrefix:(NSString*)prefix withValue:(NSString*)value { + if( [prefix length] == 0) + return value; + if( [value length] == 0) + return prefix; + if( [prefix characterAtIndex:([prefix length]-1)] == '/' ) + return [NSString stringWithFormat:@"%@%@",prefix,value]; + else + return [NSString stringWithFormat:@"%@/%@",prefix,value]; +} + +@end + + +#pragma mark OBAJsonDigester (Private) Implementation + +@implementation OBAJsonDigester (Private) + +-(void) recursivelyParse:(OBAJsonDigesterContextImpl*)context jsonValue:(id)value prefix:(NSString*)prefix name:(NSString*)name { + + NSString * fullName = [self extendPrefix:prefix withValue:name]; + + if( _verbose ) + OBALogDebug(@"path=%@",fullName); + + NSArray * rules = _rulesByPrefix[fullName]; + + if( rules ) { + for( id rule in rules) { + if( [rule respondsToSelector:@selector(begin:name:value:)] ) { + [rule begin:context name:name value:value]; + if( context.error ) + return; + } + } + } + + if([value isKindOfClass:[NSDictionary class]]) { + NSDictionary * dictionary = (NSDictionary*) value; + for( id key in dictionary ) { + if( ! [key isKindOfClass:[NSString class]] ) + continue; + NSString * keyString = (NSString*)key; + id nextValue = dictionary[key]; + [self recursivelyParse:context jsonValue:nextValue prefix:fullName name:keyString]; + if( context.error ) + return; + } + } + else if([value isKindOfClass:[NSArray class]]) { + NSArray * array = (NSArray*) value; + for( id nextValue in array ) { + [self recursivelyParse:context jsonValue:nextValue prefix:fullName name:@"[]"]; + if( context.error ) + return; + } + } + else { + + } + + if( rules ) { + for( NSInteger i = [rules count]-1; i>=0; i--) { + id rule = rules[i]; + if( [rule respondsToSelector:@selector(end:name:value:)] ) { + [rule end:context name:name value:value]; + if( context.error ) + return; + } + } + } +} + +@end + + +#pragma mark OBAJsonDigesterContextImpl Implementation + +@implementation OBAJsonDigesterContextImpl + +@synthesize error = _error; + +- (id) initWithVerbose:(BOOL)verbose { + self = [super init]; + if( self ) { + _stack = [[NSMutableArray alloc] init]; + _parameters = [[NSMutableDictionary alloc] init]; + _verbose = verbose; + } + return self; +} + + +-(void) pushValue:(id)value { + [_stack addObject:value]; +} + +-(id) peek:(NSUInteger)index { + NSInteger objIndex = [_stack count] - 1 - index; + if (objIndex < 0 || objIndex > [_stack count]) { + NSLog(@"OBAJsonDigesterContextImpl: peek - index out of bounds: %lu => %ld", (unsigned long)index, (long)objIndex); + return nil; + } + return _stack[objIndex]; +} + +-(void) popValue { + [_stack removeLastObject]; +} + +- (id) getParameterForKey:(id)key { + return _parameters[key]; +} + +- (void) setParamter:(id)value forKey:(id)key { + _parameters[key] = value; +} + +- (BOOL) verbose { + return _verbose; +} + +@end + diff --git a/Classes/OBAListWithRangeAndReferencesV2.h b/Classes/OBAListWithRangeAndReferencesV2.h new file mode 100755 index 0000000..e0521a6 --- /dev/null +++ b/Classes/OBAListWithRangeAndReferencesV2.h @@ -0,0 +1,21 @@ +#import "OBAHasReferencesV2.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBAListWithRangeAndReferencesV2 : OBAHasReferencesV2 { + BOOL _limitExceeded; + BOOL _outOfRange; + NSMutableArray * _values; +} + +@property (nonatomic) BOOL limitExceeded; +@property (nonatomic) BOOL outOfRange; +@property (nonatomic,strong) NSArray * values; + +@property (nonatomic,readonly) NSUInteger count; + +- (void) addValue:(id)value; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAListWithRangeAndReferencesV2.m b/Classes/OBAListWithRangeAndReferencesV2.m new file mode 100755 index 0000000..3b5abb5 --- /dev/null +++ b/Classes/OBAListWithRangeAndReferencesV2.m @@ -0,0 +1,22 @@ +#import "OBAListWithRangeAndReferencesV2.h" + + +@implementation OBAListWithRangeAndReferencesV2 + +- (id) initWithReferences:(OBAReferencesV2*)refs { + self = [super initWithReferences:refs]; + if (self) { + _values = [[NSMutableArray alloc] init]; + } + return self; +} + + +- (void) addValue:(id)value { + [_values addObject:value]; +} + +- (NSUInteger) count { + return _values.count; +} +@end diff --git a/Classes/OBALocationManager.h b/Classes/OBALocationManager.h new file mode 100755 index 0000000..34e15c4 --- /dev/null +++ b/Classes/OBALocationManager.h @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#import "OBAModelDAO.h" + +NS_ASSUME_NONNULL_BEGIN + +@class OBALocationManager; + +@protocol OBALocationManagerDelegate +- (void) locationManager:(OBALocationManager *)manager didUpdateLocation:(CLLocation *)location; +- (void) locationManager:(OBALocationManager *)manager didFailWithError:(NSError*)error; + +@optional +- (void)locationManager:(OBALocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status; +@end + + +@interface OBALocationManager : NSObject { + + OBAModelDAO * _modelDao; + CLLocationManager * _locationManager; + NSMutableArray * _delegates; + + CLLocation * _currentLocation; +} + +- (id) initWithModelDao:(OBAModelDAO*)modelDao; + +@property (nonatomic,strong) CLLocation * currentLocation; +@property (readonly, nonatomic) BOOL locationServicesEnabled; + +- (void)addDelegate:(id)delegate; +- (void)removeDelegate:(id)delegate; + +- (void)startUpdatingLocation; +- (void)stopUpdatingLocation; + +// iOS 8 Location Manager Support +- (BOOL)hasRequestedInUseAuthorization; +- (void)requestInUseAuthorization; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBALocationManager.m b/Classes/OBALocationManager.m new file mode 100755 index 0000000..7ba1d09 --- /dev/null +++ b/Classes/OBALocationManager.m @@ -0,0 +1,159 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBALocationManager.h" +#import "OBALogger.h" + +static const NSTimeInterval kSuccessiveLocationComparisonWindow = 3; + +@interface OBALocationManager (Private) + +- (void)handleNewLocation:(CLLocation*)location; + +@end + +@implementation OBALocationManager + +- (id) initWithModelDao:(OBAModelDAO*)modelDao { + if( self = [super init]) { + _modelDao = modelDao; + _locationManager = [[CLLocationManager alloc] init]; + _locationManager.delegate = self; + _delegates = [[NSMutableArray alloc] init]; + + if (![self hasRequestedInUseAuthorization]) { + [self requestInUseAuthorization]; + } + } + return self; +} + + +- (BOOL)locationServicesEnabled { + return [CLLocationManager locationServicesEnabled]; +} + +- (void) addDelegate:(id)delegate { + @synchronized(self) { + [_delegates addObject:delegate]; + } +} + +- (void) removeDelegate:(id)delegate { + @synchronized(self) { + [_delegates removeObject:delegate]; + } +} + +-(void) startUpdatingLocation { + if( [CLLocationManager locationServicesEnabled] ) { + [_locationManager startUpdatingLocation]; + } + else { + if (! [_modelDao hideFutureLocationWarnings]) { + [_locationManager startUpdatingLocation]; + // [_modelDao setHideFutureLocationWarnings:YES]; + } + } +} + +-(void) stopUpdatingLocation { + [_locationManager stopUpdatingLocation]; +} + +#pragma mark - iOS 8 Location Manager Support + +- (BOOL)hasRequestedInUseAuthorization { + if ([CLLocationManager respondsToSelector:@selector(authorizationStatus)]) { + return [CLLocationManager authorizationStatus] != kCLAuthorizationStatusNotDetermined; + } + else { + return YES; + } +} + +- (void)requestInUseAuthorization { + if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { + [_locationManager requestWhenInUseAuthorization]; + } +} + +#pragma mark CLLocationManagerDelegate + +- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations +{ +// _modelDao.hideFutureLocationWarnings = NO; + [self handleNewLocation:locations.lastObject]; +} + +- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { + +// if (error.code == kCLErrorDenied) { +// [self stopUpdatingLocation]; +// for (NSInteger i = 0; i < _delegates.count; i++) { +// [(id)_delegates[i] locationManager:self didFailWithError:error]; +// } +// } +} + +- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status +{ + for (id d in _delegates) { + if ([d respondsToSelector:@selector(locationManager:didChangeAuthorizationStatus:)]) { + [d locationManager:self didChangeAuthorizationStatus:status]; + } + } +} + +@end + +@implementation OBALocationManager (Private) + +- (void)handleNewLocation:(CLLocation*)location { + + @synchronized(self) { + + /** + * We have this issue where we get a high-accuracy location reading immediately + * followed by a low-accuracy location reading, such as if wifi-localization + * completed before cell-tower-localization. We want to ignore the low-accuracy + * reading + */ + if (_currentLocation) { + + NSDate * currentTime = [_currentLocation timestamp]; + NSDate * newTime = [location timestamp]; + + NSTimeInterval interval = [newTime timeIntervalSinceDate:currentTime]; + + if (interval < kSuccessiveLocationComparisonWindow && + [_currentLocation horizontalAccuracy] < [location horizontalAccuracy]) { + OBALogDebug(@"pruning location reading with low accuracy"); + return; + } + } + _currentLocation = location; + + for (int i = 0; i < [_delegates count]; i++) { + [(id)[_delegates objectAtIndex:i ] locationManager:self didUpdateLocation:_currentLocation]; + } + } +} + +@end + + + diff --git a/Classes/OBALogger.h b/Classes/OBALogger.h new file mode 100755 index 0000000..8860062 --- /dev/null +++ b/Classes/OBALogger.h @@ -0,0 +1,62 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import Foundation; + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, OBALoggerLevel) { + OBALoggerLevelDebug, + OBALoggerLevelInfo, + OBALoggerLevelWarning, + OBALoggerLevelSevere +}; + +#ifdef NDEBUG + +#define OBALog(level,s,...) +#define OBALogWithError(level,errorObject,s,...) + +#else + +#define OBALog(level,s,...) [OBALogger logWithLevel:level pointer:self file:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] line:__LINE__ message:[NSString stringWithFormat:(s), ##__VA_ARGS__]] +#define OBALogWithError(level,errorObject,s,...) [OBALogger logWithLevel:level pointer:self file:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] line:__LINE__ message:[NSString stringWithFormat:(s), ##__VA_ARGS__] error:errorObject] + +#endif + +#define OBALogDebug(s,...) OBALog(OBALoggerLevelDebug,s, ##__VA_ARGS__) +#define OBALogDebugWithError(error,s,...) OBALogWithError(OBALoggerLevelDebug,error,s, ##__VA_ARGS__) + +#define OBALogInfo(s,...) OBALog(OBALoggerLevelInfo,s, ##__VA_ARGS__) +#define OBALogInfoWithError(error,s,...) OBALogWithError(OBALoggerLevelInfo,error, s, ##__VA_ARGS__) + +#define OBALogWarning(s,...) OBALog(OBALoggerLevelWarning,s, ##__VA_ARGS__) +#define OBALogWarningWithError(error,s,...) OBALogWithError(OBALoggerLevelWarning,error,s, ##__VA_ARGS__) + +#define OBALogSevere(s,...) OBALog(OBALoggerLevelSevere,s, ##__VA_ARGS__) +#define OBALogSevereWithError(error,s,...) OBALogWithError(OBALoggerLevelSevere,error,s, ##__VA_ARGS__) + +@interface OBALogger : NSObject { + +} + ++ (void) logWithLevel:(OBALoggerLevel)level pointer:(id)pointer file:(NSString*)file line:(NSInteger)line message:(NSString*)message; ++ (void) logWithLevel:(OBALoggerLevel)level pointer:(id)pointer file:(NSString*)file line:(NSInteger)line message:(NSString*)message error:(NSError*)error; ++ (NSString*) logLevelAsString:(OBALoggerLevel)level; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Classes/OBALogger.m b/Classes/OBALogger.m new file mode 100755 index 0000000..57ca0d2 --- /dev/null +++ b/Classes/OBALogger.m @@ -0,0 +1,86 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import CoreData; +#import "OBALogger.h" + +@interface OBALogger (Internal) + ++ (void) logError:(NSError*)error prefix:(NSString*)prefix; + +@end + +@implementation OBALogger + ++ (void) logWithLevel:(OBALoggerLevel)level pointer:(id)pointer file:(NSString*)file line:(NSInteger)line message:(NSString*)message { + NSLog(@"# %@ - %p %@:%ld",[self logLevelAsString:level],pointer,file,(long)line); + NSLog(@"%@",message); +} + ++ (void) logWithLevel:(OBALoggerLevel)level pointer:(id)pointer file:(NSString*)file line:(NSInteger)line message:(NSString*)message error:(NSError*)error { + [self logWithLevel:level pointer:pointer file:file line:line message:message]; + [self logError:error prefix:@""]; +} + ++ (NSString*) logLevelAsString:(OBALoggerLevel)level { + switch(level) { + case OBALoggerLevelDebug: + return @"DEBUG"; + case OBALoggerLevelInfo: + return @"INFO"; + case OBALoggerLevelWarning: + return @"WARNING"; + case OBALoggerLevelSevere: + return @"SEVERE"; + default: + return @"UNKNOWN"; + } +} +@end + +@implementation OBALogger (Internal) + ++ (void) logError:(NSError*)error prefix:(NSString*)prefix { + + if( ! error ) + return; + + NSLog(@"%@%@: %@",prefix,[error localizedDescription],[error localizedFailureReason]); + + NSDictionary * userInfo = [error userInfo]; + + switch( [error code] ) { + case NSValidationMultipleErrorsError: { + NSArray * errors = userInfo[@"NSDetailedErrors"]; + for( NSError * subError in errors ) + [self logError:subError prefix:[NSString stringWithFormat:@"%@ ",prefix]]; + break; + } + case NSValidationMissingMandatoryPropertyError: { + NSString * validationErrorKey = userInfo[@"NSValidationErrorKey"]; + id validationErrorObject = userInfo[@"NSValidationErrorObject"]; + NSLog(@"%@ validation error key: %@",prefix,validationErrorKey); + NSLog(@"%@ validation error object: %@",prefix,[validationErrorObject description]); + break; + } + default: { + NSLog(@"%@ userInfo:",[userInfo description]); + } + } +} + +@end + diff --git a/Classes/OBAMacros.h b/Classes/OBAMacros.h new file mode 100644 index 0000000..83f3e65 --- /dev/null +++ b/Classes/OBAMacros.h @@ -0,0 +1,33 @@ +// +// OBAMacros.h +// OneBusAwaySDK +// +// Created by Aaron Brethorst on 2/16/16. +// Copyright © 2016 One Bus Away. All rights reserved. +// + +#ifndef OBAMacros_h +#define OBAMacros_h + +#define APP_DELEGATE ((CycleAtlantaAppDelegate.h*)[UIApplication sharedApplication].delegate) + +#define OBARGBCOLOR(__r, __g, __b) [UIColor colorWithRed:(__r / 255.f) green:(__g / 255.f) blue:(__b / 255.f) alpha:1.f] +#define OBARGBACOLOR(__r, __g, __b, __a) [UIColor colorWithRed:(__r / 255.f) green:(__g / 255.f) blue:(__b / 255.f) alpha:__a] +#define OBAGREENWITHALPHA(__a) [UIColor colorWithHue:(86.f/360.f) saturation:0.68f brightness:0.67f alpha:__a] +#define OBAGREEN [UIColor colorWithHue:(86.f/360.f) saturation:0.68f brightness:0.67f alpha:1.f] +#define OBAGREENBACKGROUND [UIColor colorWithRed:0.92f green:0.95f blue:0.88f alpha:.67f] +#define OBADARKGREEN [UIColor colorWithRed:0.2f green:.4f blue:0.f alpha:1.f] + +#define OBAViewedArrivalsAndDeparturesForStopNotification @"OBAViewedArrivalsAndDeparturesForStopNotification" +#define OBAMostRecentStopsChangedNotification @"OBAMostRecentStopsChangedNotification" + +#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) + +#define OBAGuard(CONDITION) \ + if (!CONDITION) { NSParameterAssert(CONDITION); } \ + if (CONDITION) {} + +#define OBAGuardClass(object, typeName) \ + OBAGuard([object isKindOfClass:[typeName class]]) + +#endif /* OBAMacros_h */ diff --git a/Classes/OBAModelDAO.h b/Classes/OBAModelDAO.h new file mode 100644 index 0000000..0da78d3 --- /dev/null +++ b/Classes/OBAModelDAO.h @@ -0,0 +1,45 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#import "OBARegionV2.h" +#import "OBAModelPersistenceLayer.h" + +NS_ASSUME_NONNULL_BEGIN + +@class OBAModelDAOUserPreferencesImpl; + +@interface OBAModelDAO : NSObject +@property(nonatomic,strong) CLLocation *mostRecentLocation; +@property(nonatomic,strong,nullable) OBARegionV2 *region; +@property(nonatomic,strong,nullable) NSArray *allRegions; +@property(weak, nonatomic,readonly) NSArray * mostRecentCustomApiUrls; +@property(nonatomic,assign) BOOL hideFutureLocationWarnings; + +- (instancetype)initWithModelPersistenceLayer:(id)persistenceLayer; + +- (BOOL) readSetRegionAutomatically; +- (void) writeSetRegionAutomatically:(BOOL)setRegionAutomatically; + +- (NSString*) readCustomApiUrl; +- (void) writeCustomApiUrl:(NSString*)customApiUrl; + +- (void) addCustomApiUrl:(NSString*)customApiUrl; + +- (NSString*)normalizedAPIServerURL; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAModelDAO.m b/Classes/OBAModelDAO.m new file mode 100644 index 0000000..083831a --- /dev/null +++ b/Classes/OBAModelDAO.m @@ -0,0 +1,155 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAModelDAO.h" +#import "OBACommon.h" +#import "OBACommonV1.h" +#import "OBAMacros.h" +#import "OBAModelDAOUserPreferencesImpl.h" + +const NSInteger kMaxEntriesInMostRecentList = 10; + +@interface OBAModelDAO () +@property(nonatomic,strong) id preferencesDao; +@end + +@implementation OBAModelDAO { + CLLocation * _mostRecentLocation; + NSMutableSet * _visitedSituationIds; + NSMutableArray * _mostRecentCustomApiUrls; +} +@dynamic hideFutureLocationWarnings; + +- (instancetype)initWithModelPersistenceLayer:(id)persistenceLayer { + self = [super init]; + + if (self) { + _preferencesDao = persistenceLayer; + _mostRecentLocation = [_preferencesDao readMostRecentLocation]; + _visitedSituationIds = [[NSMutableSet alloc] initWithSet:[_preferencesDao readVisistedSituationIds]]; + _region = [_preferencesDao readOBARegion]; + _mostRecentCustomApiUrls = [[NSMutableArray alloc] initWithArray:[_preferencesDao readMostRecentCustomApiUrls]]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewedArrivalsAndDeparturesForStop:) name:OBAViewedArrivalsAndDeparturesForStopNotification object:nil]; + } + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self name:OBAViewedArrivalsAndDeparturesForStopNotification object:nil]; +} + +#pragma mark - Recent + +- (NSArray*) mostRecentCustomApiUrls { + return _mostRecentCustomApiUrls; +} + +- (CLLocation*) mostRecentLocation { + return _mostRecentLocation; +} + +- (void) setMostRecentLocation:(CLLocation*)location { + _mostRecentLocation = location; + [_preferencesDao writeMostRecentLocation:location]; +} + +#pragma mark - Regions + +- (void)setRegion:(OBARegionV2 *)region { + if (_region == region) { + return; + } + + _region = region; + [_preferencesDao writeOBARegion:region]; +} + +- (BOOL) readSetRegionAutomatically { + return [_preferencesDao readSetRegionAutomatically]; +} + +- (void) writeSetRegionAutomatically:(BOOL)setRegionAutomatically { + [_preferencesDao writeSetRegionAutomatically:setRegionAutomatically]; +} + + +#pragma mark - Custom API Server + +- (void)addCustomApiUrl:(NSString *)customApiUrl { + + if (!customApiUrl) { + return; + } + + NSString *existingCustomApiUrl = nil; + + for (NSString *recentCustomApiUrl in _mostRecentCustomApiUrls) { + if ([recentCustomApiUrl isEqualToString:customApiUrl]) { + existingCustomApiUrl = customApiUrl; + break; + } + } + + if (existingCustomApiUrl) { + [_mostRecentCustomApiUrls removeObject:existingCustomApiUrl]; + [_mostRecentCustomApiUrls insertObject:existingCustomApiUrl atIndex:0]; + } + else { + [_mostRecentCustomApiUrls insertObject:customApiUrl atIndex:0]; + } + + NSInteger over = [_mostRecentCustomApiUrls count] - kMaxEntriesInMostRecentList; + for (NSInteger i=0; i 0) { + if ([self.readCustomApiUrl hasPrefix:@"http://"] || [self.readCustomApiUrl hasPrefix:@"https://"]) { + apiServerName = self.readCustomApiUrl; + } + else { + apiServerName = [NSString stringWithFormat:@"http://%@", self.readCustomApiUrl]; + } + } + else if (self.region) { + apiServerName = self.region.baseUrl; + } + + if ([apiServerName hasSuffix:@"/"]) { + apiServerName = [apiServerName substringToIndex:apiServerName.length - 1]; + } + + return apiServerName; +} + +- (NSString*)readCustomApiUrl { + return [_preferencesDao readCustomApiUrl]; +} + +- (void)writeCustomApiUrl:(NSString*)customApiUrl { + [_preferencesDao writeCustomApiUrl:customApiUrl]; +} + +@end + diff --git a/Classes/OBAModelDAOUserPreferencesImpl.h b/Classes/OBAModelDAOUserPreferencesImpl.h new file mode 100644 index 0000000..b3bd1e9 --- /dev/null +++ b/Classes/OBAModelDAOUserPreferencesImpl.h @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBARegionV2.h" +#import "OBAModelPersistenceLayer.h" + +NS_ASSUME_NONNULL_BEGIN + +extern NSString * const kSetRegionAutomaticallyKey; + +@interface OBAModelDAOUserPreferencesImpl : NSObject + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAModelDAOUserPreferencesImpl.m b/Classes/OBAModelDAOUserPreferencesImpl.m new file mode 100644 index 0000000..3cc94ea --- /dev/null +++ b/Classes/OBAModelDAOUserPreferencesImpl.m @@ -0,0 +1,159 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAModelDAOUserPreferencesImpl.h" + +NSString * const kBookmarksKey = @"bookmarks"; +NSString * const kBookmarkGroupsKey = @"bookmarkGroups"; +NSString * const kMostRecentStopsKey = @"mostRecentStops"; +NSString * const kStopPreferencesKey = @"stopPreferences"; +NSString * const kMostRecentLocationKey = @"mostRecentLocation"; +NSString * const kHideFutureLocationWarningsKey = @"hideFutureLocationWarnings"; +NSString * const kVisitedSituationIdsKey = @"hideFutureLocationWarnings"; +NSString * const kOBARegionKey = @"oBARegion"; +NSString * const kSetRegionAutomaticallyKey = @"setRegionAutomatically"; +NSString * const kCustomApiUrlKey = @"customApiUrl"; +NSString * const kMostRecentCustomApiUrlsKey = @"mostRecentCustomApiUrls"; + +@implementation OBAModelDAOUserPreferencesImpl + +- (NSArray*)readBookmarks { + return [self.class loadAndDecodeObjectFromDataForKey:kBookmarksKey] ?: @[]; +} + +- (void)writeBookmarks:(NSArray*)source { + [self.class writeObjectToUserDefaults:source withKey:kBookmarksKey]; +} + +- (NSArray*)readBookmarkGroups { + return [self.class loadAndDecodeObjectFromDataForKey:kBookmarkGroupsKey] ?: @[]; +} + +- (void)writeBookmarkGroups:(NSArray*)source { + [self.class writeObjectToUserDefaults:source withKey:kBookmarkGroupsKey]; +} + +- (NSArray*)readMostRecentStops { + return [self.class loadAndDecodeObjectFromDataForKey:kMostRecentStopsKey] ?: @[]; +} + +- (void)writeMostRecentStops:(NSArray*)source { + [self.class writeObjectToUserDefaults:source withKey:kMostRecentStopsKey]; +} + +- (NSDictionary*)readStopPreferences { + id out = [self.class loadAndDecodeObjectFromDataForKey:kStopPreferencesKey] ?: @{}; + return out; +} + +- (void)writeStopPreferences:(NSDictionary*)stopPreferences { + [self.class writeObjectToUserDefaults:stopPreferences withKey:kStopPreferencesKey]; +} + +- (CLLocation*)readMostRecentLocation { + return [self.class loadAndDecodeObjectFromDataForKey:kMostRecentLocationKey]; +} + +- (void)writeMostRecentLocation:(CLLocation*)mostRecentLocation { + [self.class writeObjectToUserDefaults:mostRecentLocation withKey:kMostRecentLocationKey]; +} + +- (BOOL)hideFutureLocationWarnings { + return [[NSUserDefaults standardUserDefaults] boolForKey:kHideFutureLocationWarningsKey]; +} + +- (void)setHideFutureLocationWarnings:(BOOL)hideFutureLocationWarnings { + [[NSUserDefaults standardUserDefaults] setBool:hideFutureLocationWarnings forKey:kHideFutureLocationWarningsKey]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +- (NSSet*)readVisistedSituationIds { + return [self.class loadAndDecodeObjectFromDataForKey:kVisitedSituationIdsKey] ?: [NSSet set]; +} + +- (void)writeVisistedSituationIds:(NSSet*)situationIds { + [self.class writeObjectToUserDefaults:situationIds withKey:kVisitedSituationIdsKey]; +} + +- (OBARegionV2*)readOBARegion { + return [self.class loadAndDecodeObjectFromDataForKey:kOBARegionKey]; +} + +- (void)writeOBARegion:(OBARegionV2 *)region { + [self.class writeObjectToUserDefaults:region withKey:kOBARegionKey]; +} + +- (BOOL)readSetRegionAutomatically { + return [[NSUserDefaults standardUserDefaults] boolForKey:kSetRegionAutomaticallyKey]; +} + +- (void)writeSetRegionAutomatically:(BOOL)setRegionAutomatically { + [[NSUserDefaults standardUserDefaults] setBool:setRegionAutomatically forKey:kSetRegionAutomaticallyKey]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +// TODO: I think the idea of slinging around an empty string instead of nil here is an +// incredibly bad idea. But, reworking our custom API support is out of scope for the moment. +- (NSString*)readCustomApiUrl { + return [self.class loadAndDecodeObjectFromDataForKey:kCustomApiUrlKey] ?: @""; +} + +- (void)writeCustomApiUrl:(NSString*)customApiUrl { + [self.class writeObjectToUserDefaults:customApiUrl withKey:kCustomApiUrlKey]; +} + +- (NSArray*)readMostRecentCustomApiUrls { + return [self.class loadAndDecodeObjectFromDataForKey:kMostRecentCustomApiUrlsKey] ?: @[]; +} + +- (void)writeMostRecentCustomApiUrls:(NSArray*)customApiUrls { + [self.class writeObjectToUserDefaults:customApiUrls withKey:kMostRecentCustomApiUrlsKey]; +} + +#pragma mark - (De-)Serialization + ++ (id)loadAndDecodeObjectFromDataForKey:(NSString*)key { + NSData *data = [[NSUserDefaults standardUserDefaults] dataForKey:key]; + + if (!data) { + return nil; + } + + id object = nil; + + @try { + NSKeyedUnarchiver * unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; + object = [unarchiver decodeObjectForKey:key]; + [unarchiver finishDecoding]; + } + @catch (NSException *exception) { + NSLog(@"Unable to decode object for key %@ - %@", key, exception); + } + + return object; +} + ++ (void)writeObjectToUserDefaults:(id)object withKey:(NSString*)key { + NSMutableData * data = [NSMutableData data]; + + NSKeyedArchiver * archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; + [archiver encodeObject:object forKey:key]; + [archiver finishEncoding]; + + [[NSUserDefaults standardUserDefaults] setObject:data forKey:key]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} +@end diff --git a/Classes/OBAModelFactory.h b/Classes/OBAModelFactory.h new file mode 100755 index 0000000..6ce01df --- /dev/null +++ b/Classes/OBAModelFactory.h @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAListWithRangeAndReferencesV2.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBAModelFactory : NSObject { + OBAReferencesV2 * _references; + NSMutableDictionary * _entityIdMappings; +} + +- (id) initWithReferences:(OBAReferencesV2*)references; + +- (OBAListWithRangeAndReferencesV2*) getRegionsV2FromJson:(id)jsonDictionary error:(NSError**)error; + +- (NSString*) getShapeV2FromJSON:(NSDictionary*)json error:(NSError*)error; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAModelFactory.m b/Classes/OBAModelFactory.m new file mode 100755 index 0000000..5d96cb9 --- /dev/null +++ b/Classes/OBAModelFactory.m @@ -0,0 +1,225 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAModelFactory.h" +#import "OBALogger.h" + +#import "OBAReferencesV2.h" +#import "OBAAgencyV2.h" + +#import "OBAJsonDigester.h" +#import "OBASetCoordinatePropertyJsonDigesterRule.h" +#import "OBASetLocationPropertyJsonDigesterRule.h" +#import "OBASetDatePropertyJsonDigesterRule.h" + +#import "OBARegionV2.h" +#import "OBARegionBoundsV2.h" + +static NSString * const kReferences = @"references"; + +@interface OBAModelFactory (Private) + +- (NSDictionary*) getDigesterParameters; + +@end + + +@interface OBAJsonDigester (CustomDigesterRules) + +- (void) addReferencesRulesWithPrefix:(NSString*)prefix; + +- (void) addAgencyV2RulesWithPrefix:(NSString*)prefix; +- (void) addRouteV2RulesWithPrefix:(NSString*)prefix; +- (void) addStopV2RulesWithPrefix:(NSString*)prefix; +- (void) addTripV2RulesWithPrefix:(NSString*)prefix; +- (void) addSituationV2RulesWithPrefix:(NSString*)prefix; +- (void) addTripDetailsV2RulesWithPrefix:(NSString*)prefix; + +- (void) addAgencyWithCoverageV2RulesWithPrefix:(NSString*)prefix; + +- (void) addArrivalAndDepartureV2RulesWithPrefix:(NSString*)prefix; +- (void) addTripStatusV2RulesWithPrefix:(NSString*)prefix; +- (void) addFrequencyV2RulesWithPrefix:(NSString*)prefix; + +- (void) addVehicleStatusV2RulesWithPrefix:(NSString*)prefix; + +- (void) addAgencyToReferences:(id)context name:(NSString*)name value:(id)value; +- (void) addRouteToReferences:(id)context name:(NSString*)name value:(id)value; +- (void) addStopToReferences:(id)context name:(NSString*)name value:(id)value; +- (void) addTripToReferences:(id)context name:(NSString*)name value:(id)value; +- (void) addSituationToReferences:(id)context name:(NSString*)name value:(id)value; + +- (void) setReferencesForContext:(id)context name:(NSString*)name value:(id)value; + +- (void) addSetCoordinatePropertyRule:(NSString*)propertyName withPrefix:(NSString*)prefix method:(OBASetCoordinatePropertyMethod)method; +- (void) addSetLocationPropertyRule:(NSString*)propertyName withPrefix:(NSString*)prefix; +- (void) addSetDatePropertyRule:(NSString*)propertyName withPrefix:(NSString*)prefix; + +- (void) addRegionV2RulesWithPrefix:(NSString*)prefix; +- (void) addRegionBoundsV2RulesWithPrefix:(NSString*)prefix; +@end + + +@implementation OBAModelFactory + +- (id) initWithReferences:(OBAReferencesV2*)references { + + self = [super init]; + + if( self ) { + _references = references; + _entityIdMappings = [[NSMutableDictionary alloc] init]; + } + return self; +} + + +- (OBAListWithRangeAndReferencesV2*) getAgenciesWithCoverageV2FromJson:(id)jsonDictionary error:(NSError**)error { + + OBAListWithRangeAndReferencesV2 * list = [[OBAListWithRangeAndReferencesV2 alloc] initWithReferences:_references]; + + OBAJsonDigester * digester = [[OBAJsonDigester alloc] init]; + [digester addReferencesRulesWithPrefix:@"/references"]; + [digester addAgencyWithCoverageV2RulesWithPrefix:@"/list/[]"]; + [digester addSetNext:@selector(addValue:) forPrefix:@"/list/[]"]; + + [digester parse:jsonDictionary withRoot:list parameters:[self getDigesterParameters] error:error]; + + return list; +} + +- (OBAListWithRangeAndReferencesV2*) getRegionsV2FromJson:(id)jsonDictionary error:(NSError**)error { + OBAListWithRangeAndReferencesV2 * list = [[OBAListWithRangeAndReferencesV2 alloc] initWithReferences:_references]; + + jsonDictionary = jsonDictionary ?: [self.class staticRegionsJSON]; + + OBAJsonDigester * digester = [[OBAJsonDigester alloc] init]; + [digester addRegionV2RulesWithPrefix:@"/list/[]"]; + [digester addSetNext:@selector(addValue:) forPrefix:@"/list/[]"]; + [digester parse:jsonDictionary withRoot:list parameters:[self getDigesterParameters] error:error]; + + return list; +} + ++ (id)staticRegionsJSON { + NSString *filePath = [[NSBundle mainBundle] pathForResource:@"regions-v3" ofType:@"json"]; + NSData *data = [[NSData alloc] initWithContentsOfFile:filePath]; + + return [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; +} + +- (NSString*) getShapeV2FromJSON:(NSDictionary*)json error:(NSError*)error { + NSDictionary * entry = json[@"entry"]; + return entry[@"points"]; +} + +@end + +@implementation OBAModelFactory (Private) + +- (NSDictionary*) getDigesterParameters { + NSMutableDictionary * params = [NSMutableDictionary dictionary]; + params[kReferences] = _references; + return params; +} + +@end + + +@implementation OBAJsonDigester (CustomDigesterRules) + +- (void) addReferencesRulesWithPrefix:(NSString*)prefix { + + NSString * agencyPrefix = [self extendPrefix:prefix withValue:@"agencies/[]"]; + [self addAgencyV2RulesWithPrefix:agencyPrefix]; + + NSString * routePrefix = [self extendPrefix:prefix withValue:@"routes/[]"]; + [self addRouteV2RulesWithPrefix:routePrefix]; + + NSString * stopPrefix = [self extendPrefix:prefix withValue:@"stops/[]"]; + [self addStopV2RulesWithPrefix:stopPrefix]; + + NSString * tripPrefix = [self extendPrefix:prefix withValue:@"trips/[]"]; + [self addTripV2RulesWithPrefix:tripPrefix]; + + NSString * situationPrefix = [self extendPrefix:prefix withValue:@"situations/[]"]; + [self addSituationV2RulesWithPrefix:situationPrefix]; + +} + +- (void) addAgencyV2RulesWithPrefix:(NSString*)prefix { + [self addObjectCreateRule:[OBAAgencyV2 class] forPrefix:prefix]; + [self addSetPropertyRule:@"agencyId" forPrefix:[self extendPrefix:prefix withValue:@"id"]]; + [self addSetPropertyRule:@"name" forPrefix:[self extendPrefix:prefix withValue:@"name"]]; + [self addSetPropertyRule:@"url" forPrefix:[self extendPrefix:prefix withValue:@"url"]]; + [self addTarget:self selector:@selector(addAgencyToReferences:name:value:) forRuleTarget:OBAJsonDigesterRuleTargetEnd prefix:prefix]; +} + +- (void) addRegionV2RulesWithPrefix:(NSString*)prefix { + [self addObjectCreateRule:[OBARegionV2 class] forPrefix:prefix]; + [self addSetPropertyRule:@"siriBaseUrl" forPrefix:[self extendPrefix:prefix withValue:@"siriBaseUrl"]]; + [self addSetPropertyRule:@"obaVersionInfo" forPrefix:[self extendPrefix:prefix withValue:@"obaVersionInfo"]]; + [self addSetPropertyRule:@"supportsSiriRealtimeApis" forPrefix:[self extendPrefix:prefix withValue:@"supportsSiriRealtimeApis"]]; + [self addSetPropertyRule:@"language" forPrefix:[self extendPrefix:prefix withValue:@"language"]]; + [self addSetPropertyRule:@"supportsObaRealtimeApis" forPrefix:[self extendPrefix:prefix withValue:@"supportsObaRealtimeApis"]]; + + NSString * regionBoundsPrefix = [self extendPrefix:prefix withValue:@"bounds/[]"]; + [self addRegionBoundsV2RulesWithPrefix:regionBoundsPrefix]; + [self addSetNext:@selector(addBound:) forPrefix:regionBoundsPrefix]; + + [self addSetPropertyRule:@"supportsObaDiscoveryApis" forPrefix:[self extendPrefix:prefix withValue:@"supportsObaDiscoveryApis"]]; + [self addSetPropertyRule:@"contactEmail" forPrefix:[self extendPrefix:prefix withValue:@"contactEmail"]]; + [self addSetPropertyRule:@"twitterUrl" forPrefix:[self extendPrefix:prefix withValue:@"twitterUrl"]]; + [self addSetPropertyRule:@"facebookUrl" forPrefix:[self extendPrefix:prefix withValue:@"facebookUrl"]]; + [self addSetPropertyRule:@"active" forPrefix:[self extendPrefix:prefix withValue:@"active"]]; + [self addSetPropertyRule:@"experimental" forPrefix:[self extendPrefix:prefix withValue:@"experimental"]]; + [self addSetPropertyRule:@"baseUrl" forPrefix:[self extendPrefix:prefix withValue:@"baseUrl"]]; + [self addSetPropertyRule:@"identifier" forPrefix:[self extendPrefix:prefix withValue:@"id"]]; + [self addSetPropertyRule:@"regionName" forPrefix:[self extendPrefix:prefix withValue:@"regionName"]]; + [self addSetPropertyRule:@"tutorialUrl" forPrefix:[self extendPrefix:prefix withValue:@"tutorialUrl"]]; +} + +- (void) addRegionBoundsV2RulesWithPrefix:(NSString*)prefix { + [self addObjectCreateRule:[OBARegionBoundsV2 class] forPrefix:prefix]; + [self addSetPropertyRule:@"lowerLeftLatitude" forPrefix:[self extendPrefix:prefix withValue:@"lowerLeftLatitude"]]; + [self addSetPropertyRule:@"upperRightLatitude" forPrefix:[self extendPrefix:prefix withValue:@"upperRightLatitude"]]; + [self addSetPropertyRule:@"lowerLeftLongitude" forPrefix:[self extendPrefix:prefix withValue:@"lowerLeftLongitude"]]; + [self addSetPropertyRule:@"upperRightLongitude" forPrefix:[self extendPrefix:prefix withValue:@"upperRightLongitude"]]; +} + +- (void) setReferencesForContext:(id)context name:(NSString*)name value:(id)value { + OBAHasReferencesV2 * top = [context peek:0]; + OBAReferencesV2 * refs = [context getParameterForKey:kReferences]; + top.references = refs; +} + +- (void) addSetCoordinatePropertyRule:(NSString*)propertyName withPrefix:(NSString*)prefix method:(OBASetCoordinatePropertyMethod)method { + OBASetCoordinatePropertyJsonDigesterRule * rule = [[OBASetCoordinatePropertyJsonDigesterRule alloc] initWithPropertyName:propertyName method:method]; + [self addRule:rule forPrefix:prefix]; +} + +- (void) addSetLocationPropertyRule:(NSString*)propertyName withPrefix:(NSString*)prefix { + OBASetLocationPropertyJsonDigesterRule * rule = [[OBASetLocationPropertyJsonDigesterRule alloc] initWithPropertyName:propertyName]; + [self addRule:rule forPrefix:prefix]; +} + +- (void) addSetDatePropertyRule:(NSString*)propertyName withPrefix:(NSString*)prefix { + OBASetDatePropertyJsonDigesterRule * rule = [[OBASetDatePropertyJsonDigesterRule alloc] initWithPropertyName:propertyName]; + [self addRule:rule forPrefix:prefix]; +} + +@end + diff --git a/Classes/OBAModelPersistenceLayer.h b/Classes/OBAModelPersistenceLayer.h new file mode 100644 index 0000000..b7dbf00 --- /dev/null +++ b/Classes/OBAModelPersistenceLayer.h @@ -0,0 +1,48 @@ +// +// OBAModelPersistenceLayer.h +// org.onebusaway.iphone +// +// Created by Aaron Brethorst on 4/3/16. +// Copyright © 2016 OneBusAway. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol OBAModelPersistenceLayer +@property(nonatomic,assign) BOOL hideFutureLocationWarnings; + +- (NSArray*) readBookmarks; +- (void) writeBookmarks:(NSArray*)source; + +- (NSArray*) readBookmarkGroups; +- (void) writeBookmarkGroups:(NSArray*)source; + +- (NSArray*) readMostRecentStops; +- (void) writeMostRecentStops:(NSArray*)source; + +- (NSDictionary*) readStopPreferences; +- (void) writeStopPreferences:(NSDictionary*)stopPreferences; + +- (CLLocation * _Nullable) readMostRecentLocation; +- (void) writeMostRecentLocation:(CLLocation*)mostRecentLocation; + +- (NSSet*) readVisistedSituationIds; +- (void) writeVisistedSituationIds:(NSSet*)situationIds; + +- (OBARegionV2 * _Nullable) readOBARegion; +- (void)writeOBARegion:(OBARegionV2*)region; + +- (BOOL) readSetRegionAutomatically; +- (void) writeSetRegionAutomatically:(BOOL)setRegionAutomatically; + +- (NSString*) readCustomApiUrl; +- (void) writeCustomApiUrl:(NSString*)customApiUrl; + +- (NSArray*) readMostRecentCustomApiUrls; +- (void) writeMostRecentCustomApiUrls:(NSArray*)customApiUrls; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAModelService.h b/Classes/OBAModelService.h new file mode 100755 index 0000000..f8ec9e7 --- /dev/null +++ b/Classes/OBAModelService.h @@ -0,0 +1,51 @@ +#import "OBAModelDAO.h" +#import "OBAModelFactory.h" +#import "OBAJsonDataSource.h" +#import "OBALocationManager.h" + +#import "OBAReferencesV2.h" +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol OBAModelServiceRequest +- (void)cancel; +@end + +/** + * This protocol mimics the functionality of UIApplication. It is placed here to get around Extension only API limitation. + */ +@protocol OBABackgroundTaskExecutor +- (UIBackgroundTaskIdentifier) beginBackgroundTaskWithExpirationHandler:(void(^)(void))handler; +- (UIBackgroundTaskIdentifier) endBackgroundTask:(UIBackgroundTaskIdentifier) task; +@end + +@interface OBAModelService : NSObject +@property (nonatomic, strong) OBAReferencesV2 *references; +@property (nonatomic, strong) OBAModelDAO *modelDao; +@property (nonatomic, strong) OBAModelFactory *modelFactory; +@property (nonatomic, strong) OBAJsonDataSource *obaJsonDataSource; +@property (nonatomic, strong) OBAJsonDataSource *obaRegionJsonDataSource; +@property (nonatomic, strong) OBAJsonDataSource *googleMapsJsonDataSource; +@property (nonatomic, strong) OBAJsonDataSource *googlePlacesJsonDataSource; +@property (nonatomic, strong) OBALocationManager *locationManager; + +/** + * Registers a background executor to be used by all services. This method should not be used by extensions. + */ ++(void) addBackgroundExecutor:(NSObject*) executor; + + +/** + * Makes an asynchronous request to fetch all available OBA regions, including experimental and inactive + * + * @param completion The block to be called once the request completes, this is always executed on the main thread. + * + * @return The OBAModelServiceRequest object that allows request cancellation + */ +- (id)requestRegions:(OBADataSourceCompletion)completion; + + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAModelService.m b/Classes/OBAModelService.m new file mode 100755 index 0000000..cdf88d1 --- /dev/null +++ b/Classes/OBAModelService.m @@ -0,0 +1,89 @@ +#import "OBAModelService.h" +#import "OBAModelServiceRequest.h" +#import "OBASphericalGeometryLibrary.h" +#import "OBAURLHelpers.h" +#import "OBAMacros.h" + +static const CLLocationAccuracy kSearchRadius = 400; +static const CLLocationAccuracy kBigSearchRadius = 15000; + +@implementation OBAModelService + +- (id)requestRegions:(OBADataSourceCompletion)completion { + return [self request:self.obaRegionJsonDataSource + url:@"" + args:nil + selector:@selector(getRegionsV2FromJson:error:) + completionBlock:completion + progressBlock:nil]; +} + +- (id)requestAgenciesWithCoverage:(OBADataSourceCompletion)completion { + return [self request:self.obaJsonDataSource + url:@"/api/where/agencies-with-coverage.json" + args:nil + selector:@selector(getAgenciesWithCoverageV2FromJson:error:) + completionBlock:completion + progressBlock:nil]; +} + + +- (OBAModelServiceRequest *)request:(OBAJsonDataSource *)source url:(NSString *)url args:(NSDictionary *)args selector:(SEL)selector completionBlock:(OBADataSourceCompletion)completion progressBlock:(OBADataSourceProgress)progress { + OBAModelServiceRequest *request = [self request:source selector:selector]; + + request.connection = [source requestWithPath:url withArgs:args completionBlock:^(id jsonData, NSUInteger responseCode, NSError *error) { + [request processData:jsonData withError:error responseCode:responseCode completionBlock:completion]; + } progressBlock:progress]; + return request; +} + +- (OBAModelServiceRequest *)request:(OBAJsonDataSource *)source selector:(SEL)selector { + OBAModelServiceRequest *request = [[OBAModelServiceRequest alloc] init]; + + request.modelFactory = _modelFactory; + request.modelFactorySelector = selector; + + if (source != _obaJsonDataSource) { + request.checkCode = NO; + } + + NSObject *executor = [[self class] sharedBackgroundExecutor]; + + if (executor) { + request.bgTask = [executor beginBackgroundTaskWithExpirationHandler:^{ + if(request.cleanupBlock) { + request.cleanupBlock(request.bgTask); + } + }]; + + [request setCleanupBlock:^(UIBackgroundTaskIdentifier identifier) { + return [executor endBackgroundTask:identifier]; + }]; + } + + return request; +} + +- (CLLocation *)currentOrDefaultLocationToSearch { + CLLocation *location = _locationManager.currentLocation; + + if (!location) { + location = _modelDao.mostRecentLocation ?: [[CLLocation alloc] initWithLatitude:47.61229680032385 longitude:-122.3386001586914]; + } + + return location; +} + +#pragma mark - OBABackgroundTaskExecutor + +static NSObject* executor; + ++ (NSObject*)sharedBackgroundExecutor { + return executor; +} + ++ (void)addBackgroundExecutor:(NSObject*)exc { + executor = exc; +} + +@end \ No newline at end of file diff --git a/Classes/OBAModelServiceRequest.h b/Classes/OBAModelServiceRequest.h new file mode 100755 index 0000000..9f99c3b --- /dev/null +++ b/Classes/OBAModelServiceRequest.h @@ -0,0 +1,25 @@ +#import "OBAModelService.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef UIBackgroundTaskIdentifier(^OBABackgroundTaskCleanup)(UIBackgroundTaskIdentifier task); + +@interface OBAModelServiceRequest : NSObject + +@property(strong) OBAModelFactory * modelFactory; +@property(assign) SEL modelFactorySelector; +@property(copy) OBABackgroundTaskCleanup cleanupBlock; + +@property BOOL checkCode; + +@property UIBackgroundTaskIdentifier bgTask; +/** + * This has to be weak to avoid retain cycles between the "Connection" object and this service request. The connection may hold a strong reference + * to this request to perform some post processing on the data. + */ +@property (nonatomic, weak) id connection; + +- (void) processData:(id) obj withError:(NSError *) error responseCode:(NSUInteger) code completionBlock:(OBADataSourceCompletion) completion; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAModelServiceRequest.m b/Classes/OBAModelServiceRequest.m new file mode 100755 index 0000000..1478bcf --- /dev/null +++ b/Classes/OBAModelServiceRequest.m @@ -0,0 +1,78 @@ +#import "OBAModelServiceRequest.h" + +@interface OBAModelServiceRequest () +@property BOOL clean; +- (void)cleanup; +@end + +@implementation OBAModelServiceRequest + +- (id)init { + self = [super init]; + + if (self) { + self.checkCode = YES; + self.bgTask = UIBackgroundTaskInvalid; + self.clean = NO; + } + + return self; +} + +- (void)dealloc { + if(self.cleanupBlock) { + _bgTask = self.cleanupBlock(_bgTask); + }} + +- (void)processData:(id)obj withError:(NSError *)error responseCode:(NSUInteger)code completionBlock:(OBADataSourceCompletion)completion { + NSUInteger responseCode = code; + + if ([obj respondsToSelector:@selector(valueForKey:)]) { + NSNumber *code = [obj valueForKey:@"code"]; + + if (code) { + responseCode = [code unsignedIntegerValue]; + } + +// obj = [obj valueForKey:@"list"]; + } + + NSDictionary *data = obj; + NSError *jsonError = nil; + id result = obj; + + if (_modelFactorySelector && [_modelFactory respondsToSelector:_modelFactorySelector]) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + result = [_modelFactory performSelector:_modelFactorySelector withObject:data withObject:jsonError]; +#pragma clang diagnostic pop + + if (!error) { + error = jsonError; + } + } + + [self cleanup]; + + completion(result, responseCode, error); +} + +#pragma mark OBAModelServiceRequest + +- (void)cancel { + [_connection cancel]; + [self cleanup]; +} + +- (void)cleanup { + if (self.clean) { + return; + } + + self.clean = YES; + if(self.cleanupBlock) { + _bgTask = self.cleanupBlock(_bgTask); + } +} + +@end diff --git a/Classes/OBAPlacemarks.m b/Classes/OBAPlacemarks.m new file mode 100755 index 0000000..9d695e3 --- /dev/null +++ b/Classes/OBAPlacemarks.m @@ -0,0 +1,23 @@ +#import "OBAPlacemarks.h" + + +@implementation OBAPlacemarks + +- (id) init { + self = [super init]; + if( self ) { + _placemarks = [[NSMutableArray alloc] init]; + _attributions = [[NSMutableArray alloc] init]; + } + return self; +} + +- (void) addPlacemark:(OBAPlacemark*)placemark { + [_placemarks addObject:placemark]; +} + +- (void) addAttribution:(NSString*)attribution { + [_attributions addObject:attribution]; +} + +@end diff --git a/Classes/OBAReferencesV2.h b/Classes/OBAReferencesV2.h new file mode 100755 index 0000000..dd16187 --- /dev/null +++ b/Classes/OBAReferencesV2.h @@ -0,0 +1,19 @@ +@import Foundation; +@class OBAAgencyV2; + +NS_ASSUME_NONNULL_BEGIN + +@interface OBAReferencesV2 : NSObject { + NSMutableDictionary * _agencies; +} + +- (void) addAgency:(OBAAgencyV2*)agency; +- (OBAAgencyV2*) getAgencyForId:(NSString*)agencyId; +- (NSDictionary*) getAllAgencies; + + +- (void) clear; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAReferencesV2.m b/Classes/OBAReferencesV2.m new file mode 100755 index 0000000..0c6c473 --- /dev/null +++ b/Classes/OBAReferencesV2.m @@ -0,0 +1,37 @@ +#import "OBAReferencesV2.h" +#import "OBAAgencyV2.h" + +@implementation OBAReferencesV2 + +-(id) init { + self = [super init]; + if( self ) { + _agencies = [[NSMutableDictionary alloc] init]; + } + return self; +} + + +- (void) addAgency:(OBAAgencyV2*)agency { + _agencies[agency.agencyId] = agency; +} + +- (OBAAgencyV2*) getAgencyForId:(NSString*)agencyId { + return _agencies[agencyId]; +} + +- (NSDictionary*) getAllAgencies { + return [NSDictionary dictionaryWithDictionary:_agencies];; +} + +- (void) clear { + [_agencies removeAllObjects]; +} + +- (NSString*) description { + return [NSString stringWithFormat:@"%@ agencies:%lu routes:%lu stops:%lu trips:%lu situations:%lu", + [super description], + (unsigned long)[_agencies count]]; +} + +@end diff --git a/Classes/OBARegionBoundsV2.h b/Classes/OBARegionBoundsV2.h new file mode 100755 index 0000000..027730d --- /dev/null +++ b/Classes/OBARegionBoundsV2.h @@ -0,0 +1,21 @@ +// +// OBARegionBoundsV2.h +// org.onebusaway.iphone +// +// Created by chaya3 on 5/22/13. +// +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface OBARegionBoundsV2 : NSObject + +@property(nonatomic,assign) double lowerLeftLatitude; +@property(nonatomic,assign) double upperRightLatitude; +@property(nonatomic,assign) double lowerLeftLongitude; +@property(nonatomic,assign) double upperRightLongitude; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBARegionBoundsV2.m b/Classes/OBARegionBoundsV2.m new file mode 100755 index 0000000..4929f50 --- /dev/null +++ b/Classes/OBARegionBoundsV2.m @@ -0,0 +1,67 @@ +// +// OBARegionBoundsV2.m +// org.onebusaway.iphone +// +// Created by chaya3 on 5/22/13. +// +// + +#import "OBARegionBoundsV2.h" + +@implementation OBARegionBoundsV2 + +static NSString * kLowerLeftLatitude = @"lowerLeftLatitude"; +static NSString * kUpperRightLatitude = @"upperRightLatitude"; +static NSString * kLowerLeftLongitude = @"lowerLeftLongitude"; +static NSString * kUpperRightLongitude = @"upperRightLongitude"; + +#pragma mark - NSCoder + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super init]; + + if (self) { + self.lowerLeftLatitude = [decoder decodeDoubleForKey:kLowerLeftLatitude]; + self.upperRightLatitude = [decoder decodeDoubleForKey:kUpperRightLatitude]; + self.lowerLeftLongitude = [decoder decodeDoubleForKey:kLowerLeftLongitude]; + self.upperRightLongitude = [decoder decodeDoubleForKey:kUpperRightLongitude]; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)encoder { + [encoder encodeDouble:self.lowerLeftLatitude forKey:kLowerLeftLatitude]; + [encoder encodeDouble:self.upperRightLatitude forKey:kUpperRightLatitude]; + [encoder encodeDouble:self.lowerLeftLongitude forKey:kLowerLeftLongitude]; + [encoder encodeDouble:self.upperRightLongitude forKey:kUpperRightLongitude]; +} + +#pragma mark - Equality + +- (BOOL)isEqual:(id)object { + if (self == object) { + return YES; + } + + if (![object isKindOfClass:self.class]) { + return NO; + } + + return self.lowerLeftLatitude == [object lowerLeftLatitude] && + self.upperRightLatitude == [object upperRightLatitude] && + self.lowerLeftLongitude == [object lowerLeftLongitude] && + self.upperRightLongitude == [object upperRightLongitude]; +} + +- (NSUInteger)hash { + return [[NSString stringWithFormat:@"%f_%f_%f_%f", self.lowerLeftLatitude, self.upperRightLatitude, self.lowerLeftLongitude, self.upperRightLongitude] hash]; +} + +#pragma mark - NSObject + +- (NSString*)description { + return [NSString stringWithFormat:@"<%@: %p> :: {lat: %@ +/- %@ :: lon: %@ +/- %@}", self.class, self, @(self.upperRightLatitude), @(self.lowerLeftLongitude), @(self.upperRightLongitude), @(self.upperRightLongitude)]; +} + +@end diff --git a/Classes/OBARegionHelper.h b/Classes/OBARegionHelper.h new file mode 100644 index 0000000..fc2eaf2 --- /dev/null +++ b/Classes/OBARegionHelper.h @@ -0,0 +1,20 @@ +// +// OBARegionHelper.h +// org.onebusaway.iphone +// +// Created by Sebastian Kießling on 11.08.13. +// Copyright (c) 2013 OneBusAway. All rights reserved. +// + +#import +#import "OBAModelService.h" +#import "OBARegionV2.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBARegionHelper : NSObject +- (void)updateNearestRegion; +- (void)updateRegion; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBARegionHelper.m b/Classes/OBARegionHelper.m new file mode 100644 index 0000000..ba55059 --- /dev/null +++ b/Classes/OBARegionHelper.m @@ -0,0 +1,164 @@ +// +// OBARegionHelper.m +// org.onebusaway.iphone +// +// Created by Sebastian Kießling on 11.08.13. +// Copyright (c) 2013 OneBusAway. All rights reserved. +// + +#import "OBARegionHelper.h" +#import "CycleAtlantaAppDelegate.h" +#import "OBAApplication.h" +#import "OBAMacros.h" +#import "RegionManager.h" + +@interface OBARegionHelper () +@property (nonatomic) NSMutableArray *regions; +@property (nonatomic) CLLocation *location; +@end + +@implementation OBARegionHelper + +- (void)updateNearestRegion { + [self updateRegion]; + OBALocationManager *lm = [OBAApplication sharedApplication].locationManager; + [lm addDelegate:self]; + [lm startUpdatingLocation]; +} + +- (void)updateRegion { + [[OBAApplication sharedApplication].modelService requestRegions:^(id responseData, NSUInteger responseCode, NSError *error) { + if (error && !responseData) { + responseData = [self loadDefaultRegions]; + } + [self processRegionData:responseData]; + }]; +} + +- (OBAListWithRangeAndReferencesV2*)loadDefaultRegions { + + NSLog(@"Unable to retrieve regions file. Loading default regions from the app bundle."); + + OBAModelFactory *factory = [OBAApplication sharedApplication].modelService.modelFactory; + NSError *error = nil; + + NSData *data = [[NSData alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"regions-v3" ofType:@"json"]]; + + if (!data) { + NSLog(@"Unable to load regions from app bundle."); + return nil; + } + + id defaultJSONData = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingOptions)0 error:&error]; + + if (!defaultJSONData) { + NSLog(@"Unable to convert bundled regions into an object. %@", error); + return nil; + } + + OBAListWithRangeAndReferencesV2 *references = [factory getRegionsV2FromJson:defaultJSONData error:&error]; + + if (error) { + NSLog(@"Issue parsing bundled JSON data: %@", error); + } + + return references; +} + +- (void)processRegionData:(id)regionData { + OBAListWithRangeAndReferencesV2 *list = regionData; + + self.regions = [[NSMutableArray alloc] initWithArray:list.values]; + + [RegionManager sharedInstance].allRegions = [NSArray arrayWithArray:self.regions]; + + if ([[RegionManager sharedInstance] isSetRegionAuto] && [OBAApplication sharedApplication].locationManager.locationServicesEnabled) { + [self setNearestRegion]; + } + else { + [self setRegion]; + } +} + +- (void)setNearestRegion { + if (self.regions && self.location) { + + OBALocationManager *lm = [OBAApplication sharedApplication].locationManager; + CLLocation *newLocation = lm.currentLocation; + + NSMutableArray *regionsToRemove = [NSMutableArray array]; + + for (OBARegionV2 *region in self.regions) { + CLLocationDistance distance = [region distanceFromLocation:newLocation]; + + if (distance > 160934) { // 100 miles + [regionsToRemove addObject:region]; + } + } + + [self.regions removeObjectsInArray:regionsToRemove]; + + if (self.regions.count == 0) { + [[RegionManager sharedInstance] saveSetRegionAuto:NO]; + [[OBAApplication sharedApplication].locationManager removeDelegate:self]; + [self showRegionSelectMessage]; + return; + } + + NSString *oldRegion = @"null"; + + if ([OBAApplication sharedApplication].modelDao.region != nil) { + oldRegion = [OBAApplication sharedApplication].modelDao.region.regionName; + } + + [OBAApplication sharedApplication].modelDao.region = self.regions[0]; + [[OBAApplication sharedApplication] refreshSettings]; + [[OBAApplication sharedApplication].locationManager removeDelegate:self]; + [[RegionManager sharedInstance] saveSetRegionAuto:YES]; + } else if (self.location == nil && self.regions != nil){ + [self showRegionSelectMessage]; + } +} + +- (void)setRegion { + NSString *regionName = [[RegionManager sharedInstance] getRegionName]; + + if (regionName) { + for (OBARegionV2 *region in self.regions) { + if ([region.regionName isEqualToString:regionName]) { + [OBAApplication sharedApplication].modelDao.region = region; + break; + } + } + } + else { +// [APP_DELEGATE showRegionListViewController]; + [self showRegionSelectMessage]; + } +} + +#pragma mark OBALocationManagerDelegate Methods + + +- (void)locationManager:(OBALocationManager *)manager didUpdateLocation:(CLLocation *)location { + self.location = [OBAApplication sharedApplication].locationManager.currentLocation; + if ([[RegionManager sharedInstance] isSetRegionAuto]) { + [self setNearestRegion]; + } + +} + +- (void)locationManager:(OBALocationManager *)manager didFailWithError:(NSError *)error { + if (![OBAApplication sharedApplication].modelDao.region) { + [self showRegionSelectMessage]; + } + + [[OBAApplication sharedApplication].locationManager removeDelegate:self]; +} + +- (void) showRegionSelectMessage { + CycleAtlantaAppDelegate *appDelegate = (CycleAtlantaAppDelegate *)[[UIApplication sharedApplication] delegate]; + [appDelegate showRegionSelectMessage]; +} + +@end diff --git a/Classes/OBARegionV2.h b/Classes/OBARegionV2.h new file mode 100755 index 0000000..d324f88 --- /dev/null +++ b/Classes/OBARegionV2.h @@ -0,0 +1,37 @@ +// +// OBARegionV2.h +// org.onebusaway.iphone +// +// Created by chaya3 on 5/22/13. +// +// +@import MapKit; +#import "OBARegionBoundsV2.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBARegionV2 : NSObject +@property(nonatomic,strong) NSString * siriBaseUrl; +@property(nonatomic,strong) NSString * obaVersionInfo; +@property(nonatomic,strong) NSString * language; +@property(nonatomic,strong) NSArray * bounds; +@property(nonatomic,strong) NSString * contactEmail; +@property(nonatomic,strong) NSString * twitterUrl; +@property(nonatomic,strong) NSString * baseUrl; +@property(nonatomic,strong) NSString * facebookUrl; +@property(nonatomic,strong) NSString * regionName; +@property(nonatomic,strong) NSString * tutorialUrl; +@property(nonatomic,assign) BOOL supportsSiriRealtimeApis; +@property(nonatomic,assign) BOOL supportsObaRealtimeApis; +@property(nonatomic,assign) BOOL supportsObaDiscoveryApis; +@property(nonatomic,assign) BOOL active; +@property(nonatomic,assign) BOOL experimental; +@property(nonatomic,assign) NSInteger identifier; + +- (void)addBound:(OBARegionBoundsV2*)bound; +- (CLLocationDistance)distanceFromLocation:(CLLocation*)location; +- (MKMapRect)serviceRect; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBARegionV2.m b/Classes/OBARegionV2.m new file mode 100755 index 0000000..531db85 --- /dev/null +++ b/Classes/OBARegionV2.m @@ -0,0 +1,150 @@ +// +// OBARegionV2.m +// org.onebusaway.iphone +// +// Created by chaya3 on 5/22/13. +// +// + +#import "OBARegionV2.h" +#import "OBARegionBoundsV2.h" +#import "NSArray+OBAAdditions.h" + +static NSString * kSiriBaseUrl = @"siriBaseUrl"; +static NSString * kObaVersionInfo = @"obaVersionInfo"; +static NSString * kSupportsSiriRealtimeApis = @"supportsSiriRealtimeApis"; +static NSString * kLanguage = @"language"; +static NSString * kSupportsObaRealtimeApis = @"supportsObaRealtimeApis"; +static NSString * kBounds = @"bounds"; +static NSString * kSupportsObaDiscoveryApis = @"supportsObaDiscoveryApis"; +static NSString * kContactEmail = @"contactEmail"; +static NSString * kTwitterUrl = @"twitterUrl"; +static NSString * kFacebookUrl = @"facebookUrl"; +static NSString * kActive = @"active"; +static NSString * kExperimental = @"experimental"; +static NSString * kBaseUrl = @"baseUrl"; +static NSString * kIdentifier = @"id_number"; +static NSString * kRegionName = @"regionName"; +static NSString * kTutorialUrl = @"tutorialUrl"; + +@implementation OBARegionV2 + +- (id)init { + self = [super init]; + if (self) { + _bounds = @[]; + } + return self; +} + +#pragma mark - NSCoding + +- (void)encodeWithCoder:(NSCoder *)encoder { + [encoder encodeObject:self.siriBaseUrl forKey:kSiriBaseUrl]; + [encoder encodeObject:self.obaVersionInfo forKey:kObaVersionInfo]; + [encoder encodeBool:self.supportsSiriRealtimeApis forKey:kSupportsSiriRealtimeApis]; + [encoder encodeObject:self.language forKey:kLanguage]; + [encoder encodeBool:self.supportsObaRealtimeApis forKey:kSupportsObaRealtimeApis]; + [encoder encodeObject:self.bounds forKey:kBounds]; + [encoder encodeBool:self.supportsObaDiscoveryApis forKey:kSupportsObaDiscoveryApis]; + [encoder encodeObject:self.contactEmail forKey:kContactEmail]; + [encoder encodeObject:self.twitterUrl forKey:kTwitterUrl]; + [encoder encodeObject:self.facebookUrl forKey:kFacebookUrl]; + [encoder encodeBool:self.active forKey:kActive]; + [encoder encodeBool:self.experimental forKey:kExperimental]; + [encoder encodeObject:self.baseUrl forKey:kBaseUrl]; + [encoder encodeInteger:self.identifier forKey:kIdentifier]; + [encoder encodeObject:self.regionName forKey:kRegionName]; + [encoder encodeObject:self.tutorialUrl forKey:kTutorialUrl]; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super init]; + + if (self) { + _siriBaseUrl = [decoder decodeObjectForKey:kSiriBaseUrl]; + _obaVersionInfo = [decoder decodeObjectForKey:kObaVersionInfo]; + _supportsSiriRealtimeApis = [decoder decodeBoolForKey:kSupportsSiriRealtimeApis]; + _language = [decoder decodeObjectForKey:kLanguage]; + _supportsObaRealtimeApis = [decoder decodeBoolForKey:kSupportsObaRealtimeApis]; + _bounds = [NSArray arrayWithArray:[decoder decodeObjectForKey:kBounds]]; + _supportsObaDiscoveryApis = [decoder decodeBoolForKey:kSupportsObaDiscoveryApis]; + _contactEmail = [decoder decodeObjectForKey:kContactEmail]; + _twitterUrl = [decoder decodeObjectForKey:kTwitterUrl]; + _facebookUrl = [decoder decodeObjectForKey:kFacebookUrl]; + _active = [decoder decodeBoolForKey:kActive]; + _experimental = [decoder decodeBoolForKey:kExperimental]; + _baseUrl = [decoder decodeObjectForKey:kBaseUrl]; + _identifier = [decoder decodeIntegerForKey:kIdentifier]; + _regionName = [decoder decodeObjectForKey:kRegionName]; + _tutorialUrl = [decoder decodeObjectForKey:kTutorialUrl]; + } + + return self; +} + +#pragma mark - Public Methods + +- (void)addBound:(OBARegionBoundsV2*)bound { + self.bounds = [self.bounds arrayByAddingObject:bound]; +} + +- (CLLocationDistance)distanceFromLocation:(CLLocation*)location { + double distance = DBL_MAX; + double lat = location.coordinate.latitude; + double lon = location.coordinate.longitude; + + for (OBARegionBoundsV2 * bound in _bounds) { + + double lon1 = bound.upperRightLongitude * M_PI / 180; + double lon2 = bound.lowerLeftLongitude * M_PI / 180; + + double lat1 = bound.upperRightLatitude * M_PI / 180; + double lat2 = bound.lowerLeftLatitude * M_PI / 180; + + double dLon = lon2 - lon1; + + double x = cos(lat2) * cos(dLon); + double y = cos(lat2) * sin(dLon); + + double lat3 = atan2( sin(lat1) + sin(lat2), sqrt((cos(lat1) + x) * (cos(lat1) + x) + y * y) ); + double lon3 = lon1 + atan2(y, cos(lat1) + x); + + CLLocation *startLocation = [[CLLocation alloc] initWithLatitude:lat3 * 180 / M_PI longitude:lon3 * 180 / M_PI]; + CLLocation *endLocation = [[CLLocation alloc] initWithLatitude:lat longitude:lon]; + double thisDistance = [startLocation distanceFromLocation:endLocation]; + + if (thisDistance < distance) { + distance = thisDistance; + } + } + + return distance; +} + +- (MKMapRect)serviceRect { + double minX = DBL_MAX; + double minY = DBL_MAX; + double maxX = DBL_MIN; + double maxY = DBL_MIN; +// for (OBARegionBoundsV2 *bounds in self.bounds) { +// MKMapPoint a = MKMapPointForCoordinate(CLLocationCoordinate2DMake(bounds.lat + bounds.latSpan / 2, +// bounds.lon - bounds.lonSpan / 2)); +// MKMapPoint b = MKMapPointForCoordinate(CLLocationCoordinate2DMake(bounds.lat - bounds.latSpan / 2, +// bounds.lon + bounds.lonSpan / 2)); +// minX = MIN(minX, MIN(a.x, b.x)); +// minY = MIN(minY, MIN(a.y, b.y)); +// maxX = MAX(maxX, MAX(a.x, b.x)); +// maxY = MAX(maxY, MAX(a.y, b.y)); +// } + return MKMapRectMake(minX, minY, maxX - minX, maxY - minY); +} + +#pragma mark - NSObject + +- (NSString*)description +{ + return [NSString stringWithFormat:@"<%@: %p> :: {%@ - obaBaseUrl: %@, bounds: %@, experimental: %@}", self.class, self, self.regionName, self.baseUrl, self.bounds, self.experimental ? @"YES" : @"NO"]; +} + +@end diff --git a/Classes/OBASelectorJsonDigesterRule.h b/Classes/OBASelectorJsonDigesterRule.h new file mode 100755 index 0000000..14f5cb8 --- /dev/null +++ b/Classes/OBASelectorJsonDigesterRule.h @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAJsonDigester.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSUInteger, OBASelectorJsonDigesterRuleTarget) { + OBASelectorJsonDigesterRuleTargetBefore, + OBASelectorJsonDigesterRuleTargetAfter, +}; + +@interface OBASelectorJsonDigesterRule : NSObject + +/** + Note: the target is not retained by this object. + */ +- (instancetype) initWithTarget:(NSObject*)target selector:(SEL)selector ruleTarget:(OBAJsonDigesterRuleTarget)ruleTarget; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBASelectorJsonDigesterRule.m b/Classes/OBASelectorJsonDigesterRule.m new file mode 100755 index 0000000..7b58f98 --- /dev/null +++ b/Classes/OBASelectorJsonDigesterRule.m @@ -0,0 +1,70 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBASelectorJsonDigesterRule.h" +#import "OBALogger.h" + +@interface OBASelectorJsonDigesterRule() + +@property (nonatomic, weak) NSObject * target; +@property (nonatomic, assign) SEL selector; +@property (nonatomic, assign) OBAJsonDigesterRuleTarget ruleTarget; + +@end + + +@implementation OBASelectorJsonDigesterRule + +- (instancetype) initWithTarget:(id)target selector:(SEL)selector ruleTarget:(OBAJsonDigesterRuleTarget)ruleTarget { + if( self = [super init] ) { + _target = target; + _selector = selector; + _ruleTarget = ruleTarget; + } + return self; +} + +- (void) begin:(id)context name:(NSString*)name value:(id)value { + [self handleRuleTarget:OBAJsonDigesterRuleTargetBegin context:context name:name value:value]; +} + +- (void) end:(id)context name:(NSString*)name value:(id)value { + [self handleRuleTarget:OBAJsonDigesterRuleTargetEnd context:context name:name value:value]; +} + +- (void) handleRuleTarget:(OBAJsonDigesterRuleTarget)ruleTarget context:(id)context name:(NSString*)name value:(id)value { + + if( self.ruleTarget != ruleTarget ) + return; + + NSMethodSignature * methodSig = [self.target methodSignatureForSelector:self.selector]; + + if(!methodSig) { + OBALogSevere(@"selector not found for target object in OBASelectorJSONDigesterRule"); + return; + } + + NSInvocation * invoker = [NSInvocation invocationWithMethodSignature:methodSig]; + [invoker setTarget:self.target]; + [invoker setSelector:self.selector]; + [invoker setArgument:&context atIndex:2]; + [invoker setArgument:&name atIndex:3]; + [invoker setArgument:&value atIndex:4]; + + [invoker invoke]; +} + +@end diff --git a/Classes/OBASetCoordinatePropertyJsonDigesterRule.h b/Classes/OBASetCoordinatePropertyJsonDigesterRule.h new file mode 100755 index 0000000..14325d7 --- /dev/null +++ b/Classes/OBASetCoordinatePropertyJsonDigesterRule.h @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBASetPropertyJsonDigesterRule.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, OBASetCoordinatePropertyMethod) { + OBASetCoordinatePropertyMethodArray, + OBASetCoordinatePropertyMethodLatLon +}; + +@interface OBASetCoordinatePropertyJsonDigesterRule : OBASetPropertyJsonDigesterRule { + OBASetCoordinatePropertyMethod _method; +} + +- (id) initWithPropertyName:(NSString*)propertyName method:(OBASetCoordinatePropertyMethod) method; + +@property (nonatomic,strong) NSString * latJsonName; +@property (nonatomic,strong) NSString * lonJsonName; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBASetCoordinatePropertyJsonDigesterRule.m b/Classes/OBASetCoordinatePropertyJsonDigesterRule.m new file mode 100755 index 0000000..f2982ce --- /dev/null +++ b/Classes/OBASetCoordinatePropertyJsonDigesterRule.m @@ -0,0 +1,92 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@import CoreLocation; +#import "OBASetCoordinatePropertyJsonDigesterRule.h" + +@interface OBASetCoordinatePropertyJsonDigesterRule (Private) + +- (void) arrayMethod:(id)context name:(NSString*)name value:(id)value; +- (void) latLonMethod:(id)context name:(NSString*)name value:(id)value; +- (void) setCoordinate:(id)context name:(NSString*)name lat:(NSNumber*)lat lon:(NSNumber*)lon; + +@end + + +@implementation OBASetCoordinatePropertyJsonDigesterRule + +- (id) initWithPropertyName:(NSString*)propertyName method:(OBASetCoordinatePropertyMethod) method { + self = [super initWithPropertyName:propertyName]; + if( self ) { + _method = method; + self.latJsonName = @"lat"; + self.lonJsonName = @"lon"; + } + return self; +} + + +- (void) begin:(id)context name:(NSString*)name value:(id)value { + + switch(_method) { + case OBASetCoordinatePropertyMethodArray: + [self arrayMethod:context name:name value:value]; + break; + case OBASetCoordinatePropertyMethodLatLon: + [self latLonMethod:context name:name value:value]; + break; + } +} + +@end + +@implementation OBASetCoordinatePropertyJsonDigesterRule (Private) + +- (void) arrayMethod:(id)context name:(NSString*)name value:(id)value { + + if( ! [value isKindOfClass:[NSArray class]] ) + return; + + NSArray * array = (NSArray*)value; + + if( [array count] < 2 ) + return; + + NSNumber * longitude = array[0]; + NSNumber * latitude = array[1]; + + [self setCoordinate:context name:name lat:latitude lon:longitude]; +} + +- (void) latLonMethod:(id)context name:(NSString*)name value:(id)value { + + if( ! [value isKindOfClass:[NSDictionary class]] ) + return; + + NSDictionary * dictionary = (NSDictionary*)value; + + NSNumber * latitude = dictionary[self.latJsonName]; + NSNumber * longitude = dictionary[self.lonJsonName]; + + [self setCoordinate:context name:name lat:latitude lon:longitude]; +} + +- (void) setCoordinate:(id)context name:(NSString*)name lat:(NSNumber*)lat lon:(NSNumber*)lon { + CLLocationCoordinate2D coordinate = {[lat doubleValue], [lon doubleValue]}; + NSValue * v = [NSValue value:&coordinate withObjCType:@encode(CLLocationCoordinate2D)]; + [super begin:context name:name value:v]; +} + +@end diff --git a/Classes/OBASetDatePropertyJsonDigesterRule.h b/Classes/OBASetDatePropertyJsonDigesterRule.h new file mode 100755 index 0000000..661bb8a --- /dev/null +++ b/Classes/OBASetDatePropertyJsonDigesterRule.h @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBASetPropertyJsonDigesterRule.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBASetDatePropertyJsonDigesterRule : OBASetPropertyJsonDigesterRule +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBASetDatePropertyJsonDigesterRule.m b/Classes/OBASetDatePropertyJsonDigesterRule.m new file mode 100755 index 0000000..7deb1e9 --- /dev/null +++ b/Classes/OBASetDatePropertyJsonDigesterRule.m @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBASetDatePropertyJsonDigesterRule.h" + + +@implementation OBASetDatePropertyJsonDigesterRule + +- (void) begin:(id)context name:(NSString*)name value:(id)value { + + if ([value isKindOfClass:[NSNumber class]]) { + NSNumber * n = value; + NSTimeInterval interval = [n longLongValue] / 1000.0; + NSDate * date = [NSDate dateWithTimeIntervalSince1970:interval]; + [super begin:context name:name value:date]; + } +} + +@end \ No newline at end of file diff --git a/Classes/OBASetLocationPropertyJsonDigesterRule.h b/Classes/OBASetLocationPropertyJsonDigesterRule.h new file mode 100755 index 0000000..a2b104e --- /dev/null +++ b/Classes/OBASetLocationPropertyJsonDigesterRule.h @@ -0,0 +1,16 @@ +// +// OBASetLocationPropertyJsonDigesterRule.h +// org.onebusaway.iphone +// +// Created by Brian Ferris on 10/15/09. +// Copyright 2009 __MyCompanyName__. All rights reserved. +// + +#import "OBASetPropertyJsonDigesterRule.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBASetLocationPropertyJsonDigesterRule : OBASetPropertyJsonDigesterRule +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBASetLocationPropertyJsonDigesterRule.m b/Classes/OBASetLocationPropertyJsonDigesterRule.m new file mode 100755 index 0000000..85b283e --- /dev/null +++ b/Classes/OBASetLocationPropertyJsonDigesterRule.m @@ -0,0 +1,29 @@ +// +// OBASetLocationPropertyJsonDigesterRule.m +// org.onebusaway.iphone +// +// Created by Brian Ferris on 10/15/09. +// Copyright 2009 __MyCompanyName__. All rights reserved. +// + +#import "OBASetLocationPropertyJsonDigesterRule.h" +@import CoreLocation; + +@implementation OBASetLocationPropertyJsonDigesterRule + +- (void) begin:(id)context name:(NSString*)name value:(id)value { + + if( ! [value isKindOfClass:[NSDictionary class]] ) + return; + + NSDictionary * dictionary = (NSDictionary*)value; + + NSNumber * latitude = dictionary[@"lat"]; + NSNumber * longitude = dictionary[@"lon"]; + + CLLocation * location = [[CLLocation alloc] initWithLatitude:[latitude doubleValue] longitude:[longitude doubleValue]]; + [super begin:context name:name value:location]; +} + + +@end diff --git a/Classes/OBASetNextOBAJsonDigesterRule.h b/Classes/OBASetNextOBAJsonDigesterRule.h new file mode 100755 index 0000000..9e2c17b --- /dev/null +++ b/Classes/OBASetNextOBAJsonDigesterRule.h @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAJsonDigester.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBASetNextOBAJsonDigesterRule : NSObject { + SEL _selector; + BOOL _onlyIfNotNull; +} + +- (id) initWithSelector:(SEL)selector; + +@property (nonatomic) BOOL onlyIfNotNull; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBASetNextOBAJsonDigesterRule.m b/Classes/OBASetNextOBAJsonDigesterRule.m new file mode 100755 index 0000000..14f7b73 --- /dev/null +++ b/Classes/OBASetNextOBAJsonDigesterRule.m @@ -0,0 +1,56 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBASetNextOBAJsonDigesterRule.h" +#import "OBALogger.h" + + +@implementation OBASetNextOBAJsonDigesterRule + +- (id) initWithSelector:(SEL)selector { + self = [super init]; + if( self ) { + _selector = selector; + _onlyIfNotNull = YES; + } + return self; +} + +- (void) end:(id)context name:(NSString*)name value:(id)value { + + if( _onlyIfNotNull && (value == nil || value == ((id)kCFNull)) ) + return; + + id a = [context peek:0]; + id b = [context peek:1]; + + if (context.verbose) { + OBALogDebug(@"setNext"); + } + + if (a && b && [b respondsToSelector:_selector]) { +// note: I think that silencing warnings like this is gross. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + [b performSelector:_selector withObject:a]; +#pragma clang diagnostic pop + } + else if (context.verbose) { + OBALogDebug(@"setNext selector not supported"); + } +} + +@end diff --git a/Classes/OBASetPropertyJsonDigesterRule.h b/Classes/OBASetPropertyJsonDigesterRule.h new file mode 100755 index 0000000..26a4943 --- /dev/null +++ b/Classes/OBASetPropertyJsonDigesterRule.h @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBAJsonDigester.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBASetPropertyJsonDigesterRule : NSObject { + NSString * _propertyName; + BOOL _onlyIfNeeded; + BOOL _optional; +} + +- (id) initWithPropertyName:(NSString*)propertyName; +- (id) initWithPropertyName:(NSString*)propertyName onlyIfNeeded:(BOOL)onlyIfNeeded; + +@property (nonatomic) BOOL optional; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBASetPropertyJsonDigesterRule.m b/Classes/OBASetPropertyJsonDigesterRule.m new file mode 100755 index 0000000..b723b7b --- /dev/null +++ b/Classes/OBASetPropertyJsonDigesterRule.m @@ -0,0 +1,71 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBASetPropertyJsonDigesterRule.h" + + +@implementation OBASetPropertyJsonDigesterRule + +- (id) initWithPropertyName:(NSString*)propertyName { + self = [super init]; + if( self ) { + if (!(self = [self initWithPropertyName:propertyName onlyIfNeeded:NO])) return nil; + _propertyName = propertyName; + } + return self; +} + +- (id) initWithPropertyName:(NSString*)propertyName onlyIfNeeded:(BOOL)onlyIfNeeded { + self = [super init]; + if( self ) { + _propertyName = propertyName; + _onlyIfNeeded = onlyIfNeeded; + } + return self; + +} + + +- (void) begin:(id)context name:(NSString*)name value:(id)value { + + NSObject * top = [context peek:0]; + + /** + * Due to a bug in iPhone OS 3.0, NSDecimalNumbers sometimes cause errors when used in + * a Core Data entity that is saved to an NSManagedObjectContext. Get around it by + * changing NSDecimalNumbers to just plain NSNumber + * + * https://devforums.apple.com/message/129925#129925 + * http://www.stackoverflow.com/questions/1200591/coredata-error-while-saving-binding-not-implemented-for-this-sqltype-7 + */ + if( [value isKindOfClass:[NSDecimalNumber class]] ) { + NSDecimalNumber * d = value; + value = @([d doubleValue]); + } + + if( _onlyIfNeeded ) { + id existingValue = [top valueForKey:_propertyName]; + if( [existingValue isEqual:value] ) + return; + } + + if( _optional && [value isKindOfClass:[NSString class]] && [value length] == 0) + return; + + [top setValue:value forKey:_propertyName]; +} + +@end diff --git a/Classes/OBASphericalGeometryLibrary.h b/Classes/OBASphericalGeometryLibrary.h new file mode 100755 index 0000000..7aaa5a7 --- /dev/null +++ b/Classes/OBASphericalGeometryLibrary.h @@ -0,0 +1,41 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@import MapKit; +#import "OBACoordinateBounds.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OBASphericalGeometryLibrary : NSObject ++ (CLLocationCoordinate2D) makeCoordinateLat:(CLLocationDegrees)lat lon:(CLLocationDegrees)lon; ++ (MKCoordinateRegion) createRegionWithCenter:(CLLocationCoordinate2D)center latRadius:(double)latRadiusInMeters lonRadius:(double)lonRadiusInMeters; ++ (CLLocationDistance) getDistanceFromRegion:(MKCoordinateRegion)regionA toRegion:(MKCoordinateRegion)regionB; ++ (BOOL) isRegion:(MKCoordinateRegion)regionA containedBy:(MKCoordinateRegion)regionB; ++ (BOOL) isCoordinate:(CLLocationCoordinate2D)coordinate containedBy:(MKCoordinateRegion)region; ++ (NSString*) regionAsString:(MKCoordinateRegion)region; + ++ (NSArray*) decodePolylineString:(NSString*)encodedPolyline; ++ (MKPolyline*) createMKPolylineFromLocations:(NSArray*) locations; ++ (MKPolyline*) decodePolylineStringAsMKPolyline:(NSString*)polylineString; + ++ (NSArray*) subsamplePoints:(NSArray*)points minDistance:(double)minDistance; + ++ (OBACoordinateBounds*) boundsForLocations:(NSArray*)locations; ++ (OBACoordinateBounds*) boundsForMKPolyline:(MKPolyline*)polyline; + ++ (CGFloat)computeStopsForRouteAnnotationScaleFactor:(MKCoordinateRegion)region; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBASphericalGeometryLibrary.m b/Classes/OBASphericalGeometryLibrary.m new file mode 100755 index 0000000..da0b530 --- /dev/null +++ b/Classes/OBASphericalGeometryLibrary.m @@ -0,0 +1,246 @@ +/** + * Copyright (C) 2009 bdferris + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "OBASphericalGeometryLibrary.h" + +static const CGFloat kStopForRouteAnnotationMinScale = 0.1f; +static const CGFloat kStopForRouteAnnotationMaxScaleDistance = 1500.f; +static const CGFloat kStopForRouteAnnotationMinScaleDistance = 8000.f; +static const double kRadiusOfEarthInMeters = 6371.01 * 1000; + +typedef struct { + int number; + int index; +} OBANumberAndIndex; + +@implementation OBASphericalGeometryLibrary + ++ (CLLocationCoordinate2D) makeCoordinateLat:(CLLocationDegrees)lat lon:(CLLocationDegrees)lon { + CLLocationCoordinate2D p; + p.latitude = lat; + p.longitude = lon; + return p; +} + ++ (MKCoordinateRegion) createRegionWithCenter:(CLLocationCoordinate2D)center latRadius:(double)latRadiusInMeters lonRadius:(double)lonRadiusInMeters { + + double latRadians = center.latitude / 180 * M_PI; + + double latRadius = kRadiusOfEarthInMeters; + double lonRadius = cos(latRadians) * kRadiusOfEarthInMeters; + + double latOffset = (latRadiusInMeters / latRadius) * 180 / M_PI; + double lonOffset = (lonRadiusInMeters / lonRadius) * 180 / M_PI; + + MKCoordinateSpan span = MKCoordinateSpanMake(latOffset*2,lonOffset*2); + return MKCoordinateRegionMake(center, span); +} + ++ (CLLocationDistance) getDistanceFromRegion:(MKCoordinateRegion)regionA toRegion:(MKCoordinateRegion)regionB { + CLLocation * a = [[CLLocation alloc] initWithLatitude:regionA.center.latitude longitude:regionA.center.longitude]; + CLLocation * b = [[CLLocation alloc] initWithLatitude:regionB.center.latitude longitude:regionB.center.longitude]; + return [a distanceFromLocation:b]; +} + ++ (BOOL) isRegion:(MKCoordinateRegion)regionA containedBy:(MKCoordinateRegion)regionB { + + CLLocationCoordinate2D pA = regionA.center; + MKCoordinateSpan spanA = regionA.span; + + CLLocationCoordinate2D pB = regionB.center; + MKCoordinateSpan spanB = regionB.span; + + return pB.latitude - spanB.latitudeDelta / 2 <= pA.latitude - spanA.latitudeDelta / 2 && + pA.latitude + spanA.latitudeDelta / 2 <= pB.latitude + spanB.latitudeDelta / 2 && + pB.longitude - spanB.longitudeDelta/2 <= pA.longitude - spanA.longitudeDelta / 2 && + pA.longitude + spanA.longitudeDelta/2 <= pB.longitude + spanB.longitudeDelta / 2; +} + ++ (BOOL) isCoordinate:(CLLocationCoordinate2D)coordinate containedBy:(MKCoordinateRegion)region { + + CLLocationCoordinate2D pR = region.center; + MKCoordinateSpan spanR = region.span; + + return pR.latitude - spanR.latitudeDelta / 2 <= coordinate.latitude && + coordinate.latitude <= pR.latitude + spanR.latitudeDelta / 2 && + pR.longitude - spanR.longitudeDelta/2 <= coordinate.longitude && + coordinate.longitude <= pR.longitude + spanR.longitudeDelta / 2; +} + ++ (NSString*) regionAsString:(MKCoordinateRegion)region { + + CLLocationCoordinate2D pA = region.center; + MKCoordinateSpan spanA = region.span; + + return [NSString stringWithFormat:@"%f %f %f %f", + pA.latitude - spanA.latitudeDelta / 2, + pA.longitude - spanA.longitudeDelta / 2, + pA.latitude + spanA.latitudeDelta / 2, + pA.longitude + spanA.longitudeDelta / 2]; +} + ++ (NSArray*) decodePolylineString:(NSString*)encodedPolyline { + + double lat = 0; + double lon = 0; + + int strIndex = 0; + NSMutableArray * points = [NSMutableArray array]; + + while (strIndex < [encodedPolyline length]) { + + OBANumberAndIndex rLat = [self decodeSignedNumber:encodedPolyline withIndex:strIndex]; + lat = lat + rLat.number * 1e-5; + strIndex = rLat.index; + + OBANumberAndIndex rLon = [self decodeSignedNumber:encodedPolyline withIndex:strIndex]; + lon = lon + rLon.number * 1e-5; + strIndex = rLon.index; + + CLLocation * loc = [[CLLocation alloc] initWithLatitude:lat longitude:lon]; + [points addObject:loc]; + } + + return points; +} + ++ (MKPolyline*) createMKPolylineFromLocations:(NSArray*) locations { + + CLLocationCoordinate2D* pointArr = malloc(sizeof(CLLocationCoordinate2D) * locations.count); + + for (int i=0; i minDistance ) { + [array addObject:location]; + prevLocation = location; + } + } + + return array; +} + ++ (OBACoordinateBounds*) boundsForLocations:(NSArray*)locations { + + OBACoordinateBounds * bounds = [[OBACoordinateBounds alloc] init]; + + for( CLLocation * location in locations) { + CLLocationCoordinate2D p = location.coordinate; + [bounds addLat:p.latitude lon:p.longitude]; + } + + return bounds; +} + ++ (OBACoordinateBounds*) boundsForMKPolyline:(MKPolyline*)polyline { + + OBACoordinateBounds * bounds = [[OBACoordinateBounds alloc] init]; + + MKMapPoint * points = polyline.points; + for( int i=0; i 0) { + sgn_num = ~(sgn_num); + } + r.number = sgn_num >> 1; + return r; +} + ++ (OBANumberAndIndex) decodeNumber:(NSString*)value withIndex:(int)index { + + int num = 0; + int v = 0; + int shift = 0; + + do { + unichar c = [value characterAtIndex:index++]; + v = c - 63; + num |= (v & 0x1f) << shift; + shift += 5; + } while (v >= 0x20); + + OBANumberAndIndex r; + r.number = num; + r.index = index; + return r; +} + +@end + + diff --git a/Classes/OBAURLHelpers.h b/Classes/OBAURLHelpers.h new file mode 100644 index 0000000..187053f --- /dev/null +++ b/Classes/OBAURLHelpers.h @@ -0,0 +1,17 @@ +// +// OBAURLHelpers.h +// org.onebusaway.iphone +// +// Created by Aaron Brethorst on 2/22/15. +// Copyright (c) 2015 OneBusAway. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface OBAURLHelpers : NSObject ++ (NSURL*)normalizeURLPath:(NSString*)path relativeToBaseURL:(NSString*)baseURLString parameters:(NSDictionary* _Nullable)params; +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/Classes/OBAURLHelpers.m b/Classes/OBAURLHelpers.m new file mode 100644 index 0000000..10c666f --- /dev/null +++ b/Classes/OBAURLHelpers.m @@ -0,0 +1,43 @@ +// +// OBAURLHelpers.m +// org.onebusaway.iphone +// +// Created by Aaron Brethorst on 2/22/15. +// Copyright (c) 2015 OneBusAway. All rights reserved. +// + +#import "OBAURLHelpers.h" + +@implementation OBAURLHelpers + ++ (NSURL*)normalizeURLPath:(NSString*)path relativeToBaseURL:(NSString*)baseURLString parameters:(NSDictionary*)params { + + if (![baseURLString hasPrefix:@"http://"] && ![baseURLString hasPrefix:@"https://"]) { + baseURLString = [@"http://" stringByAppendingString:baseURLString]; + } + + NSURLComponents *components = [[NSURLComponents alloc] initWithString:baseURLString]; + + if (components.path.length == 0) { + components.path = @"/api"; + } + else if (![components.path hasSuffix:@"api"] && ![components.path hasSuffix:@"api/"]) { + components.path = [components.path stringByAppendingPathComponent:@"api"]; + } + + components.path = [(components.path ?: @"") stringByAppendingPathComponent:path]; + + if (params.count > 0) { + NSMutableArray *urlQueryItems = [[NSMutableArray alloc] init]; + + for (NSString *key in params) { + [urlQueryItems addObject:[NSURLQueryItem queryItemWithName:key value:params[key]]]; + } + + components.queryItems = urlQueryItems; + } + + return components.URL; +} + +@end diff --git a/Classes/RegionManager.h b/Classes/RegionManager.h new file mode 100644 index 0000000..4c9d482 --- /dev/null +++ b/Classes/RegionManager.h @@ -0,0 +1,24 @@ +// +// RegionManager.h +// Cycle Atlanta +// +// Created by Cagri Cetin on 7/8/16. +// +// + +#import +#import "OBARegionV2.h" + +@interface RegionManager : NSObject + +@property (nonatomic, retain) NSArray *allRegions; +@property(nonatomic, retain) OBARegionV2 *region; + ++ (instancetype)sharedInstance; +- (void) saveSetRegionAuto: (BOOL) isAuto; +- (BOOL) isSetRegionAuto; + +- (void) saveRegionName: (NSString*) regionName; +- (NSString*) getRegionName; + +@end diff --git a/Classes/RegionManager.m b/Classes/RegionManager.m new file mode 100644 index 0000000..5af5368 --- /dev/null +++ b/Classes/RegionManager.m @@ -0,0 +1,52 @@ +// +// RegionManager.m +// Cycle Atlanta +// +// Created by Cagri Cetin on 7/8/16. +// +// + +#import "RegionManager.h" + +@implementation RegionManager + +@synthesize allRegions; +@synthesize region; + ++ (instancetype)sharedInstance +{ + static RegionManager *sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [[RegionManager alloc] init]; + }); + return sharedInstance; +} + +- (void) saveSetRegionAuto:(BOOL)isAuto { + NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults]; + [preferences setBool:isAuto forKey:@"setRegionAuto"]; + [preferences synchronize]; +} + +- (BOOL) isSetRegionAuto { + NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults]; + NSString *currentLevelKey = @"setRegionAuto"; + if ([preferences objectForKey:currentLevelKey] == nil) { + return YES; + } + else { + return [preferences boolForKey:currentLevelKey]; + } +} + +- (void) saveRegionName:(NSString *)regionName { + [[NSUserDefaults standardUserDefaults] setObject:regionName forKey:@"regionName"]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +- (NSString*) getRegionName { + return [[NSUserDefaults standardUserDefaults] stringForKey:@"regionName"]; +} + +@end diff --git a/Classes/SaveRequest.m b/Classes/SaveRequest.m index 9cb58af..ae7ae34 100644 --- a/Classes/SaveRequest.m +++ b/Classes/SaveRequest.m @@ -41,6 +41,7 @@ #import "CycleAtlantaAppDelegate.h" #import "SaveRequest.h" #import "ZipUtil.h" +#import "OBAApplication.h" @implementation SaveRequest @@ -52,9 +53,10 @@ @implementation SaveRequest { if (self = [super init]) { + NSString* url = [OBAApplication sharedApplication].modelDao.region.baseUrl; // create request. self.request = [[NSMutableURLRequest alloc] init]; - [request setURL:[NSURL URLWithString:kSaveURL]]; + [request setURL:[NSURL URLWithString:url]]; [request setHTTPMethod:@"POST"]; // Nab the unique device id hash from our delegate. @@ -135,7 +137,7 @@ @implementation SaveRequest NSData *postBodyDataZipped = [ZipUtil gzipDeflate:originalData]; NSLog(@"Initializing HTTP POST request to %@ of size %lu, orig size %lu", - kSaveURL, (unsigned long)[postBodyDataZipped length], (unsigned long)[originalData length]); + url, (unsigned long)[postBodyDataZipped length], (unsigned long)[originalData length]); [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[postBodyDataZipped length]] forHTTPHeaderField:@"Content-Length"]; //set the POST body diff --git a/Cycle Atlanta-Bridging-Header.h b/Cycle Atlanta-Bridging-Header.h index f355b38..32778c9 100644 --- a/Cycle Atlanta-Bridging-Header.h +++ b/Cycle Atlanta-Bridging-Header.h @@ -6,4 +6,6 @@ #import "ALToastView.h" #import "FetchUser.h" #import "TripManager.h" -#import "User.h" \ No newline at end of file +#import "User.h" +#import "OBAApplication.h" +#import "RegionManager.h" \ No newline at end of file diff --git a/Cycle Atlanta-Info.plist b/Cycle Atlanta-Info.plist index 68b6c41..03fcdf9 100644 --- a/Cycle Atlanta-Info.plist +++ b/Cycle Atlanta-Info.plist @@ -15,7 +15,7 @@ CFBundleIcons~ipad CFBundleIdentifier - edu.gatech.ppl.cycleatlanta + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Cycle Atlanta.xcodeproj/project.pbxproj b/Cycle Atlanta.xcodeproj/project.pbxproj index a3d8ac4..8f8c4b4 100644 --- a/Cycle Atlanta.xcodeproj/project.pbxproj +++ b/Cycle Atlanta.xcodeproj/project.pbxproj @@ -11,8 +11,43 @@ 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; + 26109E061D00837F006EADB9 /* OBALocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 26109E051D00837F006EADB9 /* OBALocationManager.m */; }; + 26109E091D0083B9006EADB9 /* OBAListWithRangeAndReferencesV2.m in Sources */ = {isa = PBXBuildFile; fileRef = 26109E081D0083B9006EADB9 /* OBAListWithRangeAndReferencesV2.m */; }; + 26109E0C1D0083E1006EADB9 /* OBAHasReferencesV2.m in Sources */ = {isa = PBXBuildFile; fileRef = 26109E0B1D0083E1006EADB9 /* OBAHasReferencesV2.m */; }; + 26109E111D00843F006EADB9 /* OBAReferencesV2.m in Sources */ = {isa = PBXBuildFile; fileRef = 26109E101D00843F006EADB9 /* OBAReferencesV2.m */; }; + 26109E141D00845C006EADB9 /* OBAAgencyV2.m in Sources */ = {isa = PBXBuildFile; fileRef = 26109E131D00845C006EADB9 /* OBAAgencyV2.m */; }; + 2658517E1D3039A500C1304D /* RegionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2658517D1D3039A500C1304D /* RegionManager.m */; }; + 2684F4CE1CDA4A9F00BEC015 /* NSArray+OBAAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4CD1CDA4A9F00BEC015 /* NSArray+OBAAdditions.m */; }; + 2684F4D31CDA4E4900BEC015 /* OBARegionBoundsV2.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4D01CDA4E4900BEC015 /* OBARegionBoundsV2.m */; }; + 2684F4D41CDA4E4900BEC015 /* OBARegionV2.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4D21CDA4E4900BEC015 /* OBARegionV2.m */; }; + 2684F4D71CDA508900BEC015 /* OBARegionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4D61CDA508900BEC015 /* OBARegionHelper.m */; }; + 2684F4DA1CDA51C900BEC015 /* OBAApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4D91CDA51C900BEC015 /* OBAApplication.m */; }; + 2684F4E11CDA546800BEC015 /* OBAModelDAO.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4DD1CDA546800BEC015 /* OBAModelDAO.m */; }; + 2684F4E21CDA546800BEC015 /* OBAModelDAOUserPreferencesImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4DF1CDA546800BEC015 /* OBAModelDAOUserPreferencesImpl.m */; }; + 2684F4EA1CDA61E300BEC015 /* OBACommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4E51CDA61E300BEC015 /* OBACommon.m */; }; + 2684F4EB1CDA61E300BEC015 /* OBADateHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4E81CDA61E300BEC015 /* OBADateHelpers.m */; }; + 2684F4EE1CDA61F200BEC015 /* OBALogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4ED1CDA61F200BEC015 /* OBALogger.m */; }; + 2684F4FD1CDA626A00BEC015 /* JsonUrlFetcherImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4F11CDA626A00BEC015 /* JsonUrlFetcherImpl.m */; }; + 2684F4FE1CDA626A00BEC015 /* OBADataSourceConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4F41CDA626A00BEC015 /* OBADataSourceConfig.m */; }; + 2684F4FF1CDA626A00BEC015 /* OBAJsonDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4F61CDA626A00BEC015 /* OBAJsonDataSource.m */; }; + 2684F5001CDA626A00BEC015 /* OBAModelFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4F81CDA626A00BEC015 /* OBAModelFactory.m */; }; + 2684F5011CDA626A00BEC015 /* OBAModelService.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4FA1CDA626A00BEC015 /* OBAModelService.m */; }; + 2684F5021CDA626A00BEC015 /* OBAModelServiceRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2684F4FC1CDA626A00BEC015 /* OBAModelServiceRequest.m */; }; + 26DF6AE91D0090E600804F15 /* OBACallMethodJsonDigesterRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6AD81D0090E600804F15 /* OBACallMethodJsonDigesterRule.m */; }; + 26DF6AEA1D0090E600804F15 /* OBACreateObjectJsonDigesterRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6ADA1D0090E600804F15 /* OBACreateObjectJsonDigesterRule.m */; }; + 26DF6AEB1D0090E600804F15 /* OBAJsonDigester.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6ADC1D0090E600804F15 /* OBAJsonDigester.m */; }; + 26DF6AEC1D0090E600804F15 /* OBASelectorJsonDigesterRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6ADE1D0090E600804F15 /* OBASelectorJsonDigesterRule.m */; }; + 26DF6AED1D0090E600804F15 /* OBASetCoordinatePropertyJsonDigesterRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6AE01D0090E600804F15 /* OBASetCoordinatePropertyJsonDigesterRule.m */; }; + 26DF6AEE1D0090E600804F15 /* OBASetDatePropertyJsonDigesterRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6AE21D0090E600804F15 /* OBASetDatePropertyJsonDigesterRule.m */; }; + 26DF6AEF1D0090E600804F15 /* OBASetLocationPropertyJsonDigesterRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6AE41D0090E600804F15 /* OBASetLocationPropertyJsonDigesterRule.m */; }; + 26DF6AF01D0090E600804F15 /* OBASetNextOBAJsonDigesterRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6AE61D0090E600804F15 /* OBASetNextOBAJsonDigesterRule.m */; }; + 26DF6AF11D0090E600804F15 /* OBASetPropertyJsonDigesterRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6AE81D0090E600804F15 /* OBASetPropertyJsonDigesterRule.m */; }; + 26DF6AF51D0091F400804F15 /* OBASphericalGeometryLibrary.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6AF41D0091F400804F15 /* OBASphericalGeometryLibrary.m */; }; + 26DF6AF81D00921E00804F15 /* OBACoordinateBounds.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6AF71D00921E00804F15 /* OBACoordinateBounds.m */; }; + 26DF6AFB1D00924A00804F15 /* OBAURLHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 26DF6AFA1D00924A00804F15 /* OBAURLHelpers.m */; }; 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 28D801B40F44B63D00FB423F /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28D801B30F44B63D00FB423F /* CoreData.framework */; }; + 59D481A3C4C16131F6BA9FAA /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26FB1F198383A8C7975E1BC4 /* Pods.framework */; }; 6411996210683D7500C201F0 /* RecordTripViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6411996110683D7500C201F0 /* RecordTripViewController.m */; }; 6411996D10683DCD00C201F0 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6411996C10683DCD00C201F0 /* CoreLocation.framework */; }; 64119AAD1068672100C201F0 /* CustomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 64119AAA1068672100C201F0 /* CustomView.m */; }; @@ -126,10 +161,85 @@ 1D3623250D0F684500981E51 /* CycleAtlantaAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CycleAtlantaAppDelegate.m; sourceTree = ""; }; 1D6058910D05DD3D006BFB54 /* Cycle Atlanta.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Cycle Atlanta.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 26109E041D00837F006EADB9 /* OBALocationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBALocationManager.h; sourceTree = ""; }; + 26109E051D00837F006EADB9 /* OBALocationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBALocationManager.m; sourceTree = ""; }; + 26109E071D0083B9006EADB9 /* OBAListWithRangeAndReferencesV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAListWithRangeAndReferencesV2.h; sourceTree = ""; }; + 26109E081D0083B9006EADB9 /* OBAListWithRangeAndReferencesV2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAListWithRangeAndReferencesV2.m; sourceTree = ""; }; + 26109E0A1D0083E1006EADB9 /* OBAHasReferencesV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAHasReferencesV2.h; sourceTree = ""; }; + 26109E0B1D0083E1006EADB9 /* OBAHasReferencesV2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAHasReferencesV2.m; sourceTree = ""; }; + 26109E0E1D008406006EADB9 /* OBAReferencesV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAReferencesV2.h; sourceTree = ""; }; + 26109E101D00843F006EADB9 /* OBAReferencesV2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAReferencesV2.m; sourceTree = ""; }; + 26109E121D00845C006EADB9 /* OBAAgencyV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAAgencyV2.h; sourceTree = ""; }; + 26109E131D00845C006EADB9 /* OBAAgencyV2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAAgencyV2.m; sourceTree = ""; }; + 2658517C1D3039A500C1304D /* RegionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegionManager.h; sourceTree = ""; }; + 2658517D1D3039A500C1304D /* RegionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegionManager.m; sourceTree = ""; }; + 2684F4CC1CDA4A9F00BEC015 /* NSArray+OBAAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+OBAAdditions.h"; sourceTree = ""; }; + 2684F4CD1CDA4A9F00BEC015 /* NSArray+OBAAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+OBAAdditions.m"; sourceTree = ""; }; + 2684F4CF1CDA4E4900BEC015 /* OBARegionBoundsV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBARegionBoundsV2.h; sourceTree = ""; }; + 2684F4D01CDA4E4900BEC015 /* OBARegionBoundsV2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBARegionBoundsV2.m; sourceTree = ""; }; + 2684F4D11CDA4E4900BEC015 /* OBARegionV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBARegionV2.h; sourceTree = ""; }; + 2684F4D21CDA4E4900BEC015 /* OBARegionV2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBARegionV2.m; sourceTree = ""; }; + 2684F4D51CDA508900BEC015 /* OBARegionHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBARegionHelper.h; sourceTree = ""; }; + 2684F4D61CDA508900BEC015 /* OBARegionHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBARegionHelper.m; sourceTree = ""; }; + 2684F4D81CDA51C900BEC015 /* OBAApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAApplication.h; sourceTree = ""; }; + 2684F4D91CDA51C900BEC015 /* OBAApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAApplication.m; sourceTree = ""; }; + 2684F4DC1CDA546800BEC015 /* OBAModelDAO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAModelDAO.h; sourceTree = ""; }; + 2684F4DD1CDA546800BEC015 /* OBAModelDAO.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAModelDAO.m; sourceTree = ""; }; + 2684F4DE1CDA546800BEC015 /* OBAModelDAOUserPreferencesImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAModelDAOUserPreferencesImpl.h; sourceTree = ""; }; + 2684F4DF1CDA546800BEC015 /* OBAModelDAOUserPreferencesImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAModelDAOUserPreferencesImpl.m; sourceTree = ""; }; + 2684F4E01CDA546800BEC015 /* OBAModelPersistenceLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAModelPersistenceLayer.h; sourceTree = ""; }; + 2684F4E41CDA61E300BEC015 /* OBACommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBACommon.h; sourceTree = ""; }; + 2684F4E51CDA61E300BEC015 /* OBACommon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBACommon.m; sourceTree = ""; }; + 2684F4E61CDA61E300BEC015 /* OBACommonV1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBACommonV1.h; sourceTree = ""; }; + 2684F4E71CDA61E300BEC015 /* OBADateHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBADateHelpers.h; sourceTree = ""; }; + 2684F4E81CDA61E300BEC015 /* OBADateHelpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBADateHelpers.m; sourceTree = ""; }; + 2684F4E91CDA61E300BEC015 /* OBAImageHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAImageHelpers.h; sourceTree = ""; }; + 2684F4EC1CDA61F200BEC015 /* OBALogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBALogger.h; sourceTree = ""; }; + 2684F4ED1CDA61F200BEC015 /* OBALogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBALogger.m; sourceTree = ""; }; + 2684F4F01CDA626A00BEC015 /* JsonUrlFetcherImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JsonUrlFetcherImpl.h; sourceTree = ""; }; + 2684F4F11CDA626A00BEC015 /* JsonUrlFetcherImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JsonUrlFetcherImpl.m; sourceTree = ""; }; + 2684F4F21CDA626A00BEC015 /* OBADataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBADataSource.h; sourceTree = ""; }; + 2684F4F31CDA626A00BEC015 /* OBADataSourceConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBADataSourceConfig.h; sourceTree = ""; }; + 2684F4F41CDA626A00BEC015 /* OBADataSourceConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBADataSourceConfig.m; sourceTree = ""; }; + 2684F4F51CDA626A00BEC015 /* OBAJsonDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAJsonDataSource.h; sourceTree = ""; }; + 2684F4F61CDA626A00BEC015 /* OBAJsonDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAJsonDataSource.m; sourceTree = ""; }; + 2684F4F71CDA626A00BEC015 /* OBAModelFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAModelFactory.h; sourceTree = ""; }; + 2684F4F81CDA626A00BEC015 /* OBAModelFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAModelFactory.m; sourceTree = ""; }; + 2684F4F91CDA626A00BEC015 /* OBAModelService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAModelService.h; sourceTree = ""; }; + 2684F4FA1CDA626A00BEC015 /* OBAModelService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAModelService.m; sourceTree = ""; }; + 2684F4FB1CDA626A00BEC015 /* OBAModelServiceRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAModelServiceRequest.h; sourceTree = ""; }; + 2684F4FC1CDA626A00BEC015 /* OBAModelServiceRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAModelServiceRequest.m; sourceTree = ""; }; + 26DF6AD71D0090E600804F15 /* OBACallMethodJsonDigesterRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBACallMethodJsonDigesterRule.h; sourceTree = ""; }; + 26DF6AD81D0090E600804F15 /* OBACallMethodJsonDigesterRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBACallMethodJsonDigesterRule.m; sourceTree = ""; }; + 26DF6AD91D0090E600804F15 /* OBACreateObjectJsonDigesterRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBACreateObjectJsonDigesterRule.h; sourceTree = ""; }; + 26DF6ADA1D0090E600804F15 /* OBACreateObjectJsonDigesterRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBACreateObjectJsonDigesterRule.m; sourceTree = ""; }; + 26DF6ADB1D0090E600804F15 /* OBAJsonDigester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAJsonDigester.h; sourceTree = ""; }; + 26DF6ADC1D0090E600804F15 /* OBAJsonDigester.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAJsonDigester.m; sourceTree = ""; }; + 26DF6ADD1D0090E600804F15 /* OBASelectorJsonDigesterRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBASelectorJsonDigesterRule.h; sourceTree = ""; }; + 26DF6ADE1D0090E600804F15 /* OBASelectorJsonDigesterRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBASelectorJsonDigesterRule.m; sourceTree = ""; }; + 26DF6ADF1D0090E600804F15 /* OBASetCoordinatePropertyJsonDigesterRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBASetCoordinatePropertyJsonDigesterRule.h; sourceTree = ""; }; + 26DF6AE01D0090E600804F15 /* OBASetCoordinatePropertyJsonDigesterRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBASetCoordinatePropertyJsonDigesterRule.m; sourceTree = ""; }; + 26DF6AE11D0090E600804F15 /* OBASetDatePropertyJsonDigesterRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBASetDatePropertyJsonDigesterRule.h; sourceTree = ""; }; + 26DF6AE21D0090E600804F15 /* OBASetDatePropertyJsonDigesterRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBASetDatePropertyJsonDigesterRule.m; sourceTree = ""; }; + 26DF6AE31D0090E600804F15 /* OBASetLocationPropertyJsonDigesterRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBASetLocationPropertyJsonDigesterRule.h; sourceTree = ""; }; + 26DF6AE41D0090E600804F15 /* OBASetLocationPropertyJsonDigesterRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBASetLocationPropertyJsonDigesterRule.m; sourceTree = ""; }; + 26DF6AE51D0090E600804F15 /* OBASetNextOBAJsonDigesterRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBASetNextOBAJsonDigesterRule.h; sourceTree = ""; }; + 26DF6AE61D0090E600804F15 /* OBASetNextOBAJsonDigesterRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBASetNextOBAJsonDigesterRule.m; sourceTree = ""; }; + 26DF6AE71D0090E600804F15 /* OBASetPropertyJsonDigesterRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBASetPropertyJsonDigesterRule.h; sourceTree = ""; }; + 26DF6AE81D0090E600804F15 /* OBASetPropertyJsonDigesterRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBASetPropertyJsonDigesterRule.m; sourceTree = ""; }; + 26DF6AF31D0091F400804F15 /* OBASphericalGeometryLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBASphericalGeometryLibrary.h; sourceTree = ""; }; + 26DF6AF41D0091F400804F15 /* OBASphericalGeometryLibrary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBASphericalGeometryLibrary.m; sourceTree = ""; }; + 26DF6AF61D00921E00804F15 /* OBACoordinateBounds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBACoordinateBounds.h; sourceTree = ""; }; + 26DF6AF71D00921E00804F15 /* OBACoordinateBounds.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBACoordinateBounds.m; sourceTree = ""; }; + 26DF6AF91D00924A00804F15 /* OBAURLHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAURLHelpers.h; sourceTree = ""; }; + 26DF6AFA1D00924A00804F15 /* OBAURLHelpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAURLHelpers.m; sourceTree = ""; }; + 26DF6AFC1D00926900804F15 /* OBAMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OBAMacros.h; sourceTree = ""; }; + 26FB1F198383A8C7975E1BC4 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 28D801B30F44B63D00FB423F /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 32CA4F630368D1EE00C91783 /* Cycle Atlanta_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Cycle Atlanta_Prefix.pch"; path = "../Cycle Atlanta_Prefix.pch"; sourceTree = ""; }; + 60EAEA52A4414B9B982F60AB /* Pods.distribution.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.distribution.xcconfig; path = "Pods/Target Support Files/Pods/Pods.distribution.xcconfig"; sourceTree = ""; }; 6411996010683D7500C201F0 /* RecordTripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RecordTripViewController.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 6411996110683D7500C201F0 /* RecordTripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = RecordTripViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 6411996C10683DCD00C201F0 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; @@ -166,7 +276,9 @@ 64F823E0106AC151001413F8 /* SaveRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SaveRequest.m; sourceTree = ""; }; 64F824E4106AFFA4001413F8 /* PersonalInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PersonalInfoViewController.h; sourceTree = ""; }; 64F824E5106AFFA4001413F8 /* PersonalInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PersonalInfoViewController.m; sourceTree = ""; }; + 89BFB741B7EBC7CB12909BF1 /* Pods.release beta.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods.release beta.xcconfig"; path = "Pods/Target Support Files/Pods/Pods.release beta.xcconfig"; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Cycle Atlanta-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Cycle Atlanta-Info.plist"; path = "../Cycle Atlanta-Info.plist"; sourceTree = ""; }; + 8E8208B45C32300EBD3D28E2 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; 8F1B1D3D164B94C60022B776 /* DetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailViewController.h; sourceTree = ""; }; 8F1B1D3E164B94C60022B776 /* DetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DetailViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 8F20B0A916F0F08A00031712 /* TripDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TripDetailViewController.h; sourceTree = ""; }; @@ -270,6 +382,7 @@ C261D63E19E753DD002E1B2D /* GlobalVars.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlobalVars.h; sourceTree = ""; }; C2A1189419F5ADFB003C65E4 /* ALToastView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ALToastView.h; sourceTree = ""; }; C2A1189519F5ADFB003C65E4 /* ALToastView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ALToastView.m; sourceTree = ""; }; + C5101F7522144449BF5C7B34 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; D6B6941A1923F2A8006908C3 /* MainWindow.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainWindow.storyboard; sourceTree = ""; }; D6DBCE03196B2B66007BE9C3 /* NoteToDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoteToDetailViewController.h; sourceTree = ""; }; D6DBCE04196B2B66007BE9C3 /* NoteToDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NoteToDetailViewController.m; sourceTree = ""; }; @@ -277,6 +390,7 @@ D6EF02FE192BCFAB00AA67CD /* SaveButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SaveButton@2x.png"; sourceTree = ""; }; D6EF0301192BED5100AA67CD /* StartButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = StartButton.png; sourceTree = ""; }; D6EF0302192BED5100AA67CD /* StartButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StartButton@2x.png"; sourceTree = ""; }; + F5532E87744C724F7D9543B3 /* Pods.beta.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.beta.xcconfig; path = "Pods/Target Support Files/Pods/Pods.beta.xcconfig"; sourceTree = ""; }; FB1ACCE91C10C7A7003C5CAA /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = "Cycle Atlanta/Images.xcassets"; sourceTree = ""; }; FBE4EAA61BE17F68007C1AF2 /* Cycle Atlanta-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Cycle Atlanta-Bridging-Header.h"; sourceTree = ""; }; FBE4EAA71BE17F68007C1AF2 /* SavedTripsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SavedTripsViewController.swift; path = Classes/SavedTripsViewController.swift; sourceTree = ""; }; @@ -303,6 +417,7 @@ 642F151C1071D9DD0050BCB9 /* MapKit.framework in Frameworks */, 642647FD107435A200E43DEF /* AudioToolbox.framework in Frameworks */, 64ED1621112F364200E617E1 /* QuartzCore.framework in Frameworks */, + 59D481A3C4C16131F6BA9FAA /* Pods.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -312,6 +427,7 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( + 2684F4CA1CDA48FB00BEC015 /* Regions */, C2A1189419F5ADFB003C65E4 /* ALToastView.h */, C2A1189519F5ADFB003C65E4 /* ALToastView.m */, D6DBCE08196B2CA7007BE9C3 /* Tools */, @@ -364,6 +480,142 @@ name = Products; sourceTree = ""; }; + 26109E031D008354006EADB9 /* Manager */ = { + isa = PBXGroup; + children = ( + 26109E041D00837F006EADB9 /* OBALocationManager.h */, + 26109E051D00837F006EADB9 /* OBALocationManager.m */, + ); + name = Manager; + sourceTree = ""; + }; + 2684F4CA1CDA48FB00BEC015 /* Regions */ = { + isa = PBXGroup; + children = ( + 26DF6AF21D0091EA00804F15 /* Location */, + 26109E031D008354006EADB9 /* Manager */, + 2684F4EF1CDA624400BEC015 /* Services */, + 2684F4E31CDA61D800BEC015 /* Helpers */, + 2684F4DB1CDA545B00BEC015 /* Dao */, + 2684F4CB1CDA4A4400BEC015 /* Model */, + 2684F4D81CDA51C900BEC015 /* OBAApplication.h */, + 2684F4D91CDA51C900BEC015 /* OBAApplication.m */, + 2684F4D51CDA508900BEC015 /* OBARegionHelper.h */, + 2684F4D61CDA508900BEC015 /* OBARegionHelper.m */, + 2658517C1D3039A500C1304D /* RegionManager.h */, + 2658517D1D3039A500C1304D /* RegionManager.m */, + ); + name = Regions; + sourceTree = ""; + }; + 2684F4CB1CDA4A4400BEC015 /* Model */ = { + isa = PBXGroup; + children = ( + 26DF6AD61D0090D500804F15 /* Json */, + 26DF6AF61D00921E00804F15 /* OBACoordinateBounds.h */, + 26DF6AF71D00921E00804F15 /* OBACoordinateBounds.m */, + 26109E121D00845C006EADB9 /* OBAAgencyV2.h */, + 26109E131D00845C006EADB9 /* OBAAgencyV2.m */, + 26109E101D00843F006EADB9 /* OBAReferencesV2.m */, + 26109E0E1D008406006EADB9 /* OBAReferencesV2.h */, + 26109E0A1D0083E1006EADB9 /* OBAHasReferencesV2.h */, + 26109E0B1D0083E1006EADB9 /* OBAHasReferencesV2.m */, + 26109E071D0083B9006EADB9 /* OBAListWithRangeAndReferencesV2.h */, + 26109E081D0083B9006EADB9 /* OBAListWithRangeAndReferencesV2.m */, + 2684F4CF1CDA4E4900BEC015 /* OBARegionBoundsV2.h */, + 2684F4D01CDA4E4900BEC015 /* OBARegionBoundsV2.m */, + 2684F4D11CDA4E4900BEC015 /* OBARegionV2.h */, + 2684F4D21CDA4E4900BEC015 /* OBARegionV2.m */, + 2684F4CC1CDA4A9F00BEC015 /* NSArray+OBAAdditions.h */, + 2684F4CD1CDA4A9F00BEC015 /* NSArray+OBAAdditions.m */, + ); + name = Model; + sourceTree = ""; + }; + 2684F4DB1CDA545B00BEC015 /* Dao */ = { + isa = PBXGroup; + children = ( + 2684F4DC1CDA546800BEC015 /* OBAModelDAO.h */, + 2684F4DD1CDA546800BEC015 /* OBAModelDAO.m */, + 2684F4DE1CDA546800BEC015 /* OBAModelDAOUserPreferencesImpl.h */, + 2684F4DF1CDA546800BEC015 /* OBAModelDAOUserPreferencesImpl.m */, + 2684F4E01CDA546800BEC015 /* OBAModelPersistenceLayer.h */, + ); + name = Dao; + sourceTree = ""; + }; + 2684F4E31CDA61D800BEC015 /* Helpers */ = { + isa = PBXGroup; + children = ( + 26DF6AF91D00924A00804F15 /* OBAURLHelpers.h */, + 26DF6AFA1D00924A00804F15 /* OBAURLHelpers.m */, + 2684F4EC1CDA61F200BEC015 /* OBALogger.h */, + 2684F4ED1CDA61F200BEC015 /* OBALogger.m */, + 2684F4E41CDA61E300BEC015 /* OBACommon.h */, + 2684F4E51CDA61E300BEC015 /* OBACommon.m */, + 2684F4E61CDA61E300BEC015 /* OBACommonV1.h */, + 26DF6AFC1D00926900804F15 /* OBAMacros.h */, + 2684F4E71CDA61E300BEC015 /* OBADateHelpers.h */, + 2684F4E81CDA61E300BEC015 /* OBADateHelpers.m */, + 2684F4E91CDA61E300BEC015 /* OBAImageHelpers.h */, + ); + name = Helpers; + sourceTree = ""; + }; + 2684F4EF1CDA624400BEC015 /* Services */ = { + isa = PBXGroup; + children = ( + 2684F4F01CDA626A00BEC015 /* JsonUrlFetcherImpl.h */, + 2684F4F11CDA626A00BEC015 /* JsonUrlFetcherImpl.m */, + 2684F4F21CDA626A00BEC015 /* OBADataSource.h */, + 2684F4F31CDA626A00BEC015 /* OBADataSourceConfig.h */, + 2684F4F41CDA626A00BEC015 /* OBADataSourceConfig.m */, + 2684F4F51CDA626A00BEC015 /* OBAJsonDataSource.h */, + 2684F4F61CDA626A00BEC015 /* OBAJsonDataSource.m */, + 2684F4F71CDA626A00BEC015 /* OBAModelFactory.h */, + 2684F4F81CDA626A00BEC015 /* OBAModelFactory.m */, + 2684F4F91CDA626A00BEC015 /* OBAModelService.h */, + 2684F4FA1CDA626A00BEC015 /* OBAModelService.m */, + 2684F4FB1CDA626A00BEC015 /* OBAModelServiceRequest.h */, + 2684F4FC1CDA626A00BEC015 /* OBAModelServiceRequest.m */, + ); + name = Services; + sourceTree = ""; + }; + 26DF6AD61D0090D500804F15 /* Json */ = { + isa = PBXGroup; + children = ( + 26DF6AD71D0090E600804F15 /* OBACallMethodJsonDigesterRule.h */, + 26DF6AD81D0090E600804F15 /* OBACallMethodJsonDigesterRule.m */, + 26DF6AD91D0090E600804F15 /* OBACreateObjectJsonDigesterRule.h */, + 26DF6ADA1D0090E600804F15 /* OBACreateObjectJsonDigesterRule.m */, + 26DF6ADB1D0090E600804F15 /* OBAJsonDigester.h */, + 26DF6ADC1D0090E600804F15 /* OBAJsonDigester.m */, + 26DF6ADD1D0090E600804F15 /* OBASelectorJsonDigesterRule.h */, + 26DF6ADE1D0090E600804F15 /* OBASelectorJsonDigesterRule.m */, + 26DF6ADF1D0090E600804F15 /* OBASetCoordinatePropertyJsonDigesterRule.h */, + 26DF6AE01D0090E600804F15 /* OBASetCoordinatePropertyJsonDigesterRule.m */, + 26DF6AE11D0090E600804F15 /* OBASetDatePropertyJsonDigesterRule.h */, + 26DF6AE21D0090E600804F15 /* OBASetDatePropertyJsonDigesterRule.m */, + 26DF6AE31D0090E600804F15 /* OBASetLocationPropertyJsonDigesterRule.h */, + 26DF6AE41D0090E600804F15 /* OBASetLocationPropertyJsonDigesterRule.m */, + 26DF6AE51D0090E600804F15 /* OBASetNextOBAJsonDigesterRule.h */, + 26DF6AE61D0090E600804F15 /* OBASetNextOBAJsonDigesterRule.m */, + 26DF6AE71D0090E600804F15 /* OBASetPropertyJsonDigesterRule.h */, + 26DF6AE81D0090E600804F15 /* OBASetPropertyJsonDigesterRule.m */, + ); + name = Json; + sourceTree = ""; + }; + 26DF6AF21D0091EA00804F15 /* Location */ = { + isa = PBXGroup; + children = ( + 26DF6AF31D0091F400804F15 /* OBASphericalGeometryLibrary.h */, + 26DF6AF41D0091F400804F15 /* OBASphericalGeometryLibrary.m */, + ); + name = Location; + sourceTree = ""; + }; 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( @@ -378,6 +630,7 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */, 19C28FACFE9D520D11CA2CBB /* Products */, FBE4EAA61BE17F68007C1AF2 /* Cycle Atlanta-Bridging-Header.h */, + C1728DCBE071EF85D03D5C44 /* Pods */, ); name = CustomTemplate; sourceTree = ""; @@ -423,6 +676,7 @@ 288765A40DF7441C002DB57D /* CoreGraphics.framework */, 28D801B30F44B63D00FB423F /* CoreData.framework */, 64ED1620112F364200E617E1 /* QuartzCore.framework */, + 26FB1F198383A8C7975E1BC4 /* Pods.framework */, ); name = Frameworks; sourceTree = ""; @@ -544,6 +798,18 @@ path = "Ressources/TabBarIcons V2"; sourceTree = ""; }; + C1728DCBE071EF85D03D5C44 /* Pods */ = { + isa = PBXGroup; + children = ( + C5101F7522144449BF5C7B34 /* Pods.debug.xcconfig */, + F5532E87744C724F7D9543B3 /* Pods.beta.xcconfig */, + 8E8208B45C32300EBD3D28E2 /* Pods.release.xcconfig */, + 89BFB741B7EBC7CB12909BF1 /* Pods.release beta.xcconfig */, + 60EAEA52A4414B9B982F60AB /* Pods.distribution.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; D6DBCE06196B2BF0007BE9C3 /* MagnetNotes */ = { isa = PBXGroup; children = ( @@ -619,9 +885,12 @@ isa = PBXNativeTarget; buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Cycle Atlanta" */; buildPhases = ( + 505FB18E17FD5B821818F620 /* Check Pods Manifest.lock */, 1D60588D0D05DD3D006BFB54 /* Resources */, 1D60588E0D05DD3D006BFB54 /* Sources */, 1D60588F0D05DD3D006BFB54 /* Frameworks */, + F0ABE17A47275EDF9A6CBA06 /* Embed Pods Frameworks */, + 8CB0E6A1F7F08CAFB7DDF5E4 /* Copy Pods Resources */, ); buildRules = ( ); @@ -639,7 +908,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0510; + LastUpgradeCheck = 0730; TargetAttributes = { 1D6058900D05DD3D006BFB54 = { DevelopmentTeam = LECSLW6UDQ; @@ -732,6 +1001,54 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 505FB18E17FD5B821818F620 /* 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; + }; + 8CB0E6A1F7F08CAFB7DDF5E4 /* 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; + }; + F0ABE17A47275EDF9A6CBA06 /* Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 1D60588E0D05DD3D006BFB54 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -739,42 +1056,76 @@ files = ( FBE4EAAC1BE4082C007C1AF2 /* SavedTripsViewController.m in Sources */, 9D3056F5174412F40091B214 /* YLBackgroundView.m in Sources */, + 26DF6AF01D0090E600804F15 /* OBASetNextOBAJsonDigesterRule.m in Sources */, 9D3056F017440BC00091B214 /* YLProgressBar.m in Sources */, 1D60589B0D05DD56006BFB54 /* main.m in Sources */, + 26DF6AEC1D0090E600804F15 /* OBASelectorJsonDigesterRule.m in Sources */, + 2684F4DA1CDA51C900BEC015 /* OBAApplication.m in Sources */, + 26109E141D00845C006EADB9 /* OBAAgencyV2.m in Sources */, 1D3623260D0F684500981E51 /* CycleAtlantaAppDelegate.m in Sources */, + 26DF6AF81D00921E00804F15 /* OBACoordinateBounds.m in Sources */, 6411996210683D7500C201F0 /* RecordTripViewController.m in Sources */, 64119AAD1068672100C201F0 /* CustomView.m in Sources */, + 26109E091D0083B9006EADB9 /* OBAListWithRangeAndReferencesV2.m in Sources */, + 26109E061D00837F006EADB9 /* OBALocationManager.m in Sources */, + 2684F4EE1CDA61F200BEC015 /* OBALogger.m in Sources */, 64119AAE1068672100C201F0 /* CustomPickerDataSource.m in Sources */, + 2684F4FD1CDA626A00BEC015 /* JsonUrlFetcherImpl.m in Sources */, 64119F041069ACF800C201F0 /* TripManager.m in Sources */, + 26109E0C1D0083E1006EADB9 /* OBAHasReferencesV2.m in Sources */, 64F823E1106AC151001413F8 /* SaveRequest.m in Sources */, 642F15271071DA700050BCB9 /* MapViewController.m in Sources */, 642F161D1071ED1C0050BCB9 /* MapCoord.m in Sources */, 6426476E1073FEC300E43DEF /* ReminderManager.m in Sources */, D6DBCE05196B2B66007BE9C3 /* NoteToDetailViewController.m in Sources */, + 26DF6AEE1D0090E600804F15 /* OBASetDatePropertyJsonDigesterRule.m in Sources */, + 2684F5011CDA626A00BEC015 /* OBAModelService.m in Sources */, + 26DF6AE91D0090E600804F15 /* OBACallMethodJsonDigesterRule.m in Sources */, 64210F6111350C8500415F1A /* AboutViewController.m in Sources */, + 26DF6AED1D0090E600804F15 /* OBASetCoordinatePropertyJsonDigesterRule.m in Sources */, + 2684F4E21CDA546800BEC015 /* OBAModelDAOUserPreferencesImpl.m in Sources */, + 2684F4EA1CDA61E300BEC015 /* OBACommon.m in Sources */, BAF7B46B19CBBAB800056E5B /* SelectViewController.m in Sources */, 645E4EDC1200C1C800EFF0E6 /* LoadingView.m in Sources */, 8F5E60661602CBE000D8F85D /* NSString+MD5Addition.m in Sources */, + 26DF6AEB1D0090E600804F15 /* OBAJsonDigester.m in Sources */, 8F5E60671602CBE000D8F85D /* UIDevice+IdentifierAddition.m in Sources */, 8F1B1D3F164B94C60022B776 /* DetailViewController.m in Sources */, 9D504DA116B6CF4000B99EBC /* ZipUtil.m in Sources */, + 2684F4EB1CDA61E300BEC015 /* OBADateHelpers.m in Sources */, + 2684F4CE1CDA4A9F00BEC015 /* NSArray+OBAAdditions.m in Sources */, + 26DF6AEF1D0090E600804F15 /* OBASetLocationPropertyJsonDigesterRule.m in Sources */, + 2684F4E11CDA546800BEC015 /* OBAModelDAO.m in Sources */, 8FA0AD9416BB4ED800E0E7C4 /* CycleAtlanta.xcdatamodeld in Sources */, 8FB7C20D16C55EB9001A8A48 /* NoteManager.m in Sources */, 8F9C086416DC9479003EA308 /* Note.m in Sources */, 8F9C086716DC9479003EA308 /* Trip.m in Sources */, 8F9C086A16DC947A003EA308 /* User.m in Sources */, + 26DF6AFB1D00924A00804F15 /* OBAURLHelpers.m in Sources */, 8F9C086D16DC947A003EA308 /* Coord.m in Sources */, + 2658517E1D3039A500C1304D /* RegionManager.m in Sources */, + 2684F4FE1CDA626A00BEC015 /* OBADataSourceConfig.m in Sources */, 8FBCD3CA16E0E58100C11EBE /* NoteViewController.m in Sources */, 8F25EC7916E13E7C004263D4 /* SavedNotesViewController.m in Sources */, 8F20B0AC16F0F08A00031712 /* TripDetailViewController.m in Sources */, 8FAD930516F189EE00082B6F /* UIImageViewResizable.m in Sources */, 9DD65FBB16FEA3CC00F2EB63 /* ImageResize.m in Sources */, + 2684F4D41CDA4E4900BEC015 /* OBARegionV2.m in Sources */, C2A1189619F5ADFB003C65E4 /* ALToastView.m in Sources */, FBE4EAB01BE40CEA007C1AF2 /* PersonalInfoViewController.swift in Sources */, 8F316F671703161E0087529E /* Model.xcmappingmodel in Sources */, 9D8A1BAF171B03E000509FBD /* FetchUser.m in Sources */, + 26DF6AF11D0090E600804F15 /* OBASetPropertyJsonDigesterRule.m in Sources */, + 2684F4D71CDA508900BEC015 /* OBARegionHelper.m in Sources */, 9D8A1BB2171B03E900509FBD /* FetchTripData.m in Sources */, 9D4B4EE61722B8B0005A4CDD /* ProgressView.m in Sources */, + 2684F4FF1CDA626A00BEC015 /* OBAJsonDataSource.m in Sources */, + 26DF6AF51D0091F400804F15 /* OBASphericalGeometryLibrary.m in Sources */, + 26109E111D00843F006EADB9 /* OBAReferencesV2.m in Sources */, + 26DF6AEA1D0090E600804F15 /* OBACreateObjectJsonDigesterRule.m in Sources */, + 2684F4D31CDA4E4900BEC015 /* OBARegionBoundsV2.m in Sources */, + 2684F5021CDA626A00BEC015 /* OBAModelServiceRequest.m in Sources */, + 2684F5001CDA626A00BEC015 /* OBAModelFactory.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -783,6 +1134,7 @@ /* Begin XCBuildConfiguration section */ 1D6058940D05DD3E006BFB54 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = C5101F7522144449BF5C7B34 /* Pods.debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -802,6 +1154,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Cycle Atlanta-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = edu.gatech.ppl.cycleatlanta; PRODUCT_NAME = "Cycle Atlanta"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; @@ -812,6 +1165,7 @@ }; 1D6058950D05DD3E006BFB54 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8E8208B45C32300EBD3D28E2 /* Pods.release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -829,6 +1183,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Cycle Atlanta-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = edu.gatech.ppl.cycleatlanta; PRODUCT_NAME = "Cycle Atlanta"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; @@ -845,11 +1200,13 @@ GCC_WARN_UNUSED_VARIABLE = YES; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "7682DFBF-AE70-4C0B-AED0-DC1BBCD2D87F"; SDKROOT = iphoneos; + SWIFT_OBJC_BRIDGING_HEADER = ""; }; name = Distribution; }; 64577E11106DB5D8003ACBFD /* Distribution */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 60EAEA52A4414B9B982F60AB /* Pods.distribution.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -867,6 +1224,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Cycle Atlanta-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = edu.gatech.ppl.cycleatlanta; PRODUCT_NAME = "Cycle Atlanta"; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; @@ -885,11 +1243,13 @@ GCC_WARN_UNUSED_VARIABLE = YES; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "7682DFBF-AE70-4C0B-AED0-DC1BBCD2D87F"; SDKROOT = iphoneos; + SWIFT_OBJC_BRIDGING_HEADER = ""; }; name = Beta; }; 64577E13106DB5E6003ACBFD /* Beta */ = { isa = XCBuildConfiguration; + baseConfigurationReference = F5532E87744C724F7D9543B3 /* Pods.beta.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -910,6 +1270,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Cycle Atlanta-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = edu.gatech.ppl.cycleatlanta; PRODUCT_NAME = "Cycle Atlanta"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; @@ -928,11 +1289,13 @@ GCC_WARN_UNUSED_VARIABLE = YES; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "7682DFBF-AE70-4C0B-AED0-DC1BBCD2D87F"; SDKROOT = iphoneos; + SWIFT_OBJC_BRIDGING_HEADER = ""; }; name = "Release Beta"; }; 64D31CDA108E80E400D52130 /* Release Beta */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 89BFB741B7EBC7CB12909BF1 /* Pods.release beta.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -951,6 +1314,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Cycle Atlanta-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = edu.gatech.ppl.cycleatlanta; PRODUCT_NAME = "Cycle Atlanta"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; @@ -962,12 +1326,14 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Georgia Tech Research Corporation (LECSLW6UDQ)"; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = c99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "7682DFBF-AE70-4C0B-AED0-DC1BBCD2D87F"; SDKROOT = iphoneos; + SWIFT_OBJC_BRIDGING_HEADER = ""; }; name = Debug; }; @@ -980,6 +1346,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "7682DFBF-AE70-4C0B-AED0-DC1BBCD2D87F"; SDKROOT = iphoneos; + SWIFT_OBJC_BRIDGING_HEADER = ""; }; name = Release; }; diff --git a/Cycle Atlanta.xcworkspace/contents.xcworkspacedata b/Cycle Atlanta.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..54c5918 --- /dev/null +++ b/Cycle Atlanta.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/MainWindow.storyboard b/MainWindow.storyboard index 827926c..9491070 100644 --- a/MainWindow.storyboard +++ b/MainWindow.storyboard @@ -1,7 +1,7 @@ - + - + @@ -796,7 +796,7 @@ - + @@ -848,7 +848,7 @@ - + @@ -876,12 +876,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -905,7 +947,7 @@ - + @@ -929,7 +971,7 @@ - + @@ -953,7 +995,7 @@ - + @@ -977,7 +1019,7 @@ - + @@ -1005,7 +1047,7 @@ - + @@ -1029,7 +1071,7 @@ - + @@ -1053,7 +1095,7 @@ - + @@ -1081,7 +1123,7 @@ - + @@ -1109,7 +1151,7 @@ - + @@ -1137,7 +1179,7 @@ - + @@ -1165,7 +1207,7 @@ - + @@ -1190,7 +1232,7 @@ - + @@ -1231,7 +1273,10 @@ + + + diff --git a/PersonalInfoViewController.swift b/PersonalInfoViewController.swift index 69a69fb..ac9ffcb 100644 --- a/PersonalInfoViewController.swift +++ b/PersonalInfoViewController.swift @@ -1,4 +1,4 @@ -// + // // PersonalInfoViewController.swift // Cycle Atlanta // @@ -11,6 +11,8 @@ import CoreData class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, UIPickerViewDelegate, UITextFieldDelegate { + var areViewsHidden = false; + var managedObjectContext : NSManagedObjectContext? var fetchUser : FetchUser? var user : User? @@ -23,6 +25,7 @@ class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, var cycleFreqChoice: [String] = ["", "Less than once a month", "Several times per month", "Several times per week", "Daily"] var riderTypeChoice: [String] = ["", "Strong & fearless", "Enthused & confident", "Comfortable, but cautious", "Interested, but concerned"] var riderHistoryChoice: [String] = ["", "Since childhood", "Several years", "One year or less", "Just trying it out / just started"] + var regionsChoice: [String] = [""]; // List of lists for brevity and readability elsewhere. var pickerLists: [UITextField] = [] @@ -36,6 +39,8 @@ class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, var pickerDataSource: [String] = [] var pickerTarget: UITextField? = nil + + @IBOutlet weak var regions: UITextField! @IBOutlet weak var userAge: UITextField! @IBOutlet weak var userEmail: UITextField! @IBOutlet weak var userGender: UITextField! @@ -48,7 +53,8 @@ class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, @IBOutlet weak var userRiderType: UITextField! @IBOutlet weak var userRiderHistory: UITextField! @IBOutlet weak var userMagnetometer: UISwitch! - + @IBOutlet weak var regionSave: UIView! + @IBOutlet weak var saveRegionButton: UIButton! required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) @@ -60,7 +66,9 @@ class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, } @IBAction func OpenInstructions(sender: AnyObject) { - UIApplication.sharedApplication().openURL(NSURL(string: "http://cycleatlanta.org/instructions-v2")!) + let region = OBAApplication.sharedApplication().modelDao.region; + let tutorialUrl = region?.tutorialUrl; + UIApplication.sharedApplication().openURL(NSURL(string: tutorialUrl ?? "http://cycleatlanta.org/instructions-v2")!) } @IBAction func AttemptRedownload(sender: AnyObject) { @@ -82,10 +90,14 @@ class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, override func viewDidLoad() { super.viewDidLoad() + hideViews(); + let appDelegate = UIApplication.sharedApplication().delegate as! CycleAtlantaAppDelegate managedObjectContext = appDelegate.managedObjectContext + + loadRegions(); - pickerLists = [userAge, userGender, userEthnicity, userIncome, userCycleFreq, userRiderType, userRiderHistory] + pickerLists = [userAge, userGender, userEthnicity, userIncome, userCycleFreq, userRiderType, userRiderHistory, regions] textFields = [userEmail, userZipHome, userZipWork, userZipSchool] for pickerList in pickerLists { @@ -93,12 +105,38 @@ class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, pickerList.inputAccessoryView = pickerToolbar } - pickerDataSource = genderChoice - pickerTarget = userGender + pickerDataSource = regionsChoice + pickerTarget = regions fetchUser = FetchUser() } + func setHideViews() -> Void { + areViewsHidden = true; + } + + func hideViews() -> Void { + if !areViewsHidden { + regionSave.hidden = true; + } + } + + @IBAction func onButtonClick(sender: AnyObject) { + saveUser(); + self.dismissViewControllerAnimated(true, completion: {}); + } + + func loadRegions() -> Void { + let regionsArr = RegionManager.sharedInstance().allRegions; + + for reg in regionsArr as! [OBARegionV2] { + regionsChoice.append(reg.regionName); + } + + let obaApp = OBAApplication.sharedApplication(); + regions.text = obaApp.modelDao.region?.regionName; + } + override func viewWillAppear(animated: Bool) { let request = NSFetchRequest() if let moc = managedObjectContext { @@ -167,6 +205,7 @@ class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, case userCycleFreq: pickerDataSource = cycleFreqChoice case userRiderType: pickerDataSource = riderTypeChoice case userRiderHistory: pickerDataSource = riderHistoryChoice + case regions: pickerDataSource = regionsChoice default: pickerDataSource = ageChoice } @@ -222,6 +261,7 @@ class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, func loadUser() { // Loads user from data model to view controller. if let u = user { + userAge.text = loadListField(ageChoice, field: u.age) userEmail.text = u.email userGender.text = loadListField(genderChoice, field: u.gender) @@ -255,6 +295,20 @@ class PersonalInfoViewController: UITableViewController, UIPickerViewDataSource, u.rider_type = riderTypeChoice.indexOf(userRiderType.text!) u.rider_history = riderHistoryChoice.indexOf(userRiderHistory.text!) + let regionManager = RegionManager.sharedInstance(); + regionManager.saveRegionName(regions.text); + regionManager.saveSetRegionAuto(false); + let obaApp = OBAApplication.sharedApplication(); + let regionArr = regionManager.allRegions; + + for reg in regionArr as! [OBARegionV2] { + if reg.regionName == regions.text{ + obaApp.modelDao.region = reg; + } + } + + + do { try managedObjectContext?.save() } catch let error as NSError { diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..89718f3 --- /dev/null +++ b/Podfile @@ -0,0 +1,4 @@ +use_frameworks! + +source 'https://github.com/CocoaPods/Specs.git' +pod 'PromiseKit' \ No newline at end of file diff --git a/Pods/Headers/Private/OMGHTTPURLRQ/OMGFormURLEncode.h b/Pods/Headers/Private/OMGHTTPURLRQ/OMGFormURLEncode.h new file mode 120000 index 0000000..8271dc4 --- /dev/null +++ b/Pods/Headers/Private/OMGHTTPURLRQ/OMGFormURLEncode.h @@ -0,0 +1 @@ +../../../OMGHTTPURLRQ/Sources/OMGFormURLEncode.h \ No newline at end of file diff --git a/Pods/Headers/Private/OMGHTTPURLRQ/OMGHTTPURLRQ.h b/Pods/Headers/Private/OMGHTTPURLRQ/OMGHTTPURLRQ.h new file mode 120000 index 0000000..e0cf7ca --- /dev/null +++ b/Pods/Headers/Private/OMGHTTPURLRQ/OMGHTTPURLRQ.h @@ -0,0 +1 @@ +../../../OMGHTTPURLRQ/Sources/OMGHTTPURLRQ.h \ No newline at end of file diff --git a/Pods/Headers/Private/OMGHTTPURLRQ/OMGUserAgent.h b/Pods/Headers/Private/OMGHTTPURLRQ/OMGUserAgent.h new file mode 120000 index 0000000..682de9a --- /dev/null +++ b/Pods/Headers/Private/OMGHTTPURLRQ/OMGUserAgent.h @@ -0,0 +1 @@ +../../../OMGHTTPURLRQ/Sources/OMGUserAgent.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/AnyPromise.h b/Pods/Headers/Private/PromiseKit/AnyPromise.h new file mode 120000 index 0000000..61ce91e --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/AnyPromise.h @@ -0,0 +1 @@ +../../../PromiseKit/Sources/AnyPromise.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/CALayer+AnyPromise.h b/Pods/Headers/Private/PromiseKit/CALayer+AnyPromise.h new file mode 120000 index 0000000..831485e --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/CALayer+AnyPromise.h @@ -0,0 +1 @@ +../../../PromiseKit/Categories/QuartzCore/CALayer+AnyPromise.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/NSError+Cancellation.h b/Pods/Headers/Private/PromiseKit/NSError+Cancellation.h new file mode 120000 index 0000000..7312b04 --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/NSError+Cancellation.h @@ -0,0 +1 @@ +../../../PromiseKit/Sources/NSError+Cancellation.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/NSNotificationCenter+AnyPromise.h b/Pods/Headers/Private/PromiseKit/NSNotificationCenter+AnyPromise.h new file mode 120000 index 0000000..2890a33 --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/NSNotificationCenter+AnyPromise.h @@ -0,0 +1 @@ +../../../PromiseKit/Categories/Foundation/NSNotificationCenter+AnyPromise.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/NSURLConnection+AnyPromise.h b/Pods/Headers/Private/PromiseKit/NSURLConnection+AnyPromise.h new file mode 120000 index 0000000..fd8271b --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/NSURLConnection+AnyPromise.h @@ -0,0 +1 @@ +../../../PromiseKit/Categories/Foundation/NSURLConnection+AnyPromise.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/PromiseKit.h b/Pods/Headers/Private/PromiseKit/PromiseKit.h new file mode 120000 index 0000000..c941a07 --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/PromiseKit.h @@ -0,0 +1 @@ +../../../PromiseKit/Sources/PromiseKit.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/UIActionSheet+AnyPromise.h b/Pods/Headers/Private/PromiseKit/UIActionSheet+AnyPromise.h new file mode 120000 index 0000000..981d4ad --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/UIActionSheet+AnyPromise.h @@ -0,0 +1 @@ +../../../PromiseKit/Categories/UIKit/UIActionSheet+AnyPromise.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/UIAlertView+AnyPromise.h b/Pods/Headers/Private/PromiseKit/UIAlertView+AnyPromise.h new file mode 120000 index 0000000..01b78aa --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/UIAlertView+AnyPromise.h @@ -0,0 +1 @@ +../../../PromiseKit/Categories/UIKit/UIAlertView+AnyPromise.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/UIView+AnyPromise.h b/Pods/Headers/Private/PromiseKit/UIView+AnyPromise.h new file mode 120000 index 0000000..98b020a --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/UIView+AnyPromise.h @@ -0,0 +1 @@ +../../../PromiseKit/Categories/UIKit/UIView+AnyPromise.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/UIViewController+AnyPromise.h b/Pods/Headers/Private/PromiseKit/UIViewController+AnyPromise.h new file mode 120000 index 0000000..3414608 --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/UIViewController+AnyPromise.h @@ -0,0 +1 @@ +../../../PromiseKit/Categories/UIKit/UIViewController+AnyPromise.h \ No newline at end of file diff --git a/Pods/Headers/Private/PromiseKit/Umbrella.h b/Pods/Headers/Private/PromiseKit/Umbrella.h new file mode 120000 index 0000000..ac97619 --- /dev/null +++ b/Pods/Headers/Private/PromiseKit/Umbrella.h @@ -0,0 +1 @@ +../../../PromiseKit/Sources/Umbrella.h \ No newline at end of file diff --git a/Pods/OMGHTTPURLRQ/README.markdown b/Pods/OMGHTTPURLRQ/README.markdown new file mode 100644 index 0000000..1cd7125 --- /dev/null +++ b/Pods/OMGHTTPURLRQ/README.markdown @@ -0,0 +1,145 @@ +# OMGHTTPURLRQ + +Vital extensions to `NSURLRequest` that Apple left out for some reason. + +```objc +NSMutableURLRequest *rq = [OMGHTTPURLRQ GET:@"http://api.com":@{@"key": @"value"}]; + +// application/x-www-form-urlencoded +NSMutableURLRequest *rq = [OMGHTTPURLRQ POST:@"http://api.com":@{@"key": @"value"}]; + +// application/json +NSMutableURLRequest *rq = [OMGHTTPURLRQ POST:@"http://api.com" JSON:@{@"key": @"value"}]; + +// PUT +NSMutableURLRequest *rq = [OMGHTTPURLRQ PUT:@"http://api.com":@{@"key": @"value"}]; + +// DELETE +NSMutableURLRequest *rq = [OMGHTTPURLRQ DELETE:@"http://api.com":@{@"key": @"value"}]; +``` + +You can then pass these to an `NSURLConnection` or `NSURLSession`. + + +## `multipart/form-data` + +OMG! Constructing multipart/form-data for POST requests is complicated, let us do it for you: + +```objc + +OMGMultipartFormData *multipartFormData = [OMGMultipartFormData new]; + +NSData *data1 = [NSData dataWithContentsOfFile:@"myimage1.png"]; +[multipartFormData addFile:data1 parameterName:@"file1" filename:@"myimage1.png" contentType:@"image/png"]; + +// Ideally you would not want to re-encode the PNG, but often it is +// tricky to avoid it. +UIImage *image2 = [UIImage imageNamed:@"image2"]; +NSData *data2 = UIImagePNGRepresentation(image2); +[multipartFormData addFile:data2 parameterName:@"file2" filename:@"myimage2.png" contentType:@"image/png"]; + +// SUPER Ideally you would not want to re-encode the JPEG as the process +// is lossy. If your image comes from the AssetLibrary you *CAN* get the +// original `NSData`. See stackoverflow.com. +UIImage *image3 = [UIImage imageNamed:@"image3"]; +NSData *data3 = UIImageJPEGRepresentation(image3); +[multipartFormData addFile:data3 parameterName:@"file2" filename:@"myimage3.jpeg" contentType:@"image/jpeg"]; + +NSMutableURLRequest *rq = [OMGHTTPURLRQ POST:url:multipartFormData]; +``` + +Now feed `rq` to `[NSURLConnection sendSynchronousRequest:returningResponse:error:`. + + +## Configuring an `NSURLSessionUploadTask` + +If you need to use `NSURLSession`’s `uploadTask:` but you have become frustrated because your endpoint expects a multipart/form-data POST request and `NSURLSession` sends the data *raw*, use this: + +```objc +id config = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:someID]; +id session = [NSURLSession sessionWithConfiguration:config delegate:someObject delegateQueue:[NSOperationQueue new]]; + +OMGMultipartFormData *multipartFormData = [OMGMultipartFormData new]; +[multipartFormData addFile:data parameterName:@"file" filename:nil contentType:nil]; + +NSURLRequest *rq = [OMGHTTPURLRQ POST:urlString:multipartFormData]; + +id path = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"upload.NSData"]; +[rq.HTTPBody writeToFile:path atomically:YES]; + +[[session uploadTaskWithRequest:rq fromFile:[NSURL fileURLWithPath:path]] resume]; +``` + + +## OMGUserAgent + +If you just need a sensible UserAgent string for your application you can `pod OMGHTTPURLRQ/UserAgent` and then: + +```objc +#import + +NSString *userAgent = OMGUserAgent(); +``` + +OMGHTTPURLRQ adds this User-Agent to all requests it generates automatically. + +So for URLRequests generated **other** than by OMGHTTPURLRQ you would do: + +```objc +[someURLRequest addValue:OMGUserAgent() forHTTPHeaderField:@"User-Agent"]; +``` + + +# Twitter Reverse Auth + +You need an OAuth library, here we use the [TDOAuth](https://github.com/tweetdeck/TDOAuth) pod. You also need +your API keys that registering at https://dev.twitter.com will provide +you. + +```objc +NSMutableURLRequest *rq = [TDOAuth URLRequestForPath:@"/oauth/request_token" POSTParameters:@{@"x_auth_mode" : @"reverse_auth"} host:@"api.twitter.com" consumerKey:APIKey consumerSecret:APISecret accessToken:nil tokenSecret:nil]; +[rq addValue:OMGUserAgent() forHTTPHeaderField:@"User-Agent"]; + +[NSURLConnection sendAsynchronousRequest:rq queue:nil completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { + id oauth = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + SLRequest *reverseAuth = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/oauth/access_token"] parameters:@{ + @"x_reverse_auth_target": APIKey, + @"x_reverse_auth_parameters": oauth + }]; + reverseAuth.account = account; + [reverseAuth performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *urlResponse, NSError *error) { + id creds = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + id credsDict = [NSMutableDictionary new]; + for (__strong id pair in [creds componentsSeparatedByString:@"&"]) { + pair = [pair componentsSeparatedByString:@"="]; + credsDict[pair[0]] = pair[1]; + } + NSLog(@"%@", credsDict); + }]; +}]; +``` + + +# License + +``` +Copyright 2014 Max Howell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` diff --git a/Pods/OMGHTTPURLRQ/Sources/OMGFormURLEncode.h b/Pods/OMGHTTPURLRQ/Sources/OMGFormURLEncode.h new file mode 100644 index 0000000..994c564 --- /dev/null +++ b/Pods/OMGHTTPURLRQ/Sources/OMGFormURLEncode.h @@ -0,0 +1,22 @@ +#import +#import +#import + +#if __has_feature(nullability) && defined(NS_ASSUME_NONNULL_BEGIN) +NS_ASSUME_NONNULL_BEGIN +#endif + +/** + Express this dictionary as a `application/x-www-form-urlencoded` string. + + Most users would recognize the result of this transformation as the query + string in a browser bar. For our purposes it is the query string in a GET + request and the HTTP body for POST, PUT and DELETE requests. + + If the parameters dictionary is nil or empty, returns nil. +*/ +NSString *OMGFormURLEncode(NSDictionary *parameters); + +#if __has_feature(nullability) && defined(NS_ASSUME_NONNULL_END) +NS_ASSUME_NONNULL_END +#endif diff --git a/Pods/OMGHTTPURLRQ/Sources/OMGFormURLEncode.m b/Pods/OMGHTTPURLRQ/Sources/OMGFormURLEncode.m new file mode 100644 index 0000000..1014543 --- /dev/null +++ b/Pods/OMGHTTPURLRQ/Sources/OMGFormURLEncode.m @@ -0,0 +1,56 @@ +#import +#import "OMGFormURLEncode.h" + +static inline NSString *enc(id in, NSString *ignore) { + NSMutableCharacterSet *allowedSet = [NSMutableCharacterSet characterSetWithCharactersInString:ignore]; + [allowedSet formUnionWithCharacterSet:[NSCharacterSet URLQueryAllowedCharacterSet]]; + [allowedSet removeCharactersInString:@":/?&=;+!@#$()',*"]; + + return [[in description] stringByAddingPercentEncodingWithAllowedCharacters:allowedSet]; +} + +#define enckey(in) enc(in, @"[]") +#define encval(in) enc(in, @"") + +static NSArray *DoQueryMagic(NSString *key, id value) { + NSMutableArray *parts = [NSMutableArray new]; + + // Sort dictionary keys to ensure consistent ordering in query string, + // which is important when deserializing potentially ambiguous sequences, + // such as an array of dictionaries + #define sortDescriptor [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)] + + if ([value isKindOfClass:[NSDictionary class]]) { + NSDictionary *dictionary = value; + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[sortDescriptor]]) { + id recursiveKey = key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey; + [parts addObjectsFromArray:DoQueryMagic(recursiveKey, dictionary[nestedKey])]; + } + } else if ([value isKindOfClass:[NSArray class]]) { + for (id nestedValue in value) + [parts addObjectsFromArray:DoQueryMagic([NSString stringWithFormat:@"%@[]", key], nestedValue)]; + } else if ([value isKindOfClass:[NSSet class]]) { + for (id obj in [value sortedArrayUsingDescriptors:@[sortDescriptor]]) + [parts addObjectsFromArray:DoQueryMagic(key, obj)]; + } else { + [parts addObjectsFromArray:[NSArray arrayWithObjects:key, value, nil]]; + } + + return parts; + + #undef sortDescriptor +} + +NSString *OMGFormURLEncode(NSDictionary *parameters) { + if (parameters.count == 0) + return @""; + NSMutableString *queryString = [NSMutableString new]; + NSEnumerator *e = DoQueryMagic(nil, parameters).objectEnumerator; + for (;;) { + id const obj = e.nextObject; + if (!obj) break; + [queryString appendFormat:@"%@=%@&", enckey(obj), encval(e.nextObject)]; + } + [queryString deleteCharactersInRange:NSMakeRange(queryString.length - 1, 1)]; + return queryString; +} diff --git a/Pods/OMGHTTPURLRQ/Sources/OMGHTTPURLRQ.h b/Pods/OMGHTTPURLRQ/Sources/OMGHTTPURLRQ.h new file mode 100644 index 0000000..1eb04b1 --- /dev/null +++ b/Pods/OMGHTTPURLRQ/Sources/OMGHTTPURLRQ.h @@ -0,0 +1,64 @@ +#import + +FOUNDATION_EXPORT double OMGHTTPURLRQVersionNumber; +FOUNDATION_EXPORT const unsigned char OMGHTTPURLRQVersionString[]; + +#import +#import +#import +#import +#import "OMGFormURLEncode.h" +#import "OMGUserAgent.h" + + +#if __has_feature(nullability) && defined(NS_ASSUME_NONNULL_BEGIN) +NS_ASSUME_NONNULL_BEGIN +#else +#define nullable +#endif + +/** + The error will either be a JSON error (NSCocoaDomain :/) or in the NSURLErrorDomain + with code: NSURLErrorUnsupportedURL. +*/ +@interface OMGHTTPURLRQ : NSObject + ++ (nullable NSMutableURLRequest *)GET:(NSString *)url :(nullable NSDictionary *)parameters error:(NSError **)error; ++ (nullable NSMutableURLRequest *)POST:(NSString *)url :(nullable id)parametersOrMultipartFormData error:(NSError **)error; ++ (nullable NSMutableURLRequest *)POST:(NSString *)url JSON:(nullable id)JSONObject error:(NSError **)error; ++ (nullable NSMutableURLRequest *)PUT:(NSString *)url :(nullable NSDictionary *)parameters error:(NSError **)error; ++ (nullable NSMutableURLRequest *)PUT:(NSString *)url JSON:(nullable id)JSONObject error:(NSError **)error; ++ (nullable NSMutableURLRequest *)DELETE:(NSString *)url :(nullable NSDictionary *)parameters error:(NSError **)error; + +@end + + +/** + POST this with `OMGHTTPURLRQ`’s `-POST::` class method. +*/ +@interface OMGMultipartFormData : NSObject + +/** + The `filename` parameter is optional. The content-type is optional, and + if left `nil` will default to *octet-stream*. +*/ +- (void)addFile:(NSData *)data parameterName:(NSString *)parameterName filename:(nullable NSString *)filename contentType:(nullable NSString *)contentType; + +- (void)addText:(NSString *)text parameterName:(NSString *)parameterName; + +/** + Technically adding parameters to a multipart/form-data request is abusing + the specification. What we do is add each parameter as a text-item. Any + API that expects parameters in a multipart/form-data request will expect + the parameters to be encoded in this way. +*/ +- (void)addParameters:(NSDictionary *)parameters; + +@end + + +#if __has_feature(nullability) && defined(NS_ASSUME_NONNULL_END) +NS_ASSUME_NONNULL_END +#else +#undef nullable +#endif diff --git a/Pods/OMGHTTPURLRQ/Sources/OMGHTTPURLRQ.m b/Pods/OMGHTTPURLRQ/Sources/OMGHTTPURLRQ.m new file mode 100644 index 0000000..3f48ace --- /dev/null +++ b/Pods/OMGHTTPURLRQ/Sources/OMGHTTPURLRQ.m @@ -0,0 +1,172 @@ +#import +#import +#import +#import +#import +#import "OMGHTTPURLRQ.h" +#import "OMGUserAgent.h" +#import "OMGFormURLEncode.h" +#import + +static inline NSMutableURLRequest *OMGMutableURLRequest() { + NSMutableURLRequest *rq = [NSMutableURLRequest new]; + [rq setValue:OMGUserAgent() forHTTPHeaderField:@"User-Agent"]; + return rq; +} + +#define OMGInvalidURLErrorMake() \ + [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorUnsupportedURL userInfo:@{NSLocalizedDescriptionKey: @"The provided URL was invalid."}] + + +@implementation OMGMultipartFormData { +@public + NSString *boundary; + NSMutableData *body; +} + +- (instancetype)init { + body = [NSMutableData data]; + boundary = [NSString stringWithFormat:@"------------------------%08X%08X", arc4random(), arc4random()]; + return self; +} + +- (void)add:(NSData *)payload :(NSString *)name :(NSString *)filename :(NSString *)contentType { + id ln1 = [NSString stringWithFormat:@"--%@\r\n", boundary]; + id ln2 = ({ + id s = [NSMutableString stringWithString:@"Content-Disposition: form-data; "]; + [s appendFormat:@"name=\"%@\"", name]; + if (filename.length) + [s appendFormat:@"; filename=\"%@\"", filename]; + [s appendString:@"\r\n"]; + if (contentType.length) + [s appendFormat:@"Content-Type: %@\r\n", contentType]; + [s appendString:@"\r\n"]; + s; + }); + + [body appendData:[ln1 dataUsingEncoding:NSUTF8StringEncoding]]; + [body appendData:[ln2 dataUsingEncoding:NSUTF8StringEncoding]]; + [body appendData:payload]; + [body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; +} + +- (void)addFile:(NSData *)payload parameterName:(NSString *)name filename:(NSString *)filename contentType:(NSString *)contentType +{ + [self add:payload:name:filename:(contentType ?: @"application/octet-stream")]; +} + +- (void)addText:(NSString *)text parameterName:(NSString *)parameterName { + [self add:[text dataUsingEncoding:NSUTF8StringEncoding]:parameterName:nil:nil]; +} + +- (void)addParameters:(NSDictionary *)parameters { + for (id key in parameters) + [self addText:[parameters[key] description] parameterName:key]; +} + +@end + + + +@implementation OMGHTTPURLRQ + ++ (NSMutableURLRequest *)GET:(NSString *)urlString :(NSDictionary *)params error:(NSError **)error { + NSString *queryString = OMGFormURLEncode(params); + if (queryString.length) urlString = [urlString stringByAppendingFormat:@"?%@", queryString]; + + id url = [NSURL URLWithString:urlString]; + if (!url) { + if (error) *error = OMGInvalidURLErrorMake(); + return nil; + } + + NSMutableURLRequest *rq = OMGMutableURLRequest(); + rq.HTTPMethod = @"GET"; + rq.URL = url; + return rq; +} + +static NSMutableURLRequest *OMGFormURLEncodedRequest(NSString *urlString, NSString *method, NSDictionary *parameters, NSError **error) { + id url = [NSURL URLWithString:urlString]; + if (!url) { + if (error) *error = OMGInvalidURLErrorMake(); + return nil; + } + + NSMutableURLRequest *rq = OMGMutableURLRequest(); + rq.URL = url; + rq.HTTPMethod = method; + + id queryString = OMGFormURLEncode(parameters); + NSData *data = [queryString dataUsingEncoding:NSUTF8StringEncoding]; + [rq addValue:@"8bit" forHTTPHeaderField:@"Content-Transfer-Encoding"]; + [rq addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; + [rq addValue:@(data.length).description forHTTPHeaderField:@"Content-Length"]; + [rq setHTTPBody:data]; + + return rq; +} + ++ (NSMutableURLRequest *)POST:(NSString *)urlString :(id)body error:(NSError **)error { + if (![body isKindOfClass:[OMGMultipartFormData class]]) { + return OMGFormURLEncodedRequest(urlString, @"POST", body, error); + } else { + id url = [NSURL URLWithString:urlString]; + if (!url) { + if (error) *error = OMGInvalidURLErrorMake(); + return nil; + } + + OMGMultipartFormData *multipartFormData = (id)body; + id const charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); + id const contentType = [NSString stringWithFormat:@"multipart/form-data; charset=%@; boundary=%@", charset, multipartFormData->boundary]; + + NSMutableData *data = [multipartFormData->body mutableCopy]; + id lastLine = [NSString stringWithFormat:@"\r\n--%@--\r\n", multipartFormData->boundary]; + [data appendData:[lastLine dataUsingEncoding:NSUTF8StringEncoding]]; + + NSMutableURLRequest *rq = OMGMutableURLRequest(); + [rq setURL:url]; + [rq setHTTPMethod:@"POST"]; + [rq addValue:contentType forHTTPHeaderField:@"Content-Type"]; + [rq setHTTPBody:data]; + return rq; + } +} + ++ (NSMutableURLRequest *)POST:(NSString *)urlString JSON:(id)params error:(NSError **)error { + if (error) *error = nil; + + id url = [NSURL URLWithString:urlString]; + if (!url) { + if (error) *error = OMGInvalidURLErrorMake(); + return nil; + } + + id JSONData = [NSJSONSerialization dataWithJSONObject:params options:(NSJSONWritingOptions)0 error:error]; + if (error && *error) return nil; + + NSMutableURLRequest *rq = OMGMutableURLRequest(); + [rq setURL:url]; + [rq setHTTPMethod:@"POST"]; + [rq setHTTPBody:JSONData]; + [rq setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; + [rq setValue:@"json" forHTTPHeaderField:@"Data-Type"]; + return rq; +} + ++ (NSMutableURLRequest *)PUT:(NSString *)url :(NSDictionary *)parameters error:(NSError **)error { + return OMGFormURLEncodedRequest(url, @"PUT", parameters, error); +} + ++ (NSMutableURLRequest *)PUT:(NSString *)url JSON:(id)params error:(NSError **)error { + NSMutableURLRequest *rq = [OMGHTTPURLRQ POST:url JSON:params error:error]; + rq.HTTPMethod = @"PUT"; + return rq; +} + ++ (NSMutableURLRequest *)DELETE:(NSString *)url :(NSDictionary *)parameters error:(NSError **)error { + return OMGFormURLEncodedRequest(url, @"DELETE", parameters, error); +} + +@end diff --git a/Pods/OMGHTTPURLRQ/Sources/OMGUserAgent.h b/Pods/OMGHTTPURLRQ/Sources/OMGUserAgent.h new file mode 100644 index 0000000..75dacf4 --- /dev/null +++ b/Pods/OMGHTTPURLRQ/Sources/OMGUserAgent.h @@ -0,0 +1,12 @@ +#import +@class NSString; + +#if __has_feature(nullability) && defined(NS_ASSUME_NONNULL_BEGIN) +NS_ASSUME_NONNULL_BEGIN +#endif + +NSString *OMGUserAgent(); + +#if __has_feature(nullability) && defined(NS_ASSUME_NONNULL_END) +NS_ASSUME_NONNULL_END +#endif diff --git a/Pods/OMGHTTPURLRQ/Sources/OMGUserAgent.m b/Pods/OMGHTTPURLRQ/Sources/OMGUserAgent.m new file mode 100644 index 0000000..1d08311 --- /dev/null +++ b/Pods/OMGHTTPURLRQ/Sources/OMGUserAgent.m @@ -0,0 +1,19 @@ +#import +#import "OMGUserAgent.h" + +NSString *OMGUserAgent() { + static NSString *ua; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + id info = [NSBundle mainBundle].infoDictionary; + id name = info[@"CFBundleDisplayName"] ?: info[(__bridge NSString *)kCFBundleIdentifierKey]; + id vers = (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: info[(__bridge NSString *)kCFBundleVersionKey]; + #ifdef UIKIT_EXTERN + float scale = ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [UIScreen mainScreen].scale : 1.0f); + ua = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", name, vers, [UIDevice currentDevice].model, [UIDevice currentDevice].systemVersion, scale]; + #else + ua = [NSString stringWithFormat:@"%@/%@", name, vers]; + #endif + }); + return ua; +} diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000..8e8431d --- /dev/null +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,3730 @@ + + + + + archiveVersion + 1 + classes + + objectVersion + 46 + objects + + 009F66A48D8629B7B862D213908C1A34 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods.release beta.xcconfig + sourceTree + <group> + + 00F296E9CCF19FEE504516534B64F218 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + OMGFormURLEncode.h + path + Sources/OMGFormURLEncode.h + sourceTree + <group> + + 04AC7845366C00E35B57BF00A8893A21 + + fileRef + 4A7C09CFE55C9B022608ECCB6A899E4E + isa + PBXBuildFile + + 04B787F1088B1082807BCEDA0C290A4E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + Umbrella.h + path + Sources/Umbrella.h + sourceTree + <group> + + 0745E77B9C51CF29A37D678302115511 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + AC5099F6E0D3B27645B5F64BD7675D18 + remoteInfo + PromiseKit + + 0922CFBFA7AA984DB966FA575B9D5A9E + + fileRef + 3B823AF19CB2CA90E7FF666D2BD6A5B5 + isa + PBXBuildFile + + 0962E067CFB04778FD9D5C78954AFA16 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Pods-acknowledgements.plist + sourceTree + <group> + + 098C9BC9B17546D4462C7D710DF2FBB7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AnyPromise.m + path + Sources/AnyPromise.m + sourceTree + <group> + + 0B95CFE225D3B5397EF88E3AA5727B4B + + fileRef + BDD69CD6B9A8ED23A1D5F528C170D30B + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 0D3705109CF7A9E60D154DA1E9325E6F + + baseConfigurationReference + 68F92C56153E0C4070C12CD6929E6518 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/PromiseKit/PromiseKit-prefix.pch + INFOPLIST_FILE + Target Support Files/PromiseKit/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/PromiseKit/PromiseKit.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + PromiseKit + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Distribution + + 0DBB4EEC95CB6DB2618F45149CDBDF08 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Promise+Properties.swift + path + Sources/Promise+Properties.swift + sourceTree + <group> + + 0DD68F53D8E765A5B2CFF2A173E2D12D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-frameworks.sh + sourceTree + <group> + + 10C7DF355F3C59E207E5A9277B63A4A7 + + fileRef + 098C9BC9B17546D4462C7D710DF2FBB7 + isa + PBXBuildFile + + 110630E793F7534F59FF7C302CC0E9ED + + fileRef + D26A5FE22D52E0DDB7C5E0ADB3041F36 + isa + PBXBuildFile + + 125681AA8BD0C3DDE30131BD35E74DCE + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 9CE88AD44E43F99C466AA0CF8B0E1C91 + remoteInfo + OMGHTTPURLRQ + + 12BC89D678E20B22271AC2A81E522E3A + + buildConfigurationList + E3BAB31B49BC5FF8866EE974F6F6DE95 + buildPhases + + 8693C649600968EC255690E4B06022F9 + 79EA621D2D300AF3810F7A7399C5A9E8 + B17054868085E51CFC44D62BEA16B02D + + buildRules + + dependencies + + B2F60B5D24269CE0B42DDE42C72B7EB9 + AAAD815C570A31A33406B2423A937C26 + + isa + PBXNativeTarget + name + Pods + productName + Pods + productReference + E0ADE99AE56A277EE6F2ADAB3BFB3F25 + productType + com.apple.product-type.framework + + 134639ADF85E3F398578384A342651D0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + 1346AD0B1932C707DB241123A1D49E6E + + fileRef + AD85FD316CA256A8B06C5F48DC25DF04 + isa + PBXBuildFile + + 13821B9C543CAC6B7AEB1FE03025FC0D + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + COPY_PHASE_STRIP + YES + ENABLE_NS_ASSERTIONS + NO + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_PREPROCESSOR_DEFINITIONS + + RELEASE_BETA=1 + + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + STRIP_INSTALLED_PRODUCT + NO + VALIDATE_PRODUCT + YES + + isa + XCBuildConfiguration + name + Release Beta + + 1682134017840F1375CD14E6CC7A46BF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text + path + Pods-acknowledgements.markdown + sourceTree + <group> + + 17F4975971A588B37B6FA35491278E6E + + baseConfigurationReference + 93E2B13A680D37A527CED93C491EAD9A + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-prefix.pch + INFOPLIST_FILE + Target Support Files/OMGHTTPURLRQ/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + OMGHTTPURLRQ + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Beta + + 18609302A94538DA3154DE0EED52E98A + + baseConfigurationReference + 68F92C56153E0C4070C12CD6929E6518 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/PromiseKit/PromiseKit-prefix.pch + INFOPLIST_FILE + Target Support Files/PromiseKit/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/PromiseKit/PromiseKit.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + PromiseKit + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release Beta + + 18CEEA4BBF2665A3FB9C37590394D6D7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + NSNotificationCenter+AnyPromise.m + path + Categories/Foundation/NSNotificationCenter+AnyPromise.m + sourceTree + <group> + + 1CCB423110ADB3AF2AFDD17A6D7EF9D7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + OMGHTTPURLRQ-umbrella.h + sourceTree + <group> + + 1E5CDBAAFD77DDE3877499CCA6E49A85 + + fileRef + 7E14693323D2574CDB415A8EFBE276ED + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 2164BFAF2BF31BD72D077A36CEDF2C4C + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + OMGHTTPURLRQ.framework + path + OMGHTTPURLRQ.framework + sourceTree + BUILT_PRODUCTS_DIR + + 21D4A2610852C8FF3F3BC7D3C7BC435F + + children + + 72D9C2D97DF0BC2EBB4BFDDDF1A3AE0A + D4297CEE6E42748FDB61201357A5CA51 + 68F92C56153E0C4070C12CD6929E6518 + BA8D0CFED86F928E7E2B5D35D02CA7D4 + D539A2ADF2AEF524A0001FAB89101B0A + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/PromiseKit + sourceTree + <group> + + 2221A940CBA5ECA26FF2C75E1592F629 + + fileRef + 3D2608AEA8AFDB9C8CBDF7B4B0FC3B71 + isa + PBXBuildFile + + 25E9691175F1E8F6F28006CE620928BA + + fileRef + 3C12AA131CFB6E451B53935351FC4EAA + isa + PBXBuildFile + + 2804E3F79F59436F5205BA0344C75C02 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + NSNotificationCenter+AnyPromise.h + path + Categories/Foundation/NSNotificationCenter+AnyPromise.h + sourceTree + <group> + + 2835CBEE8D10C3E6CB897B9CA74639B0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + AnyPromise.swift + path + Sources/AnyPromise.swift + sourceTree + <group> + + 2CD6312F3B583A21AA6528321B852BBA + + children + + 44FFC142BBD6E212E22B0C394885510F + 894467D63FA4E6B9F0F33C04B91324FA + 50D9213B88E93F0EEFA9BAC8F034803C + 098C9BC9B17546D4462C7D710DF2FBB7 + 2835CBEE8D10C3E6CB897B9CA74639B0 + AD85FD316CA256A8B06C5F48DC25DF04 + 99812218190532F9E33FC2D05D3963CA + 3B823AF19CB2CA90E7FF666D2BD6A5B5 + 4473BD8E0270F84C16B10FDAD0C33128 + 4065B69EA1A96146941E6C08D5FACBBE + 6616BB1AEA8792DCC96F217C7247CFC7 + E94F6A0421F5BF463B469E664A855960 + 708AD44928282459701B7C58FF04836F + 0DBB4EEC95CB6DB2618F45149CDBDF08 + 3E81B6399B86149C808656EAD5E2657C + 4A7C09CFE55C9B022608ECCB6A899E4E + EEB130BEE52061CAE4F86B3C975DBF4C + 04B787F1088B1082807BCEDA0C290A4E + B4576A7014E7829E1B2EC9A618CAF7AC + 4B882805A7FFF55F0D79768FF801B90C + 9A7D65176AFC3AA21A31890B404FF1C6 + + isa + PBXGroup + name + CorePromise + sourceTree + <group> + + 2D8E8EC45A3A1A1D94AE762CB5028504 + + buildConfigurations + + 9BE7F90C0A147972B37491F307FF3583 + 5CE5176205D06FF3FFE3DDDA9291E44B + D0C30505A32865F7A88325F2EDCBCDFD + 74857149DC1E0D599B8A01A78349A926 + 13821B9C543CAC6B7AEB1FE03025FC0D + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 2E61048DD4D65E5B33880CB65D7FA3EB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIAlertView+AnyPromise.m + path + Categories/UIKit/UIAlertView+AnyPromise.m + sourceTree + <group> + + 2EF605B7EF24A1EBB0F8F42B5D10C23D + + fileRef + 2835CBEE8D10C3E6CB897B9CA74639B0 + isa + PBXBuildFile + + 30B7284438ACD1074EC5B35A2C5A34D5 + + includeInIndex + 1 + isa + PBXFileReference + path + OMGHTTPURLRQ.modulemap + sourceTree + <group> + + 30E742ECC2C27359FD4C43A8F131F9A6 + + children + + 8DE44636A2DDB7F96DBC8D9202CABB37 + 2804E3F79F59436F5205BA0344C75C02 + 18CEEA4BBF2665A3FB9C37590394D6D7 + E0BE626166C932B9964F97298F973065 + 88DEC2EEE36DD71CB6A81C154B1AD85D + 88828B3CF98188F22AC8F757A805DB07 + 410ED79775C1550A887B0FDE0946E95A + AEE249ACD6327C99A2118209D31E1AD4 + 71ACFA6F723B99D9CF14EB8A39F61893 + + isa + PBXGroup + name + Foundation + sourceTree + <group> + + 323CAFEEB599AE0FFB7BBF713A4A4C9C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Pods-dummy.m + sourceTree + <group> + + 334D373301123558525DB349A5FE82D7 + + fileRef + 5310F21824F06B1DBEAE588BE2B16AEF + isa + PBXBuildFile + + 37C116DDE094624EF5359E9468E0883D + + fileRef + BA3B33DA25C2C920EEEF7E8FC8860312 + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + 3852E033930E0335D6BD8ED7668209E6 + + fileRef + 8DE44636A2DDB7F96DBC8D9202CABB37 + isa + PBXBuildFile + + 38930745AEB9F7FCC6E1AE7DE9E3F1C6 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 9CE88AD44E43F99C466AA0CF8B0E1C91 + remoteInfo + OMGHTTPURLRQ + + 38E9B00E993CB783765E12CC47676611 + + fileRef + 50D9213B88E93F0EEFA9BAC8F034803C + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 39DB643CE7B2439AE1CB766E996B72BD + + baseConfigurationReference + 93E2B13A680D37A527CED93C491EAD9A + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-prefix.pch + INFOPLIST_FILE + Target Support Files/OMGHTTPURLRQ/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + OMGHTTPURLRQ + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release Beta + + 3B823AF19CB2CA90E7FF666D2BD6A5B5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Error.swift + path + Sources/Error.swift + sourceTree + <group> + + 3C12AA131CFB6E451B53935351FC4EAA + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + Foundation.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/Foundation.framework + sourceTree + DEVELOPER_DIR + + 3C9AA626F0E4F1DCAEB2BDE192C95C67 + + fileRef + 18CEEA4BBF2665A3FB9C37590394D6D7 + isa + PBXBuildFile + + 3D2608AEA8AFDB9C8CBDF7B4B0FC3B71 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIView+Promise.swift + path + Categories/UIKit/UIView+Promise.swift + sourceTree + <group> + + 3E81B6399B86149C808656EAD5E2657C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + PromiseKit.h + path + Sources/PromiseKit.h + sourceTree + <group> + + 4065B69EA1A96146941E6C08D5FACBBE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + join.m + path + Sources/join.m + sourceTree + <group> + + 40D651EB10E67A540FC5FC1FE6CC6BC6 + + fileRef + 2804E3F79F59436F5205BA0344C75C02 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 410ED79775C1550A887B0FDE0946E95A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + NSURLConnection+AnyPromise.m + path + Categories/Foundation/NSURLConnection+AnyPromise.m + sourceTree + <group> + + 442AF4F56CEEEC61720089F9803D05C4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIView+AnyPromise.h + path + Categories/UIKit/UIView+AnyPromise.h + sourceTree + <group> + + 4473BD8E0270F84C16B10FDAD0C33128 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + hang.m + path + Sources/hang.m + sourceTree + <group> + + 44FFC142BBD6E212E22B0C394885510F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + after.m + path + Sources/after.m + sourceTree + <group> + + 469C7D8D8F9FE8D3CC867523F4644926 + + includeInIndex + 1 + isa + PBXFileReference + path + Pods.modulemap + sourceTree + <group> + + 47DB3F7D5751FAB5DAD2A1F0A03EA006 + + fileRef + 8C9CA1B32F5440576CB347CA599D737D + isa + PBXBuildFile + + 4984CA14A240C711E6F5DDD4A4EE4E83 + + baseConfigurationReference + 783E6C541EFDF559B2669C0616900121 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + INFOPLIST_FILE + Target Support Files/Pods/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MODULEMAP_FILE + Target Support Files/Pods/Pods.modulemap + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_NAME + Pods + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Distribution + + 4A7C09CFE55C9B022608ECCB6A899E4E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + race.swift + path + Sources/race.swift + sourceTree + <group> + + 4B225DC77E877A0A03F3DD5163DEC3AD + + fileRef + 840B48EEDA8C057646DC21190914016C + isa + PBXBuildFile + + 4B882805A7FFF55F0D79768FF801B90C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + when.m + path + Sources/when.m + sourceTree + <group> + + 4E0697C4DF211DB8CF07A727C0B4AF89 + + fileRef + 2E61048DD4D65E5B33880CB65D7FA3EB + isa + PBXBuildFile + + 501AC7474B0F8EF57AF66AF1AA18051C + + children + + 5B4A401534267B23479C7F671B7EC8CB + BA3B33DA25C2C920EEEF7E8FC8860312 + + isa + PBXGroup + name + RQ + sourceTree + <group> + + 50D9213B88E93F0EEFA9BAC8F034803C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AnyPromise.h + path + Sources/AnyPromise.h + sourceTree + <group> + + 512E5B7D04620C422876937B935C90F0 + + buildActionMask + 2147483647 + files + + 8EFEA68A710E6B3CE891F1B87BBC1AB7 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 5310F21824F06B1DBEAE588BE2B16AEF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + CALayer+AnyPromise.m + path + Categories/QuartzCore/CALayer+AnyPromise.m + sourceTree + <group> + + 537BB18B365CEF907B373369DFC47039 + + buildActionMask + 2147483647 + files + + DC9593D74BF7CF281634F66CDB6B974F + F6E23482553CDBE68332D1FFE99422F8 + 47DB3F7D5751FAB5DAD2A1F0A03EA006 + 110630E793F7534F59FF7C302CC0E9ED + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 5449DEE6FA277E4C6E978F94AB0ECDF5 + + fileRef + 708AD44928282459701B7C58FF04836F + isa + PBXBuildFile + + 55C85AAAC2ED59F68703D2387456A969 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + OMGFormURLEncode.m + path + Sources/OMGFormURLEncode.m + sourceTree + <group> + + 577E71E7C482C0D8697BE18DAA23D492 + + buildActionMask + 2147483647 + files + + 38E9B00E993CB783765E12CC47676611 + 72ECA8CE0473D37C582B2B1AC08CC315 + DF2C5BEDD15DD24872E84233F66F1483 + 40D651EB10E67A540FC5FC1FE6CC6BC6 + 934E19380F0DE7B75A25E7149BD91E45 + 933AF6B479FECD710D5A5327C910427D + 9101B38702ED244F52B64618384F239A + B7E34161F5503F03CE13E96D3F1812B4 + A3B9774AA577F225C67201F8EC248C4E + 1E5CDBAAFD77DDE3877499CCA6E49A85 + 828B7B0C766980D943E986F16B92991D + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 593973B9A33C126FD1AC3FE5C7821AAF + + fileRef + F2C74D90348574DA9ABD80F0E6B83164 + isa + PBXBuildFile + + 59EA87EBA0C740D4F9F4F8D3D40C706F + + fileRef + 9A7D65176AFC3AA21A31890B404FF1C6 + isa + PBXBuildFile + + 5A17A7434279C8850B0399999515CCCB + + fileRef + 9DD2886A272D491F8542BEEEC7C6911F + isa + PBXBuildFile + + 5AC453FCFFDE502982E2D1863436A29B + + fileRef + 6616BB1AEA8792DCC96F217C7247CFC7 + isa + PBXBuildFile + + 5B4A401534267B23479C7F671B7EC8CB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + OMGHTTPURLRQ.h + path + Sources/OMGHTTPURLRQ.h + sourceTree + <group> + + 5CE5176205D06FF3FFE3DDDA9291E44B + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + COPY_PHASE_STRIP + NO + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_DYNAMIC_NO_PIC + NO + GCC_OPTIMIZATION_LEVEL + 0 + GCC_PREPROCESSOR_DEFINITIONS + + DEBUG=1 + $(inherited) + + GCC_SYMBOLS_PRIVATE_EXTERN + NO + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + ONLY_ACTIVE_ARCH + YES + STRIP_INSTALLED_PRODUCT + NO + SYMROOT + ${SRCROOT}/../build + + isa + XCBuildConfiguration + name + Debug + + 615B214DC0B9A2FDF897618B00BFA61B + + baseConfigurationReference + 68F92C56153E0C4070C12CD6929E6518 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/PromiseKit/PromiseKit-prefix.pch + INFOPLIST_FILE + Target Support Files/PromiseKit/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/PromiseKit/PromiseKit.modulemap + MTL_ENABLE_DEBUG_INFO + YES + PRODUCT_NAME + PromiseKit + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + 6616BB1AEA8792DCC96F217C7247CFC7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + join.swift + path + Sources/join.swift + sourceTree + <group> + + 68F92C56153E0C4070C12CD6929E6518 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + PromiseKit.xcconfig + sourceTree + <group> + + 6B2511A9CE1E4202E0B9F501877B3B64 + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + PromiseKit.framework + path + PromiseKit.framework + sourceTree + BUILT_PRODUCTS_DIR + + 6C3C5CAD93CD9CC42A25ED73E6B2C5C4 + + buildConfigurations + + 17F4975971A588B37B6FA35491278E6E + 8DCA4C7E41BDFE7F562F2C4AB927EE24 + 6FC43106A9E672BDF6265A9C050278A7 + 8663D7E60C03B95B72572A3881E28E39 + 39DB643CE7B2439AE1CB766E996B72BD + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 6F48B51A6DF6EFB6F44DCB528A6F89A6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + OMGUserAgent.m + path + Sources/OMGUserAgent.m + sourceTree + <group> + + 6FC43106A9E672BDF6265A9C050278A7 + + baseConfigurationReference + 93E2B13A680D37A527CED93C491EAD9A + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-prefix.pch + INFOPLIST_FILE + Target Support Files/OMGHTTPURLRQ/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + OMGHTTPURLRQ + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Distribution + + 708AD44928282459701B7C58FF04836F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Promise.swift + path + Sources/Promise.swift + sourceTree + <group> + + 71ACFA6F723B99D9CF14EB8A39F61893 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSURLSession+Promise.swift + path + Categories/Foundation/NSURLSession+Promise.swift + sourceTree + <group> + + 72D9C2D97DF0BC2EBB4BFDDDF1A3AE0A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + 72ECA8CE0473D37C582B2B1AC08CC315 + + fileRef + B285F12A5BE139863ABF870FF4F868B9 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 73782995E510E44E2577311CD784E233 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIViewController+Promise.swift + path + Categories/UIKit/UIViewController+Promise.swift + sourceTree + <group> + + 7481D0C0923E93F62735340ADE42981C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + PMKAlertController.swift + path + Categories/UIKit/PMKAlertController.swift + sourceTree + <group> + + 74857149DC1E0D599B8A01A78349A926 + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + COPY_PHASE_STRIP + YES + ENABLE_NS_ASSERTIONS + NO + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_PREPROCESSOR_DEFINITIONS + + RELEASE=1 + + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + STRIP_INSTALLED_PRODUCT + NO + SYMROOT + ${SRCROOT}/../build + VALIDATE_PRODUCT + YES + + isa + XCBuildConfiguration + name + Release + + 75066CDED148857AB8B0271AD6B842E1 + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + path + OMGHTTPURLRQ.framework + sourceTree + BUILT_PRODUCTS_DIR + + 783E6C541EFDF559B2669C0616900121 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods.distribution.xcconfig + sourceTree + <group> + + 79EA621D2D300AF3810F7A7399C5A9E8 + + buildActionMask + 2147483647 + files + + 25E9691175F1E8F6F28006CE620928BA + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 7A5B85BA1A2C643C9E2822A8A54F556E + + fileRef + 00F296E9CCF19FEE504516534B64F218 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 7BD2332188F3A9AEFD09AC2A989CEAD1 + + fileRef + 410ED79775C1550A887B0FDE0946E95A + isa + PBXBuildFile + + 7DB346D0F39D3F0E887471402A8071AB + + children + + BA6428E9F66FD5A23C0A2E06ED26CD2F + AC76B6EC882B4FC71163F479F01FAB50 + 90D8AC72F7F74CBFB0EA89EE44000ECA + D2EA9D7BADFD7DA38AAE1A39BA3B1696 + CC0C0D494C9CDA2C2A15EE58ED573910 + + isa + PBXGroup + sourceTree + <group> + + 7DCD404BE1C663C4C1941AB32BA7F5FE + + fileRef + 4065B69EA1A96146941E6C08D5FACBBE + isa + PBXBuildFile + + 7E14693323D2574CDB415A8EFBE276ED + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIViewController+AnyPromise.h + path + Categories/UIKit/UIViewController+AnyPromise.h + sourceTree + <group> + + 7F0BD4C15E2BE8C886B560CD5BCE55FC + + buildActionMask + 2147483647 + files + + D980393FF4293CF90198F272FA7FF6F9 + EFFCE28CC5B0D10F46CEC10B4BDB3878 + 3852E033930E0335D6BD8ED7668209E6 + 10C7DF355F3C59E207E5A9277B63A4A7 + 2EF605B7EF24A1EBB0F8F42B5D10C23D + 334D373301123558525DB349A5FE82D7 + 1346AD0B1932C707DB241123A1D49E6E + 86D93D06AE14B78D8A6F6EA6879A21A8 + 0922CFBFA7AA984DB966FA575B9D5A9E + A084E9ED6EF23910CB70DA30CC293D08 + 7DCD404BE1C663C4C1941AB32BA7F5FE + 5AC453FCFFDE502982E2D1863436A29B + 3C9AA626F0E4F1DCAEB2BDE192C95C67 + DCAFA9B1940BDAC6E3938548B8E67885 + 9DFD24A79CA1A82855931191B5B97377 + 7BD2332188F3A9AEFD09AC2A989CEAD1 + CCE17F3CFDBA0C761202D582E0A0D0F5 + F1397D1697249D318A3044220FDA17EF + 82199345B7D81EACEC509E58CF6A8767 + 8ED4EBE0D848DB76DB60F4B4879FA40A + 5449DEE6FA277E4C6E978F94AB0ECDF5 + 98F7B0C8FD7620A826FAE92B0FA4CC43 + 04AC7845366C00E35B57BF00A8893A21 + 8D26FB527A863528887B6DABFA1773A0 + 593973B9A33C126FD1AC3FE5C7821AAF + CE08DFD6A91D6FEE7C57DF537525106E + 4E0697C4DF211DB8CF07A727C0B4AF89 + AC3AC179EF7C12C207E11E3144162852 + 5A17A7434279C8850B0399999515CCCB + 2221A940CBA5ECA26FF2C75E1592F629 + 4B225DC77E877A0A03F3DD5163DEC3AD + 9E69636E3B3B9281033710A035EB8341 + F8CBDE5201B98A048FEB250A1493A3FA + 94676DB255D736A7BD7A7B5DB3E2AE4D + 59EA87EBA0C740D4F9F4F8D3D40C706F + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 81C24D0DB20D60B5346F153ACCA18546 + + fileRef + 323CAFEEB599AE0FFB7BBF713A4A4C9C + isa + PBXBuildFile + + 82199345B7D81EACEC509E58CF6A8767 + + fileRef + 7481D0C0923E93F62735340ADE42981C + isa + PBXBuildFile + + 828B7B0C766980D943E986F16B92991D + + fileRef + 04B787F1088B1082807BCEDA0C290A4E + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 832C44D2F6E1A26DB49E1897CFD1A6AA + + children + + 930DCF3FA88F9E5AE0CD597FA0148EFE + 30B7284438ACD1074EC5B35A2C5A34D5 + 93E2B13A680D37A527CED93C491EAD9A + AE2930B40D67D3A0230059C823AEB686 + FADD25A6F309BE7E63B00B20D5740067 + 1CCB423110ADB3AF2AFDD17A6D7EF9D7 + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/OMGHTTPURLRQ + sourceTree + <group> + + 840B48EEDA8C057646DC21190914016C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIViewController+AnyPromise.m + path + Categories/UIKit/UIViewController+AnyPromise.m + sourceTree + <group> + + 8663D7E60C03B95B72572A3881E28E39 + + baseConfigurationReference + 93E2B13A680D37A527CED93C491EAD9A + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-prefix.pch + INFOPLIST_FILE + Target Support Files/OMGHTTPURLRQ/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + OMGHTTPURLRQ + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + 8693C649600968EC255690E4B06022F9 + + buildActionMask + 2147483647 + files + + 81C24D0DB20D60B5346F153ACCA18546 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 86D93D06AE14B78D8A6F6EA6879A21A8 + + fileRef + 99812218190532F9E33FC2D05D3963CA + isa + PBXBuildFile + + 88828B3CF98188F22AC8F757A805DB07 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + NSURLConnection+AnyPromise.h + path + Categories/Foundation/NSURLConnection+AnyPromise.h + sourceTree + <group> + + 88DEC2EEE36DD71CB6A81C154B1AD85D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSObject+Promise.swift + path + Categories/Foundation/NSObject+Promise.swift + sourceTree + <group> + + 894467D63FA4E6B9F0F33C04B91324FA + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + after.swift + path + Sources/after.swift + sourceTree + <group> + + 8AC855943E9658322C19635DF019085E + + buildActionMask + 2147483647 + files + + 7A5B85BA1A2C643C9E2822A8A54F556E + 934E2170D83AC3F267FFDF4E8A208E29 + F72B89EB3505E5287C868B9205067379 + D82A5F626240BE8E47C949EDD97B5217 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 8C0CECC30C67094775B3DABE0054E6D7 + + buildConfigurations + + DD24CE6F4A5934737F585A50C8E6221F + 615B214DC0B9A2FDF897618B00BFA61B + 0D3705109CF7A9E60D154DA1E9325E6F + B42FC70A5EDAFDB15E7B30DBE6D574AD + 18609302A94538DA3154DE0EED52E98A + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 8C9CA1B32F5440576CB347CA599D737D + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + QuartzCore.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/QuartzCore.framework + sourceTree + DEVELOPER_DIR + + 8D26FB527A863528887B6DABFA1773A0 + + fileRef + EEB130BEE52061CAE4F86B3C975DBF4C + isa + PBXBuildFile + + 8DC9C89C761A6131C66C1770B1850659 + + children + + 00F296E9CCF19FEE504516534B64F218 + 55C85AAAC2ED59F68703D2387456A969 + + isa + PBXGroup + name + FormURLEncode + sourceTree + <group> + + 8DCA4C7E41BDFE7F562F2C4AB927EE24 + + baseConfigurationReference + 93E2B13A680D37A527CED93C491EAD9A + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-prefix.pch + INFOPLIST_FILE + Target Support Files/OMGHTTPURLRQ/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.modulemap + MTL_ENABLE_DEBUG_INFO + YES + PRODUCT_NAME + OMGHTTPURLRQ + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + 8DE44636A2DDB7F96DBC8D9202CABB37 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + afterlife.swift + path + Categories/Foundation/afterlife.swift + sourceTree + <group> + + 8ED4EBE0D848DB76DB60F4B4879FA40A + + fileRef + 0DBB4EEC95CB6DB2618F45149CDBDF08 + isa + PBXBuildFile + + 8EFEA68A710E6B3CE891F1B87BBC1AB7 + + fileRef + 3C12AA131CFB6E451B53935351FC4EAA + isa + PBXBuildFile + + 904087B0340F302AAED8BE398C6CE8C6 + + children + + 3C12AA131CFB6E451B53935351FC4EAA + 8C9CA1B32F5440576CB347CA599D737D + D26A5FE22D52E0DDB7C5E0ADB3041F36 + + isa + PBXGroup + name + iOS + sourceTree + <group> + + 90D8AC72F7F74CBFB0EA89EE44000ECA + + children + + 9363D12DB312FF2576AA7FCA3D5E5B77 + 986E4FB47E81A73CE7DA763FE6B0541B + + isa + PBXGroup + name + Pods + sourceTree + <group> + + 9101B38702ED244F52B64618384F239A + + fileRef + 93CBE434EF6F1266FB6EF022404A39B8 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 930DCF3FA88F9E5AE0CD597FA0148EFE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + 933AF6B479FECD710D5A5327C910427D + + fileRef + 3E81B6399B86149C808656EAD5E2657C + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 934E19380F0DE7B75A25E7149BD91E45 + + fileRef + 88828B3CF98188F22AC8F757A805DB07 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 934E2170D83AC3F267FFDF4E8A208E29 + + fileRef + 1CCB423110ADB3AF2AFDD17A6D7EF9D7 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 9363D12DB312FF2576AA7FCA3D5E5B77 + + children + + 8DC9C89C761A6131C66C1770B1850659 + 501AC7474B0F8EF57AF66AF1AA18051C + 832C44D2F6E1A26DB49E1897CFD1A6AA + F54D5D8BCE90F0C15D7544999A3B2650 + + isa + PBXGroup + name + OMGHTTPURLRQ + path + OMGHTTPURLRQ + sourceTree + <group> + + 93CBE434EF6F1266FB6EF022404A39B8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIActionSheet+AnyPromise.h + path + Categories/UIKit/UIActionSheet+AnyPromise.h + sourceTree + <group> + + 93E2B13A680D37A527CED93C491EAD9A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + OMGHTTPURLRQ.xcconfig + sourceTree + <group> + + 94676DB255D736A7BD7A7B5DB3E2AE4D + + fileRef + 4B882805A7FFF55F0D79768FF801B90C + isa + PBXBuildFile + + 986E4FB47E81A73CE7DA763FE6B0541B + + children + + 2CD6312F3B583A21AA6528321B852BBA + 30E742ECC2C27359FD4C43A8F131F9A6 + CDE338BF73CE7C0CB5F19185A1850C2B + 21D4A2610852C8FF3F3BC7D3C7BC435F + ACEA6630B826CCDE1C109479314F0007 + + isa + PBXGroup + name + PromiseKit + path + PromiseKit + sourceTree + <group> + + 98F7B0C8FD7620A826FAE92B0FA4CC43 + + fileRef + BA8D0CFED86F928E7E2B5D35D02CA7D4 + isa + PBXBuildFile + + 99812218190532F9E33FC2D05D3963CA + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + dispatch_promise.swift + path + Sources/dispatch_promise.swift + sourceTree + <group> + + 9A7D65176AFC3AA21A31890B404FF1C6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + when.swift + path + Sources/when.swift + sourceTree + <group> + + 9AF5BB7E2EB036F3A1E2BDAA4476E361 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIActionSheet+Promise.swift + path + Categories/UIKit/UIActionSheet+Promise.swift + sourceTree + <group> + + 9BE7F90C0A147972B37491F307FF3583 + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + COPY_PHASE_STRIP + YES + ENABLE_NS_ASSERTIONS + NO + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_PREPROCESSOR_DEFINITIONS + + BETA=1 + + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + STRIP_INSTALLED_PRODUCT + NO + VALIDATE_PRODUCT + YES + + isa + XCBuildConfiguration + name + Beta + + 9CE88AD44E43F99C466AA0CF8B0E1C91 + + buildConfigurationList + 6C3C5CAD93CD9CC42A25ED73E6B2C5C4 + buildPhases + + A3D0901D46196D583CF9571C52D66E58 + 512E5B7D04620C422876937B935C90F0 + 8AC855943E9658322C19635DF019085E + + buildRules + + dependencies + + isa + PBXNativeTarget + name + OMGHTTPURLRQ + productName + OMGHTTPURLRQ + productReference + 2164BFAF2BF31BD72D077A36CEDF2C4C + productType + com.apple.product-type.framework + + 9DD2886A272D491F8542BEEEC7C6911F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIView+AnyPromise.m + path + Categories/UIKit/UIView+AnyPromise.m + sourceTree + <group> + + 9DFD24A79CA1A82855931191B5B97377 + + fileRef + 88DEC2EEE36DD71CB6A81C154B1AD85D + isa + PBXBuildFile + + 9E69636E3B3B9281033710A035EB8341 + + fileRef + 73782995E510E44E2577311CD784E233 + isa + PBXBuildFile + + A084E9ED6EF23910CB70DA30CC293D08 + + fileRef + 4473BD8E0270F84C16B10FDAD0C33128 + isa + PBXBuildFile + + A2806708FBC0E9C29D3AD9F2F866BD58 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIAlertView+AnyPromise.h + path + Categories/UIKit/UIAlertView+AnyPromise.h + sourceTree + <group> + + A3B9774AA577F225C67201F8EC248C4E + + fileRef + 442AF4F56CEEEC61720089F9803D05C4 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + A3D0901D46196D583CF9571C52D66E58 + + buildActionMask + 2147483647 + files + + AF500EC0BDC96C3D1ED4CACEF16BE420 + D5B665DC735EB62C27631176F3983EFB + 37C116DDE094624EF5359E9468E0883D + C8F5B2C7C3FDF7AFE3F8B198A57FF471 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + AAAD815C570A31A33406B2423A937C26 + + isa + PBXTargetDependency + name + PromiseKit + target + AC5099F6E0D3B27645B5F64BD7675D18 + targetProxy + 0745E77B9C51CF29A37D678302115511 + + AC3AC179EF7C12C207E11E3144162852 + + fileRef + D93BF295C0EE0062AB376E8D85938A2B + isa + PBXBuildFile + + AC5099F6E0D3B27645B5F64BD7675D18 + + buildConfigurationList + 8C0CECC30C67094775B3DABE0054E6D7 + buildPhases + + 7F0BD4C15E2BE8C886B560CD5BCE55FC + 537BB18B365CEF907B373369DFC47039 + 577E71E7C482C0D8697BE18DAA23D492 + + buildRules + + dependencies + + CC66D7B3BFB6A7477A3831C25BC18874 + + isa + PBXNativeTarget + name + PromiseKit + productName + PromiseKit + productReference + 6B2511A9CE1E4202E0B9F501877B3B64 + productType + com.apple.product-type.framework + + AC76B6EC882B4FC71163F479F01FAB50 + + children + + 75066CDED148857AB8B0271AD6B842E1 + 904087B0340F302AAED8BE398C6CE8C6 + + isa + PBXGroup + name + Frameworks + sourceTree + <group> + + ACEA6630B826CCDE1C109479314F0007 + + children + + 7481D0C0923E93F62735340ADE42981C + 93CBE434EF6F1266FB6EF022404A39B8 + F2C74D90348574DA9ABD80F0E6B83164 + 9AF5BB7E2EB036F3A1E2BDAA4476E361 + A2806708FBC0E9C29D3AD9F2F866BD58 + 2E61048DD4D65E5B33880CB65D7FA3EB + D93BF295C0EE0062AB376E8D85938A2B + 442AF4F56CEEEC61720089F9803D05C4 + 9DD2886A272D491F8542BEEEC7C6911F + 3D2608AEA8AFDB9C8CBDF7B4B0FC3B71 + 7E14693323D2574CDB415A8EFBE276ED + 840B48EEDA8C057646DC21190914016C + 73782995E510E44E2577311CD784E233 + + isa + PBXGroup + name + UIKit + sourceTree + <group> + + AD85FD316CA256A8B06C5F48DC25DF04 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + dispatch_promise.m + path + Sources/dispatch_promise.m + sourceTree + <group> + + AE2930B40D67D3A0230059C823AEB686 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + OMGHTTPURLRQ-dummy.m + sourceTree + <group> + + AEE249ACD6327C99A2118209D31E1AD4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSURLConnection+Promise.swift + path + Categories/Foundation/NSURLConnection+Promise.swift + sourceTree + <group> + + AF500EC0BDC96C3D1ED4CACEF16BE420 + + fileRef + 55C85AAAC2ED59F68703D2387456A969 + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + B17054868085E51CFC44D62BEA16B02D + + buildActionMask + 2147483647 + files + + 0B95CFE225D3B5397EF88E3AA5727B4B + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + B285F12A5BE139863ABF870FF4F868B9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + CALayer+AnyPromise.h + path + Categories/QuartzCore/CALayer+AnyPromise.h + sourceTree + <group> + + B2F60B5D24269CE0B42DDE42C72B7EB9 + + isa + PBXTargetDependency + name + OMGHTTPURLRQ + target + 9CE88AD44E43F99C466AA0CF8B0E1C91 + targetProxy + 125681AA8BD0C3DDE30131BD35E74DCE + + B42FC70A5EDAFDB15E7B30DBE6D574AD + + baseConfigurationReference + 68F92C56153E0C4070C12CD6929E6518 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/PromiseKit/PromiseKit-prefix.pch + INFOPLIST_FILE + Target Support Files/PromiseKit/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/PromiseKit/PromiseKit.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + PromiseKit + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + B4576A7014E7829E1B2EC9A618CAF7AC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + URLDataPromise.swift + path + Sources/URLDataPromise.swift + sourceTree + <group> + + B7E34161F5503F03CE13E96D3F1812B4 + + fileRef + A2806708FBC0E9C29D3AD9F2F866BD58 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + B9B40F37EAEBF9EF588AF58CE5EE9DB1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods.beta.xcconfig + sourceTree + <group> + + BA3B33DA25C2C920EEEF7E8FC8860312 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + OMGHTTPURLRQ.m + path + Sources/OMGHTTPURLRQ.m + sourceTree + <group> + + BA6428E9F66FD5A23C0A2E06ED26CD2F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text + name + Podfile + path + ../Podfile + sourceTree + SOURCE_ROOT + xcLanguageSpecificationIdentifier + xcode.lang.ruby + + BA8D0CFED86F928E7E2B5D35D02CA7D4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + PromiseKit-dummy.m + sourceTree + <group> + + BDD69CD6B9A8ED23A1D5F528C170D30B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + Pods-umbrella.h + sourceTree + <group> + + C0DFE469BF178F43465FFF20BFE102FF + + baseConfigurationReference + B9B40F37EAEBF9EF588AF58CE5EE9DB1 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + INFOPLIST_FILE + Target Support Files/Pods/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MODULEMAP_FILE + Target Support Files/Pods/Pods.modulemap + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_NAME + Pods + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Beta + + C67F4DBC3BA2C9541D865776B2EA282F + + baseConfigurationReference + F4BA3B16E0F8D8B23EBDE6D01A6B3C85 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + INFOPLIST_FILE + Target Support Files/Pods/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MODULEMAP_FILE + Target Support Files/Pods/Pods.modulemap + MTL_ENABLE_DEBUG_INFO + YES + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_NAME + Pods + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + C8F5B2C7C3FDF7AFE3F8B198A57FF471 + + fileRef + 6F48B51A6DF6EFB6F44DCB528A6F89A6 + isa + PBXBuildFile + settings + + COMPILER_FLAGS + -DOS_OBJECT_USE_OBJC=0 + + + CC0C0D494C9CDA2C2A15EE58ED573910 + + children + + CC798CB84DC15BEE1BAE463FE9AC0A52 + + isa + PBXGroup + name + Targets Support Files + sourceTree + <group> + + CC66D7B3BFB6A7477A3831C25BC18874 + + isa + PBXTargetDependency + name + OMGHTTPURLRQ + target + 9CE88AD44E43F99C466AA0CF8B0E1C91 + targetProxy + 38930745AEB9F7FCC6E1AE7DE9E3F1C6 + + CC798CB84DC15BEE1BAE463FE9AC0A52 + + children + + 134639ADF85E3F398578384A342651D0 + 469C7D8D8F9FE8D3CC867523F4644926 + 1682134017840F1375CD14E6CC7A46BF + 0962E067CFB04778FD9D5C78954AFA16 + 323CAFEEB599AE0FFB7BBF713A4A4C9C + 0DD68F53D8E765A5B2CFF2A173E2D12D + FFA30718C7F5347E7CA01E11D6BD79A9 + BDD69CD6B9A8ED23A1D5F528C170D30B + B9B40F37EAEBF9EF588AF58CE5EE9DB1 + F4BA3B16E0F8D8B23EBDE6D01A6B3C85 + 783E6C541EFDF559B2669C0616900121 + E72DFED5F6F913DDED1107B1658EADD5 + 009F66A48D8629B7B862D213908C1A34 + + isa + PBXGroup + name + Pods + path + Target Support Files/Pods + sourceTree + <group> + + CCE17F3CFDBA0C761202D582E0A0D0F5 + + fileRef + AEE249ACD6327C99A2118209D31E1AD4 + isa + PBXBuildFile + + CDDB2BC3BF188D3831F23A50463C796C + + baseConfigurationReference + 009F66A48D8629B7B862D213908C1A34 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + INFOPLIST_FILE + Target Support Files/Pods/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MODULEMAP_FILE + Target Support Files/Pods/Pods.modulemap + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_NAME + Pods + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release Beta + + CDE338BF73CE7C0CB5F19185A1850C2B + + children + + B285F12A5BE139863ABF870FF4F868B9 + 5310F21824F06B1DBEAE588BE2B16AEF + + isa + PBXGroup + name + QuartzCore + sourceTree + <group> + + CE08DFD6A91D6FEE7C57DF537525106E + + fileRef + 9AF5BB7E2EB036F3A1E2BDAA4476E361 + isa + PBXBuildFile + + D0C30505A32865F7A88325F2EDCBCDFD + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + COPY_PHASE_STRIP + YES + ENABLE_NS_ASSERTIONS + NO + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_PREPROCESSOR_DEFINITIONS + + DISTRIBUTION=1 + + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + STRIP_INSTALLED_PRODUCT + NO + VALIDATE_PRODUCT + YES + + isa + XCBuildConfiguration + name + Distribution + + D26A5FE22D52E0DDB7C5E0ADB3041F36 + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + UIKit.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/UIKit.framework + sourceTree + DEVELOPER_DIR + + D2EA9D7BADFD7DA38AAE1A39BA3B1696 + + children + + 2164BFAF2BF31BD72D077A36CEDF2C4C + E0ADE99AE56A277EE6F2ADAB3BFB3F25 + 6B2511A9CE1E4202E0B9F501877B3B64 + + isa + PBXGroup + name + Products + sourceTree + <group> + + D41D8CD98F00B204E9800998ECF8427E + + attributes + + LastSwiftUpdateCheck + 0700 + LastUpgradeCheck + 0700 + + buildConfigurationList + 2D8E8EC45A3A1A1D94AE762CB5028504 + compatibilityVersion + Xcode 3.2 + developmentRegion + English + hasScannedForEncodings + 0 + isa + PBXProject + knownRegions + + en + + mainGroup + 7DB346D0F39D3F0E887471402A8071AB + productRefGroup + D2EA9D7BADFD7DA38AAE1A39BA3B1696 + projectDirPath + + projectReferences + + projectRoot + + targets + + 9CE88AD44E43F99C466AA0CF8B0E1C91 + 12BC89D678E20B22271AC2A81E522E3A + AC5099F6E0D3B27645B5F64BD7675D18 + + + D4297CEE6E42748FDB61201357A5CA51 + + includeInIndex + 1 + isa + PBXFileReference + path + PromiseKit.modulemap + sourceTree + <group> + + D539A2ADF2AEF524A0001FAB89101B0A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + PromiseKit-prefix.pch + sourceTree + <group> + + D5B665DC735EB62C27631176F3983EFB + + fileRef + AE2930B40D67D3A0230059C823AEB686 + isa + PBXBuildFile + + D82A5F626240BE8E47C949EDD97B5217 + + fileRef + E1D0FE7D1411A4F57592660A809B5A2C + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + D93BF295C0EE0062AB376E8D85938A2B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIAlertView+Promise.swift + path + Categories/UIKit/UIAlertView+Promise.swift + sourceTree + <group> + + D980393FF4293CF90198F272FA7FF6F9 + + fileRef + 44FFC142BBD6E212E22B0C394885510F + isa + PBXBuildFile + + DC9593D74BF7CF281634F66CDB6B974F + + fileRef + 3C12AA131CFB6E451B53935351FC4EAA + isa + PBXBuildFile + + DCAFA9B1940BDAC6E3938548B8E67885 + + fileRef + E0BE626166C932B9964F97298F973065 + isa + PBXBuildFile + + DD24CE6F4A5934737F585A50C8E6221F + + baseConfigurationReference + 68F92C56153E0C4070C12CD6929E6518 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/PromiseKit/PromiseKit-prefix.pch + INFOPLIST_FILE + Target Support Files/PromiseKit/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MODULEMAP_FILE + Target Support Files/PromiseKit/PromiseKit.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + PromiseKit + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Beta + + DF2C5BEDD15DD24872E84233F66F1483 + + fileRef + E94F6A0421F5BF463B469E664A855960 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + E0ADE99AE56A277EE6F2ADAB3BFB3F25 + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + Pods.framework + path + Pods.framework + sourceTree + BUILT_PRODUCTS_DIR + + E0BE626166C932B9964F97298F973065 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSNotificationCenter+Promise.swift + path + Categories/Foundation/NSNotificationCenter+Promise.swift + sourceTree + <group> + + E1D0FE7D1411A4F57592660A809B5A2C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + OMGUserAgent.h + path + Sources/OMGUserAgent.h + sourceTree + <group> + + E3BAB31B49BC5FF8866EE974F6F6DE95 + + buildConfigurations + + C0DFE469BF178F43465FFF20BFE102FF + C67F4DBC3BA2C9541D865776B2EA282F + 4984CA14A240C711E6F5DDD4A4EE4E83 + F9AE9DB848258D93E6BB821FFE09C92A + CDDB2BC3BF188D3831F23A50463C796C + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + E72DFED5F6F913DDED1107B1658EADD5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods.release.xcconfig + sourceTree + <group> + + E94F6A0421F5BF463B469E664A855960 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + NSError+Cancellation.h + path + Sources/NSError+Cancellation.h + sourceTree + <group> + + EEB130BEE52061CAE4F86B3C975DBF4C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + State.swift + path + Sources/State.swift + sourceTree + <group> + + EFFCE28CC5B0D10F46CEC10B4BDB3878 + + fileRef + 894467D63FA4E6B9F0F33C04B91324FA + isa + PBXBuildFile + + F1397D1697249D318A3044220FDA17EF + + fileRef + 71ACFA6F723B99D9CF14EB8A39F61893 + isa + PBXBuildFile + + F2C74D90348574DA9ABD80F0E6B83164 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIActionSheet+AnyPromise.m + path + Categories/UIKit/UIActionSheet+AnyPromise.m + sourceTree + <group> + + F4BA3B16E0F8D8B23EBDE6D01A6B3C85 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods.debug.xcconfig + sourceTree + <group> + + F54D5D8BCE90F0C15D7544999A3B2650 + + children + + E1D0FE7D1411A4F57592660A809B5A2C + 6F48B51A6DF6EFB6F44DCB528A6F89A6 + + isa + PBXGroup + name + UserAgent + sourceTree + <group> + + F6E23482553CDBE68332D1FFE99422F8 + + fileRef + 75066CDED148857AB8B0271AD6B842E1 + isa + PBXBuildFile + + F72B89EB3505E5287C868B9205067379 + + fileRef + 5B4A401534267B23479C7F671B7EC8CB + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + F8CBDE5201B98A048FEB250A1493A3FA + + fileRef + B4576A7014E7829E1B2EC9A618CAF7AC + isa + PBXBuildFile + + F9AE9DB848258D93E6BB821FFE09C92A + + baseConfigurationReference + E72DFED5F6F913DDED1107B1658EADD5 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + INFOPLIST_FILE + Target Support Files/Pods/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MODULEMAP_FILE + Target Support Files/Pods/Pods.modulemap + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_NAME + Pods + SDKROOT + iphoneos + SKIP_INSTALL + YES + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + FADD25A6F309BE7E63B00B20D5740067 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + OMGHTTPURLRQ-prefix.pch + sourceTree + <group> + + FFA30718C7F5347E7CA01E11D6BD79A9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-resources.sh + sourceTree + <group> + + + rootObject + D41D8CD98F00B204E9800998ECF8427E + + diff --git a/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+AnyPromise.h b/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+AnyPromise.h new file mode 100644 index 0000000..8eb38bd --- /dev/null +++ b/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+AnyPromise.h @@ -0,0 +1,43 @@ +#import +#import + + +/** + To import the `NSNotificationCenter` category: + + use_frameworks! + pod "PromiseKit/Foundation" + + Or `NSNotificationCenter` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + #import +*/ +@interface NSNotificationCenter (PromiseKit) +/** + Observe the named notification once. + + [NSNotificationCenter once:UIKeyboardWillShowNotification].then(^(id note, id userInfo){ + UIViewAnimationCurve curve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue]; + CGFloat duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue]; + + return [UIView promiseWithDuration:duration delay:0.0 options:(curve << 16) animations:^{ + + }]; + }); + + @warning *Important* Promises only resolve once. If you need your block to execute more than once then use `-addObserverForName:object:queue:usingBlock:`. + + @param notificationName The name of the notification for which to register the observer. + + @return A promise that fulfills with two parameters: + + 1. The NSNotification object. + 2. The NSNotification’s userInfo property. +*/ ++ (AnyPromise *)once:(NSString *)notificationName; +@end diff --git a/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+AnyPromise.m b/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+AnyPromise.m new file mode 100644 index 0000000..642d966 --- /dev/null +++ b/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+AnyPromise.m @@ -0,0 +1,18 @@ +#import +#import +#import +#import "NSNotificationCenter+AnyPromise.h" + + +@implementation NSNotificationCenter (PromiseKit) + ++ (AnyPromise *)once:(NSString *)name { + return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) { + __block id identifier = [[NSNotificationCenter defaultCenter] addObserverForName:name object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { + [[NSNotificationCenter defaultCenter] removeObserver:identifier name:name object:nil]; + resolve(PMKManifold(note, note.userInfo)); + }]; + }]; +} + +@end diff --git a/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+Promise.swift b/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+Promise.swift new file mode 100644 index 0000000..578dce0 --- /dev/null +++ b/Pods/PromiseKit/Categories/Foundation/NSNotificationCenter+Promise.swift @@ -0,0 +1,51 @@ +import Foundation.NSNotification +#if !COCOAPODS +import PromiseKit +#endif + +/** + To import the `NSNotificationCenter` category: + + use_frameworks! + pod "PromiseKit/Foundation" + + Or `NSNotificationCenter` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + import PromiseKit +*/ +extension NSNotificationCenter { + public class func once(name: String) -> NotificationPromise { + return NSNotificationCenter.defaultCenter().once(name) + } + + public func once(name: String) -> NotificationPromise { + let (promise, fulfill) = NotificationPromise.go() + let id = addObserverForName(name, object: nil, queue: nil, usingBlock: fulfill) + promise.then(on: zalgo) { _ in self.removeObserver(id) } + return promise + } +} + +public class NotificationPromise: Promise<[NSObject: AnyObject]> { + private let (parentPromise, parentFulfill, _) = Promise.pendingPromise() + + public func asNotification() -> Promise { + return parentPromise + } + + private class func go() -> (NotificationPromise, (NSNotification) -> Void) { + var fulfill: (([NSObject: AnyObject]) -> Void)! + let promise = NotificationPromise { f, _ in fulfill = f } + promise.parentPromise.then { fulfill($0.userInfo ?? [:]) } + return (promise, promise.parentFulfill) + } + + private override init(@noescape resolvers: (fulfill: ([NSObject: AnyObject]) -> Void, reject: (ErrorType) -> Void) throws -> Void) { + super.init(resolvers: resolvers) + } +} diff --git a/Pods/PromiseKit/Categories/Foundation/NSObject+Promise.swift b/Pods/PromiseKit/Categories/Foundation/NSObject+Promise.swift new file mode 100644 index 0000000..4d5d35d --- /dev/null +++ b/Pods/PromiseKit/Categories/Foundation/NSObject+Promise.swift @@ -0,0 +1,67 @@ +import Foundation +#if !COCOAPODS +import PromiseKit +#endif + +/** + To import the `NSObject` category: + + use_frameworks! + pod "PromiseKit/Foundation" + + Or `NSObject` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + import PromiseKit +*/ +extension NSObject { + /** + @return A promise that resolves when the provided keyPath changes. + + @warning *Important* The promise must not outlive the object under observation. + + @see Apple’s KVO documentation. + */ + public func observe(keyPath: String) -> Promise { + let (promise, fulfill, reject) = Promise.pendingPromise() + let proxy = KVOProxy(observee: self, keyPath: keyPath) { obj in + if let obj = obj as? T { + fulfill(obj) + } else { + let info = [NSLocalizedDescriptionKey: "The observed property was not of the requested type."] + reject(NSError(domain: PMKErrorDomain, code: PMKInvalidUsageError, userInfo: info)) + } + } + proxy.retainCycle = proxy + return promise + } +} + +private class KVOProxy: NSObject { + var retainCycle: KVOProxy? + let fulfill: (AnyObject?) -> Void + + init(observee: NSObject, keyPath: String, resolve: (AnyObject?) -> Void) { + fulfill = resolve + super.init() + observee.addObserver(self, forKeyPath: keyPath, options: NSKeyValueObservingOptions.New, context: pointer) + } + + override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer) { + if let change = change where context == pointer { + defer { retainCycle = nil } + fulfill(change[NSKeyValueChangeNewKey]) + if let object = object, keyPath = keyPath { + object.removeObserver(self, forKeyPath: keyPath) + } + } + } + + private lazy var pointer: UnsafeMutablePointer = { + return UnsafeMutablePointer(Unmanaged.passUnretained(self).toOpaque()) + }() +} diff --git a/Pods/PromiseKit/Categories/Foundation/NSURLConnection+AnyPromise.h b/Pods/PromiseKit/Categories/Foundation/NSURLConnection+AnyPromise.h new file mode 100644 index 0000000..986431f --- /dev/null +++ b/Pods/PromiseKit/Categories/Foundation/NSURLConnection+AnyPromise.h @@ -0,0 +1,215 @@ +#import +#import +#import +#import + +/** + To import the `NSURLConnection` category: + + use_frameworks! + pod "PromiseKit/Foundation" + + Or `NSURLConnection` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + #import + + PromiseKit automatically deserializes the raw HTTP data response into the + appropriate rich data type based on the mime type the server provides. + Thus if the response is JSON you will get the deserialized JSON response. + PromiseKit supports decoding into strings, JSON and UIImages. + + However if your server does not provide a rich content-type, you will + just get `NSData`. This is rare, but a good example we came across was + downloading files from Dropbox. + + PromiseKit goes to quite some lengths to provide good `NSError` objects + for error conditions at all stages of the HTTP to rich-data type + pipeline. We provide the following additional `userInfo` keys as + appropriate: + + - `PMKURLErrorFailingDataKey` + - `PMKURLErrorFailingStringKey` + - `PMKURLErrorFailingURLResponseKey` + + PromiseKit uses [OMGHTTPURLRQ](https://github.com/mxcl/OMGHTTPURLRQ) to + make its HTTP requests. PromiseKit only provides a convenience layer + above OMGHTTPURLRQ, thus if you need more power (eg. a multipartFormData + POST), use OMGHTTPURLRQ to generate the `NSURLRequest` and then pass + that request to `+promise:`. + + @see https://github.com/mxcl/OMGHTTPURLRQ +*/ +@interface NSURLConnection (PromiseKit) + +/** + Makes a GET request to the provided URL. + + [NSURLConnection GET:@"http://placekitten.com/320/320"].then(^(UIImage *img){ + // PromiseKit decodes the image (if it’s an image) + }); + + @param urlStringFormatOrURL The `NSURL` or string format to request. + + @return A promise that fulfills with three parameters: + + 1) The deserialized data response. + 2) The `NSHTTPURLResponse`. + 3) The raw `NSData` response. +*/ ++ (AnyPromise *)GET:(id)urlStringFormatOrURL, ...; + +/** + Makes a GET request with the provided query parameters. + + id url = @"http://jsonplaceholder.typicode.com/comments"; + id params = @{@"postId": @1}; + [NSURLConnection GET:url query:params].then(^(NSDictionary *jsonResponse){ + // PromiseKit decodes the JSON dictionary (if it’s JSON) + }); + + @param urlString The `NSURL` or URL string format to request. + + @param parameters The parameters to be encoded as the query string for the GET request. + + @return A promise that fulfills with three parameters: + + 1) The deserialized data response. + 2) The `NSHTTPURLResponse`. + 3) The raw `NSData` response. +*/ ++ (AnyPromise *)GET:(NSString *)urlString query:(NSDictionary *)parameters; + +/** + Makes a POST request to the provided URL passing form URL encoded + parameters. + + Form URL-encoding is the standard way to POST on the Internet, so + probably this is what you want. If it doesn’t work, try the `+POST:JSON` + variant. + + id url = @"http://jsonplaceholder.typicode.com/posts"; + id params = @{@"title": @"foo", @"body": @"bar", @"userId": @1}; + [NSURLConnection POST:url formURLEncodedParameters:params].then(^(NSDictionary *jsonResponse){ + // PromiseKit decodes the JSON dictionary (if it’s JSON) + }); + + @param urlString The URL to request. + + @param parameters The parameters to be form URL-encoded and passed as the POST body. + + @return A promise that fulfills with three parameters: + + 1) The deserialized data response. + 2) The `NSHTTPURLResponse`. + 3) The raw `NSData` response. +*/ ++ (AnyPromise *)POST:(NSString *)urlString formURLEncodedParameters:(NSDictionary *)parameters; + +/** + Makes a POST request to the provided URL passing JSON encoded parameters. + + Most web servers nowadays support POST with either JSON or form + URL-encoding. If in doubt try form URL-encoded parameters first. + + id url = @"http://jsonplaceholder.typicode.com/posts"; + id params = @{@"title": @"foo", @"body": @"bar", @"userId": @1}; + [NSURLConnection POST:url JSON:params].then(^(NSDictionary *jsonResponse){ + // PromiseKit decodes the JSON dictionary (if it’s JSON) + }); + + @param urlString The URL to request. + + @param JSONParameters The parameters to be JSON encoded and passed as the POST body. + + @return A promise that fulfills with three parameters: + + 1) The deserialized data response. + 2) The `NSHTTPURLResponse`. + 3) The raw `NSData` response. +*/ ++ (AnyPromise *)POST:(NSString *)urlString JSON:(NSDictionary *)JSONParameters; + +/** + Makes a PUT request to the provided URL passing form URL-encoded + parameters. + + id url = @"http://jsonplaceholder.typicode.com/posts/1"; + id params = @{@"id": @1, @"title": @"foo", @"body": @"bar", @"userId": @1}; + [NSURLConnection PUT:url formURLEncodedParameters:params].then(^(NSDictionary *jsonResponse){ + // PromiseKit decodes the JSON dictionary (if it’s JSON) + }); + + @param urlString The URL to request. + + @param parameters The parameters to be form URL-encoded and passed as the HTTP body. + + @return A promise that fulfills with three parameters: + + 1) The deserialized data response. + 2) The `NSHTTPURLResponse`. + 3) The raw `NSData` response. +*/ ++ (AnyPromise *)PUT:(NSString *)urlString formURLEncodedParameters:(NSDictionary *)params; + +/** + Makes a DELETE request to the provided URL passing form URL-encoded + parameters. + + id url = @"http://jsonplaceholder.typicode.com/posts/1"; + id params = nil; + [NSURLConnection DELETE:url formURLEncodedParameters:params].then(^(NSDictionary *jsonResponse){ + // PromiseKit decodes the JSON dictionary (if it’s JSON) + }); + + @param urlString The URL to request. + + @param parameters The parameters to be form URL-encoded and passed as the HTTP body. + + @return A promise that fulfills with three parameters: + + 1) The deserialized data response. + 2) The `NSHTTPURLResponse`. + 3) The raw `NSData` response. +*/ ++ (AnyPromise *)DELETE:(NSString *)urlString formURLEncodedParameters:(NSDictionary *)params; + +/** + Makes an HTTP request using the parameters specified by the provided URL + request. + + This variant is less convenient, but provides you complete control over + your `NSURLRequest`. Often this is necessary if your API requires + authentication in the HTTP headers. + + Also, for example, if you need to send a multipart form request then + PromiseKit provides no convenience method for this, however using + OMGHTTPURLRQ (a dependency of this category), we can accomplish our + requirements: + + OMGMultipartFormData *multipartFormData = [OMGMultipartFormData new]; + + NSData *data1 = [NSData dataWithContentsOfFile:@"myimage1.png"]; + [multipartFormData addFile:data1 parameterName:@"file1" filename:@"myimage1.png" contentType:@"image/png"]; + + NSMutableURLRequest *rq = [OMGHTTPURLRQ POST:url:multipartFormData]; + + [NSURLConnection promise:rq].then(^(id response){ + //… + }); + + @param request The URL request. + + @return A promise that fulfills with three parameters: + + 1) The deserialized data response. + 2) The `NSHTTPURLResponse`. + 3) The raw `NSData` response. +*/ ++ (AnyPromise *)promise:(NSURLRequest *)request; + +@end diff --git a/Pods/PromiseKit/Categories/Foundation/NSURLConnection+AnyPromise.m b/Pods/PromiseKit/Categories/Foundation/NSURLConnection+AnyPromise.m new file mode 100644 index 0000000..862ef0f --- /dev/null +++ b/Pods/PromiseKit/Categories/Foundation/NSURLConnection+AnyPromise.m @@ -0,0 +1,178 @@ +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import "NSURLConnection+AnyPromise.h" +#import +#import +#import + + +@implementation NSURLConnection (PromiseKit) + ++ (AnyPromise *)GET:(id)urlFormat, ... { + if ([urlFormat isKindOfClass:[NSString class]]) { + va_list arguments; + va_start(arguments, urlFormat); + urlFormat = [[NSString alloc] initWithFormat:urlFormat arguments:arguments]; + va_end(arguments); + } else if ([urlFormat isKindOfClass:[NSURL class]]) { + NSMutableURLRequest *rq = [[NSMutableURLRequest alloc] initWithURL:urlFormat]; + [rq setValue:OMGUserAgent() forHTTPHeaderField:@"User-Agent"]; + return [self promise:rq]; + } else { + urlFormat = [urlFormat description]; + } + id err; + id rq = [OMGHTTPURLRQ GET:urlFormat:nil error:&err]; + if (err) return [AnyPromise promiseWithValue:err]; + return [self promise:rq]; +} + ++ (AnyPromise *)GET:(NSString *)url query:(NSDictionary *)params { + id err; + id rq = [OMGHTTPURLRQ GET:url:params error:&err]; + if (err) return [AnyPromise promiseWithValue:err]; + return [self promise:rq]; +} + ++ (AnyPromise *)POST:(NSString *)url formURLEncodedParameters:(NSDictionary *)params { + id err; + id rq = [OMGHTTPURLRQ POST:url:params error:&err]; + if (err) return [AnyPromise promiseWithValue:err]; + return [self promise:rq]; +} + ++ (AnyPromise *)POST:(NSString *)urlString JSON:(NSDictionary *)params { + id err; + id rq = [OMGHTTPURLRQ POST:urlString JSON:params error:&err]; + if (err) [AnyPromise promiseWithValue:err]; + return [self promise:rq]; +} + ++ (AnyPromise *)PUT:(NSString *)url formURLEncodedParameters:(NSDictionary *)params { + id err; + id rq = [OMGHTTPURLRQ PUT:url:params error:&err]; + if (err) [AnyPromise promiseWithValue:err]; + return [self promise:rq]; + +} + ++ (AnyPromise *)DELETE:(NSString *)url formURLEncodedParameters:(NSDictionary *)params { + id err; + id rq = [OMGHTTPURLRQ DELETE:url :params error:&err]; + if (err) [AnyPromise promiseWithValue:err]; + return [self promise:rq]; +} + ++ (AnyPromise *)promise:(NSURLRequest *)rq { + static id q = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + q = [NSOperationQueue new]; + }); + + return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) { + [NSURLConnection sendAsynchronousRequest:rq queue:q completionHandler:^(id rsp, id data, id urlError) { + assert(![NSThread isMainThread]); + + PMKResolver fulfiller = ^(id responseObject){ + resolve(PMKManifold(responseObject, rsp, data)); + }; + PMKResolver rejecter = ^(NSError *error){ + id userInfo = error.userInfo.mutableCopy ?: [NSMutableDictionary new]; + if (data) userInfo[PMKURLErrorFailingDataKey] = data; + if (rsp) userInfo[PMKURLErrorFailingURLResponseKey] = rsp; + error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; + resolve(error); + }; + + NSStringEncoding (^stringEncoding)() = ^NSStringEncoding{ + id encodingName = [rsp textEncodingName]; + if (encodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)encodingName); + if (encoding != kCFStringEncodingInvalidId) + return CFStringConvertEncodingToNSStringEncoding(encoding); + } + return NSUTF8StringEncoding; + }; + + if (urlError) { + rejecter(urlError); + } else if (![rsp isKindOfClass:[NSHTTPURLResponse class]]) { + fulfiller(data); + } else if ([rsp statusCode] < 200 || [rsp statusCode] >= 300) { + id info = @{ + NSLocalizedDescriptionKey: @"The server returned a bad HTTP response code", + NSURLErrorFailingURLStringErrorKey: rq.URL.absoluteString, + NSURLErrorFailingURLErrorKey: rq.URL + }; + id err = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadServerResponse userInfo:info]; + rejecter(err); + } else if (PMKHTTPURLResponseIsJSON(rsp)) { + // work around ever-so-common Rails workaround: https://github.com/rails/rails/issues/1742 + if ([rsp expectedContentLength] == 1 && [data isEqualToData:[NSData dataWithBytes:" " length:1]]) + return fulfiller(nil); + + NSError *err = nil; + id json = [NSJSONSerialization JSONObjectWithData:data options:PMKJSONDeserializationOptions error:&err]; + if (!err) { + fulfiller(json); + } else { + id userInfo = err.userInfo.mutableCopy; + if (data) { + NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding()]; + if (string) + userInfo[PMKURLErrorFailingStringKey] = string; + } + long long length = [rsp expectedContentLength]; + id bytes = length <= 0 ? @"" : [NSString stringWithFormat:@"%lld bytes", length]; + id fmt = @"The server claimed a %@ JSON response, but decoding failed with: %@"; + userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:fmt, bytes, userInfo[NSLocalizedDescriptionKey]]; + err = [NSError errorWithDomain:err.domain code:err.code userInfo:userInfo]; + rejecter(err); + } + #ifdef UIKIT_EXTERN + } else if (PMKHTTPURLResponseIsImage(rsp)) { + UIImage *image = [[UIImage alloc] initWithData:data]; + image = [[UIImage alloc] initWithCGImage:[image CGImage] scale:image.scale orientation:image.imageOrientation]; + if (image) + fulfiller(image); + else { + id info = @{ + NSLocalizedDescriptionKey: @"The server returned invalid image data", + NSURLErrorFailingURLStringErrorKey: rq.URL.absoluteString, + NSURLErrorFailingURLErrorKey: rq.URL + }; + id err = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:info]; + rejecter(err); + } + #endif + } else if (PMKHTTPURLResponseIsText(rsp)) { + id str = [[NSString alloc] initWithData:data encoding:stringEncoding()]; + if (str) + fulfiller(str); + else { + id info = @{ + NSLocalizedDescriptionKey: @"The server returned invalid string data", + NSURLErrorFailingURLStringErrorKey: rq.URL.absoluteString, + NSURLErrorFailingURLErrorKey: rq.URL + }; + id err = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:info]; + rejecter(err); + } + } else + fulfiller(data); + }]; + }]; + + #undef fulfiller +} + +@end diff --git a/Pods/PromiseKit/Categories/Foundation/NSURLConnection+Promise.swift b/Pods/PromiseKit/Categories/Foundation/NSURLConnection+Promise.swift new file mode 100644 index 0000000..dc1fe39 --- /dev/null +++ b/Pods/PromiseKit/Categories/Foundation/NSURLConnection+Promise.swift @@ -0,0 +1,74 @@ +import Foundation +import OMGHTTPURLRQ +#if !COCOAPODS +import PromiseKit +#endif + +/** + To import the `NSURLConnection` category: + + use_frameworks! + pod "PromiseKit/Foundation" + + Or `NSURLConnection` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + import PromiseKit +*/ +extension NSURLConnection { + public class func GET(URL: String, query: [NSObject:AnyObject]? = nil) -> URLDataPromise { + return go(try OMGHTTPURLRQ.GET(URL, query)) + } + + public class func POST(URL: String, formData: [NSObject:AnyObject]? = nil) -> URLDataPromise { + return go(try OMGHTTPURLRQ.POST(URL, formData)) + } + + public class func POST(URL: String, JSON: [NSObject:AnyObject]) -> URLDataPromise { + return go(try OMGHTTPURLRQ.POST(URL, JSON: JSON)) + } + + public class func POST(URL: String, multipartFormData: OMGMultipartFormData) -> URLDataPromise { + return go(try OMGHTTPURLRQ.POST(URL, multipartFormData)) + } + + public class func PUT(URL: String, formData: [NSObject:AnyObject]? = nil) -> URLDataPromise { + return go(try OMGHTTPURLRQ.PUT(URL, formData)) + } + + public class func PUT(URL: String, JSON: [NSObject:AnyObject]) -> URLDataPromise { + return go(try OMGHTTPURLRQ.PUT(URL, JSON: JSON)) + } + + public class func DELETE(URL: String) -> URLDataPromise { + return go(try OMGHTTPURLRQ.DELETE(URL, nil)) + } + + public class func promise(request: NSURLRequest) -> URLDataPromise { + return go(request) + } +} + +private func go(@autoclosure body: () throws -> NSURLRequest) -> URLDataPromise { + do { + var request = try body() + + if request.valueForHTTPHeaderField("User-Agent") == nil { + let rq = request.mutableCopy() as! NSMutableURLRequest + rq.setValue(OMGUserAgent(), forHTTPHeaderField: "User-Agent") + request = rq + } + + return URLDataPromise.go(request) { completionHandler in + NSURLConnection.sendAsynchronousRequest(request, queue: Q, completionHandler: { completionHandler($1, $0, $2) }) + } + } catch { + return URLDataPromise(error: error) + } +} + +private let Q = NSOperationQueue() diff --git a/Pods/PromiseKit/Categories/Foundation/NSURLSession+Promise.swift b/Pods/PromiseKit/Categories/Foundation/NSURLSession+Promise.swift new file mode 100644 index 0000000..6dccdff --- /dev/null +++ b/Pods/PromiseKit/Categories/Foundation/NSURLSession+Promise.swift @@ -0,0 +1,71 @@ +import Foundation +import OMGHTTPURLRQ +#if !COCOAPODS +import PromiseKit +#endif + +//TODO cancellation + +/** + To import the `NSURLSession` category: + + use_frameworks! + pod "PromiseKit/Foundation" + + Or `NSURLSession` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + import PromiseKit + + We provide convenience categories for the `sharedSession`, or + an instance method `promise`. If you need more complicated behavior + we recommend wrapping that usage in a Promise initializer. +*/ +extension NSURLSession { + public class func GET(URL: String, query: [NSObject: AnyObject]? = nil) -> URLDataPromise { + return start(try OMGHTTPURLRQ.GET(URL, query)) + } + + public class func POST(URL: String, formData: [NSObject: AnyObject]? = nil) -> URLDataPromise { + return start(try OMGHTTPURLRQ.POST(URL, formData)) + } + + public class func POST(URL: String, multipartFormData: OMGMultipartFormData) -> URLDataPromise { + return start(try OMGHTTPURLRQ.POST(URL, multipartFormData)) + } + + public class func PUT(URL: String) -> URLDataPromise { + return start(try OMGHTTPURLRQ.PUT(URL, nil)) + } + + public class func DELETE(URL: String) -> URLDataPromise { + return start(try OMGHTTPURLRQ.DELETE(URL, nil)) + } + + public func promise(request: NSURLRequest) -> URLDataPromise { + return start(request, session: self) + } +} + +private func start(@autoclosure body: () throws -> NSURLRequest, session: NSURLSession = NSURLSession.sharedSession()) -> URLDataPromise { + do { + var request = try body() + + if request.valueForHTTPHeaderField("User-Agent") == nil { + let rq = request.mutableCopy() as! NSMutableURLRequest + rq.setValue(OMGUserAgent(), forHTTPHeaderField: "User-Agent") + request = rq + } + + return URLDataPromise.go(request) { completionHandler in + let task = session.dataTaskWithRequest(request, completionHandler: completionHandler) + task.resume() + } + } catch { + return URLDataPromise(error: error) + } +} diff --git a/Pods/PromiseKit/Categories/Foundation/afterlife.swift b/Pods/PromiseKit/Categories/Foundation/afterlife.swift new file mode 100644 index 0000000..06d5aa5 --- /dev/null +++ b/Pods/PromiseKit/Categories/Foundation/afterlife.swift @@ -0,0 +1,29 @@ +import Foundation +#if !COCOAPODS +import PromiseKit +#endif + +/** + @return A promise that resolves when the provided object deallocates + + @warning *Important* The promise is not guarenteed to resolve immediately + when the provided object is deallocated. So you cannot write code that + depends on exact timing. +*/ +public func after(life object: NSObject) -> Promise { + var reaper = objc_getAssociatedObject(object, &handle) as? GrimReaper + if reaper == nil { + reaper = GrimReaper() + objc_setAssociatedObject(object, &handle, reaper, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + return reaper!.promise +} + +private var handle: UInt8 = 0 + +private class GrimReaper: NSObject { + deinit { + fulfill() + } + let (promise, fulfill, _) = Promise.pendingPromise() +} diff --git a/Pods/PromiseKit/Categories/QuartzCore/CALayer+AnyPromise.h b/Pods/PromiseKit/Categories/QuartzCore/CALayer+AnyPromise.h new file mode 100644 index 0000000..184d559 --- /dev/null +++ b/Pods/PromiseKit/Categories/QuartzCore/CALayer+AnyPromise.h @@ -0,0 +1,40 @@ +// +// CALayer+AnyPromise.h +// +// Created by María Patricia Montalvo Dzib on 24/11/14. +// Copyright (c) 2014 Aluxoft SCP. All rights reserved. +// + +#import +#import + +/** + To import the `CALayer` category: + + use_frameworks! + pod "PromiseKit/QuartzCore" + + Or `CALayer` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + #import +*/ +@interface CALayer (PromiseKit) + +/** + Add the specified animation object to the layer’s render tree. + + @return A promise that thens two parameters: + + 1. `@YES` if the animation progressed entirely to completion. + 2. The `CAAnimation` object. + + @see addAnimation:forKey +*/ +- (AnyPromise *)promiseAnimation:(CAAnimation *)animation forKey:(NSString *)key; + +@end diff --git a/Pods/PromiseKit/Categories/QuartzCore/CALayer+AnyPromise.m b/Pods/PromiseKit/Categories/QuartzCore/CALayer+AnyPromise.m new file mode 100644 index 0000000..2a0d6aa --- /dev/null +++ b/Pods/PromiseKit/Categories/QuartzCore/CALayer+AnyPromise.m @@ -0,0 +1,39 @@ +// +// CALayer+PromiseKit.m +// +// Created by María Patricia Montalvo Dzib on 24/11/14. +// Copyright (c) 2014 Aluxoft SCP. All rights reserved. +// + +#import +#import "CALayer+AnyPromise.h" + + +@interface PMKCAAnimationDelegate : NSObject { +@public + PMKResolver resolve; + CAAnimation *animation; +} +@end + +@implementation PMKCAAnimationDelegate + +- (void)animationDidStop:(CAAnimation *)ignoreOrRetainCycleHappens finished:(BOOL)flag { + resolve(PMKManifold(@(flag), animation)); + animation.delegate = nil; +} + +@end + + + +@implementation CALayer (PromiseKit) + +- (AnyPromise *)promiseAnimation:(CAAnimation *)animation forKey:(NSString *)key { + PMKCAAnimationDelegate *d = animation.delegate = [PMKCAAnimationDelegate new]; + d->animation = animation; + [self addAnimation:animation forKey:key]; + return [[AnyPromise alloc] initWithResolver:&d->resolve]; +} + +@end diff --git a/Pods/PromiseKit/Categories/UIKit/PMKAlertController.swift b/Pods/PromiseKit/Categories/UIKit/PMKAlertController.swift new file mode 100644 index 0000000..20b0c2d --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/PMKAlertController.swift @@ -0,0 +1,79 @@ +import UIKit +#if !COCOAPODS +import PromiseKit +#endif + +//TODO tests +//TODO NSCoding + +/** + A “promisable” UIAlertController. + + UIAlertController is not a suitable API for an extension; it has closure + handlers on its main API for each button and an extension would have to + either replace all these when the controller is presented or force you to + use an extended addAction method, which would be easy to forget part of + the time. Hence we provide a facade pattern that can be promised. + + let alert = PMKAlertController("OHAI") + let sup = alert.addActionWithTitle("SUP") + let bye = alert.addActionWithTitle("BYE") + promiseViewController(alert).then { action in + switch action { + case is sup: + //… + case is bye: + //… + } + } +*/ +public class PMKAlertController { + public var title: String? { return UIAlertController.title } + public var message: String? { return UIAlertController.message } + public var preferredStyle: UIAlertControllerStyle { return UIAlertController.preferredStyle } + public var actions: [UIAlertAction] { return UIAlertController.actions } + public var textFields: [UITextField]? { return UIAlertController.textFields } + + public required init(title: String?, message: String? = nil, preferredStyle: UIAlertControllerStyle = .Alert) { + UIAlertController = UIKit.UIAlertController(title: title, message: message, preferredStyle: preferredStyle) + } + + public func addActionWithTitle(title: String, style: UIAlertActionStyle = .Default) -> UIAlertAction { + let action = UIAlertAction(title: title, style: style) { action in + if style != UIAlertActionStyle.Cancel { + self.fulfill(action) + } else { + self.reject(Error.Cancelled) + } + } + UIAlertController.addAction(action) + return action + } + + public func addTextFieldWithConfigurationHandler(configurationHandler: ((UITextField) -> Void)?) { + UIAlertController.addTextFieldWithConfigurationHandler(configurationHandler) + } + + private let UIAlertController: UIKit.UIAlertController + private let (promise, fulfill, reject) = Promise.pendingPromise() + private var retainCycle: PMKAlertController? + + public enum Error: CancellableErrorType { + case Cancelled + + public var cancelled: Bool { + return self == .Cancelled + } + } +} + +extension UIViewController { + public func promiseViewController(vc: PMKAlertController, animated: Bool = true, completion: (() -> Void)? = nil) -> Promise { + vc.retainCycle = vc + presentViewController(vc.UIAlertController, animated: true, completion: nil) + vc.promise.always { _ -> Void in + vc.retainCycle = nil + } + return vc.promise + } +} diff --git a/Pods/PromiseKit/Categories/UIKit/UIActionSheet+AnyPromise.h b/Pods/PromiseKit/Categories/UIKit/UIActionSheet+AnyPromise.h new file mode 100644 index 0000000..d7739fe --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIActionSheet+AnyPromise.h @@ -0,0 +1,42 @@ +#import +#import + +/** + To import the `UIActionSheet` category: + + use_frameworks! + pod "PromiseKit/UIKit" + + Or `UIKit` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + #import +*/ +@interface UIActionSheet (PromiseKit) + +/** + Displays the action sheet originating from the specified view. + + UIActionSheet *sheet = [UIActionSheet new]; + sheet.title = @"OHAI"; + [sheet addButtonWithTitle:@"OK"]; + [sheet promiseInView:nil].then(^(NSNumber *dismissedButtonIndex){ + //… + }); + + @param view The view from which the action sheet originates. + + @warning *Important* If a cancelButtonIndex is set the promise will be *cancelled* if that button is pressed. Cancellation in PromiseKit has special behavior, see the relevant documentation for more details. + + @return A promise that fulfills with two parameters: + + 1) The index (NSNumber) of the button that was tapped to dismiss the sheet. + 2) This action sheet. +*/ +- (AnyPromise *)promiseInView:(UIView *)view; + +@end diff --git a/Pods/PromiseKit/Categories/UIKit/UIActionSheet+AnyPromise.m b/Pods/PromiseKit/Categories/UIKit/UIActionSheet+AnyPromise.m new file mode 100644 index 0000000..5c8751a --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIActionSheet+AnyPromise.m @@ -0,0 +1,41 @@ +#import +#import "UIActionSheet+AnyPromise.h" + + +@interface PMKActionSheetDelegate : NSObject { +@public + id retainCycle; + PMKResolver resolve; +} +@end + + +@implementation PMKActionSheetDelegate + +- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex { + if (buttonIndex == actionSheet.cancelButtonIndex) { + resolve([NSError cancelledError]); + } else { + resolve(PMKManifold(@(buttonIndex), actionSheet)); + } + retainCycle = nil; +} + +@end + + +@implementation UIActionSheet (PromiseKit) + +- (AnyPromise *)promiseInView:(UIView *)view { + PMKActionSheetDelegate *d = [PMKActionSheetDelegate new]; + d->retainCycle = self.delegate = d; + [self showInView:view]; + + if (self.numberOfButtons == 1 && self.cancelButtonIndex == 0) { + NSLog(@"PromiseKit: An action sheet is being promised with a single button that is set as the cancelButtonIndex. The promise *will* be cancelled which may result in unexpected behavior. See http://promisekit.org/PromiseKit-2.0-Released/ for cancellation documentation."); + } + + return [[AnyPromise alloc] initWithResolver:&d->resolve]; +} + +@end diff --git a/Pods/PromiseKit/Categories/UIKit/UIActionSheet+Promise.swift b/Pods/PromiseKit/Categories/UIKit/UIActionSheet+Promise.swift new file mode 100644 index 0000000..3b4bf6b --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIActionSheet+Promise.swift @@ -0,0 +1,59 @@ +import UIKit.UIActionSheet +#if !COCOAPODS +import PromiseKit +#endif + +/** + To import the `UIActionSheet` category: + + use_frameworks! + pod "PromiseKit/UIKit" + + Or `UIKit` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + import PromiseKit +*/ +extension UIActionSheet { + public func promiseInView(view: UIView) -> Promise { + let proxy = PMKActionSheetDelegate() + delegate = proxy + proxy.retainCycle = proxy + showInView(view) + + if numberOfButtons == 1 && cancelButtonIndex == 0 { + NSLog("PromiseKit: An action sheet is being promised with a single button that is set as the cancelButtonIndex. The promise *will* be cancelled which may result in unexpected behavior. See http://promisekit.org/PromiseKit-2.0-Released/ for cancellation documentation.") + } + + return proxy.promise + } + + public enum Error: CancellableErrorType { + case Cancelled + + public var cancelled: Bool { + switch self { + case .Cancelled: return true + } + } + } +} + +private class PMKActionSheetDelegate: NSObject, UIActionSheetDelegate { + let (promise, fulfill, reject) = Promise.pendingPromise() + var retainCycle: NSObject? + + @objc func actionSheet(actionSheet: UIActionSheet, didDismissWithButtonIndex buttonIndex: Int) { + defer { retainCycle = nil } + + if buttonIndex != actionSheet.cancelButtonIndex { + fulfill(buttonIndex) + } else { + reject(UIActionSheet.Error.Cancelled) + } + } +} diff --git a/Pods/PromiseKit/Categories/UIKit/UIAlertView+AnyPromise.h b/Pods/PromiseKit/Categories/UIKit/UIAlertView+AnyPromise.h new file mode 100644 index 0000000..744e8e2 --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIAlertView+AnyPromise.h @@ -0,0 +1,40 @@ +#import +#import + +/** + To import the `UIAlertView` category: + + use_frameworks! + pod "PromiseKit/UIKit" + + Or `UIKit` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + #import +*/ +@interface UIAlertView (PromiseKit) + +/** + Displays the alert view. + + UIAlertView *alert = [UIAlertView new]; + alert.title = @"OHAI"; + [alert addButtonWithTitle:@"OK"]; + [alert promise].then(^(NSNumber *dismissedButtonIndex){ + //… + }); + + @warning *Important* If a cancelButtonIndex is set the promise will be *cancelled* if that button is pressed. Cancellation in PromiseKit has special behavior, see the relevant documentation for more details. + + @return A promise the fulfills with two parameters: + + 1) The index of the button that was tapped to dismiss the alert. + 2) This alert view. +*/ +- (AnyPromise *)promise; + +@end diff --git a/Pods/PromiseKit/Categories/UIKit/UIAlertView+AnyPromise.m b/Pods/PromiseKit/Categories/UIKit/UIAlertView+AnyPromise.m new file mode 100644 index 0000000..ea77443 --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIAlertView+AnyPromise.m @@ -0,0 +1,41 @@ +#import +#import "UIAlertView+AnyPromise.h" + + +@interface PMKAlertViewDelegate : NSObject { +@public + PMKResolver resolve; + id retainCycle; +} +@end + + +@implementation PMKAlertViewDelegate + +- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { + if (buttonIndex != alertView.cancelButtonIndex) { + resolve(PMKManifold(@(buttonIndex), alertView)); + } else { + resolve([NSError cancelledError]); + } + retainCycle = nil; +} + +@end + + +@implementation UIAlertView (PromiseKit) + +- (AnyPromise *)promise { + PMKAlertViewDelegate *d = [PMKAlertViewDelegate new]; + d->retainCycle = self.delegate = d; + [self show]; + + if (self.numberOfButtons == 1 && self.cancelButtonIndex == 0) { + NSLog(@"PromiseKit: An alert view is being promised with a single button that is set as the cancelButtonIndex. The promise *will* be cancelled which may result in unexpected behavior. See http://promisekit.org/PromiseKit-2.0-Released/ for cancellation documentation."); + } + + return [[AnyPromise alloc] initWithResolver:&d->resolve]; +} + +@end diff --git a/Pods/PromiseKit/Categories/UIKit/UIAlertView+Promise.swift b/Pods/PromiseKit/Categories/UIKit/UIAlertView+Promise.swift new file mode 100644 index 0000000..1af023c --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIAlertView+Promise.swift @@ -0,0 +1,58 @@ +import Foundation +import UIKit.UIAlertView +#if !COCOAPODS +import PromiseKit +#endif + +/** + To import the `UIActionSheet` category: + + use_frameworks! + pod "PromiseKit/UIKit" + + Or `UIKit` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + import PromiseKit +*/ +extension UIAlertView { + public func promise() -> Promise { + let proxy = PMKAlertViewDelegate() + delegate = proxy + proxy.retainCycle = proxy + show() + + if numberOfButtons == 1 && cancelButtonIndex == 0 { + NSLog("PromiseKit: An alert view is being promised with a single button that is set as the cancelButtonIndex. The promise *will* be cancelled which may result in unexpected behavior. See http://promisekit.org/PromiseKit-2.0-Released/ for cancellation documentation.") + } + + return proxy.promise + } + + public enum Error: CancellableErrorType { + case Cancelled + + public var cancelled: Bool { + switch self { + case .Cancelled: return true + } + } + } +} + +private class PMKAlertViewDelegate: NSObject, UIAlertViewDelegate { + let (promise, fulfill, reject) = Promise.pendingPromise() + var retainCycle: NSObject? + + @objc func alertView(alertView: UIAlertView, didDismissWithButtonIndex buttonIndex: Int) { + if buttonIndex != alertView.cancelButtonIndex { + fulfill(buttonIndex) + } else { + reject(UIAlertView.Error.Cancelled) + } + } +} diff --git a/Pods/PromiseKit/Categories/UIKit/UIView+AnyPromise.h b/Pods/PromiseKit/Categories/UIKit/UIView+AnyPromise.h new file mode 100644 index 0000000..5f019c7 --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIView+AnyPromise.h @@ -0,0 +1,80 @@ +#import +#import + +// Created by Masafumi Yoshida on 2014/07/11. +// Copyright (c) 2014年 DeNA. All rights reserved. + +/** + To import the `UIView` category: + + use_frameworks! + pod "PromiseKit/UIKit" + + Or `UIKit` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + #import +*/ +@interface UIView (PromiseKit) + +/** + Animate changes to one or more views using the specified duration. + + @param duration The total duration of the animations, measured in + seconds. If you specify a negative value or 0, the changes are made + without animating them. + + @param animations A block object containing the changes to commit to the + views. + + @return A promise that fulfills with a boolean NSNumber indicating + whether or not the animations actually finished. +*/ ++ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations; + +/** + Animate changes to one or more views using the specified duration, delay, + options, and completion handler. + + @param duration The total duration of the animations, measured in + seconds. If you specify a negative value or 0, the changes are made + without animating them. + + @param delay The amount of time (measured in seconds) to wait before + beginning the animations. Specify a value of 0 to begin the animations + immediately. + + @param options A mask of options indicating how you want to perform the + animations. For a list of valid constants, see UIViewAnimationOptions. + + @param animations A block object containing the changes to commit to the + views. + + @return A promise that fulfills with a boolean NSNumber indicating + whether or not the animations actually finished. +*/ ++ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations; + +/** + Performs a view animation using a timing curve corresponding to the + motion of a physical spring. + + @return A promise that fulfills with a boolean NSNumber indicating + whether or not the animations actually finished. +*/ ++ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations; + +/** + Creates an animation block object that can be used to set up + keyframe-based animations for the current view. + + @return A promise that fulfills with a boolean NSNumber indicating + whether or not the animations actually finished. +*/ ++ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options keyframeAnimations:(void (^)(void))animations; + +@end diff --git a/Pods/PromiseKit/Categories/UIKit/UIView+AnyPromise.m b/Pods/PromiseKit/Categories/UIKit/UIView+AnyPromise.m new file mode 100644 index 0000000..04ee940 --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIView+AnyPromise.m @@ -0,0 +1,64 @@ +// +// UIView+PromiseKit_UIAnimation.m +// YahooDenaStudy +// +// Created by Masafumi Yoshida on 2014/07/11. +// Copyright (c) 2014年 DeNA. All rights reserved. +// + +#import +#import "UIView+AnyPromise.h" + + +#define CopyPasta \ + NSAssert([NSThread isMainThread], @"UIKit animation must be performed on the main thread"); \ + \ + if (![NSThread isMainThread]) { \ + id error = [NSError errorWithDomain:PMKErrorDomain code:PMKInvalidUsageError userInfo:@{NSLocalizedDescriptionKey: @"Animation was attempted on a background thread"}]; \ + return [AnyPromise promiseWithValue:error]; \ + } \ + \ + PMKResolver resolve = nil; \ + AnyPromise *promise = [[AnyPromise alloc] initWithResolver:&resolve]; + + +@implementation UIView (PromiseKit) + ++ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations { + return [self promiseWithDuration:duration delay:0 options:0 animations:animations]; +} + ++ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void(^)(void))animations +{ + CopyPasta; + + [UIView animateWithDuration:duration delay:delay options:options animations:animations completion:^(BOOL finished) { + resolve(@(finished)); + }]; + + return promise; +} + ++ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void(^)(void))animations +{ + CopyPasta; + + [UIView animateWithDuration:duration delay:delay usingSpringWithDamping:dampingRatio initialSpringVelocity:velocity options:options animations:animations completion:^(BOOL finished) { + resolve(@(finished)); + }]; + + return promise; +} + ++ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options keyframeAnimations:(void(^)(void))animations +{ + CopyPasta; + + [UIView animateKeyframesWithDuration:duration delay:delay options:options animations:animations completion:^(BOOL finished) { + resolve(@(finished)); + }]; + + return promise; +} + +@end diff --git a/Pods/PromiseKit/Categories/UIKit/UIView+Promise.swift b/Pods/PromiseKit/Categories/UIKit/UIView+Promise.swift new file mode 100644 index 0000000..387fe61 --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIView+Promise.swift @@ -0,0 +1,48 @@ +import UIKit.UIView +#if !COCOAPODS +import PromiseKit +#endif + +/** + To import the `UIView` category: + + use_frameworks! + pod "PromiseKit/UIKit" + + Or `UIKit` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + import PromiseKit +*/ +extension UIView { + /** + Animate changes to one or more views using the specified duration, delay, + options, and completion handler. + + @param duration The total duration of the animations, measured in + seconds. If you specify a negative value or 0, the changes are made + without animating them. + + @param delay The amount of time (measured in seconds) to wait before + beginning the animations. Specify a value of 0 to begin the animations + immediately. + + @param options A mask of options indicating how you want to perform the + animations. For a list of valid constants, see UIViewAnimationOptions. + + @param animations A block object containing the changes to commit to the + views. + + @return A promise that fulfills with a boolean NSNumber indicating + whether or not the animations actually finished. + */ + public class func animate(duration duration: NSTimeInterval = 0.3, delay: NSTimeInterval = 0, options: UIViewAnimationOptions = UIViewAnimationOptions(), animations: () -> Void) -> Promise { + return Promise { fulfill, _ in + self.animateWithDuration(duration, delay: delay, options: options, animations: animations, completion: fulfill) + } + } +} diff --git a/Pods/PromiseKit/Categories/UIKit/UIViewController+AnyPromise.h b/Pods/PromiseKit/Categories/UIKit/UIViewController+AnyPromise.h new file mode 100644 index 0000000..b131488 --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIViewController+AnyPromise.h @@ -0,0 +1,90 @@ +#import +#import + +/** + To import the `UIViewController` category: + + use_frameworks! + pod "PromiseKit/UIKit" + + Or `UIKit` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + #import +*/ +@interface UIViewController (PromiseKit) + +/** + Presents a view controller modally. + + If the view controller is one of the following: + + - MFMailComposeViewController + - MFMessageComposeViewController + - UIImagePickerController + - SLComposeViewController + + Then PromiseKit presents the view controller returning a promise that is + resolved as per the documentation for those classes. Eg. if you present a + `UIImagePickerController` the view controller will be presented for you + and the returned promise will resolve with the media the user selected. + + [self promiseViewController:[MFMailComposeViewController new] animated:YES completion:nil].then(^{ + //… + }); + + Otherwise PromiseKit expects your view controller to implement a + `promise` property. This promise will be returned from this method and + presentation and dismissal of the presented view controller will be + managed for you. + + @interface MyViewController: UIViewController + @property (readonly) AnyPromise *promise; + @end + + @implementation MyViewController { + PMKResolver resolve; + } + + - (void)viewDidLoad { + _promise = [[AnyPromise alloc] initWithResolver:&resolve]; + } + + - (void)later { + resolve(@"some fulfilled value"); + } + + @end + + + + [self promiseViewController:[MyViewController new] aniamted:YES completion:nil].then(^(id value){ + // value == @"some fulfilled value" + }); + + @return A promise that can be resolved by the presented view controller. +*/ +- (AnyPromise *)promiseViewController:(UIViewController *)vc animated:(BOOL)animated completion:(void (^)(void))block; + +@end + + + +@interface UIViewController (PMKUnavailable) + +#define PMKRationale \ + "The promiseViewController system has been rennovated: the fullfil and " \ + "reject category methods have been removed due to runtime safety " \ + "concerns and instead you should implement a -promise property on your " \ + "view controller subclass. @see promiseViewController:animated:completion:" + +- (void)fulfill:(id)value __attribute__((unavailable(PMKRationale))); +- (void)reject:(NSError *)value __attribute__((unavailable(PMKRationale))); + +#undef PMKRationale + +@end diff --git a/Pods/PromiseKit/Categories/UIKit/UIViewController+AnyPromise.m b/Pods/PromiseKit/Categories/UIKit/UIViewController+AnyPromise.m new file mode 100644 index 0000000..2211b37 --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIViewController+AnyPromise.m @@ -0,0 +1,128 @@ +#import +#import +#import +#import "UIViewController+AnyPromise.h" + +@interface PMKGenericDelegate : NSObject { +@public + PMKResolver resolve; +} ++ (instancetype)delegateWithPromise:(AnyPromise **)promise; +@end + + +@implementation UIViewController (PromiseKit) + +- (AnyPromise *)promiseViewController:(UIViewController *)vc animated:(BOOL)animated completion:(void (^)(void))block { + __kindof UIViewController *vc2present = vc; + AnyPromise *promise = nil; + + if ([vc isKindOfClass:NSClassFromString(@"MFMailComposeViewController")]) { + PMKGenericDelegate *delegate = [PMKGenericDelegate delegateWithPromise:&promise]; + [vc setValue:delegate forKey:@"mailComposeDelegate"]; + } + else if ([vc isKindOfClass:NSClassFromString(@"MFMessageComposeViewController")]) { + PMKGenericDelegate *delegate = [PMKGenericDelegate delegateWithPromise:&promise]; + [vc setValue:delegate forKey:@"messageComposeDelegate"]; + } + else if ([vc isKindOfClass:NSClassFromString(@"UIImagePickerController")]) { + PMKGenericDelegate *delegate = [PMKGenericDelegate delegateWithPromise:&promise]; + ((UIImagePickerController *)vc).delegate = delegate; + } + else if ([vc isKindOfClass:NSClassFromString(@"SLComposeViewController")]) { + PMKResolver resolve; + promise = [[AnyPromise alloc] initWithResolver:&resolve]; + [vc setValue:^(NSInteger result){ + if (result == 0) { + resolve([NSError cancelledError]); + } else { + resolve(@(result)); + } + } forKey:@"completionHandler"]; + } + else if ([vc isKindOfClass:[UINavigationController class]]) + vc = [(id)vc viewControllers].firstObject; + + if (!vc) { + id userInfo = @{NSLocalizedDescriptionKey: @"nil or effective nil passed to promiseViewController"}; + id err = [NSError errorWithDomain:PMKErrorDomain code:PMKInvalidUsageError userInfo:userInfo]; + return [AnyPromise promiseWithValue:err]; + } + + if (!promise) { + if (![vc respondsToSelector:NSSelectorFromString(@"promise")]) { + id userInfo = @{NSLocalizedDescriptionKey: @"ViewController is not promisable"}; + id err = [NSError errorWithDomain:PMKErrorDomain code:PMKInvalidUsageError userInfo:userInfo]; + return [AnyPromise promiseWithValue:err]; + } + + promise = [vc valueForKey:@"promise"]; + + if (![promise isKindOfClass:[AnyPromise class]]) { + id userInfo = @{NSLocalizedDescriptionKey: @"The promise property is nil or not of type AnyPromise"}; + id err = [NSError errorWithDomain:PMKErrorDomain code:PMKInvalidUsageError userInfo:userInfo]; + return [AnyPromise promiseWithValue:err]; + } + } + + if (!promise.pending) + return promise; + + [self presentViewController:vc2present animated:animated completion:block]; + + promise.finally(^{ + [vc2present.presentingViewController dismissViewControllerAnimated:animated completion:nil]; + }); + + return promise; +} + +@end + + + +@implementation PMKGenericDelegate { + id retainCycle; +} + ++ (instancetype)delegateWithPromise:(AnyPromise **)promise; { + PMKGenericDelegate *d = [PMKGenericDelegate new]; + d->retainCycle = d; + *promise = [[AnyPromise alloc] initWithResolver:&d->resolve]; + return d; +} + +- (void)mailComposeController:(id)controller didFinishWithResult:(int)result error:(NSError *)error { + if (error != nil) { + resolve(error); + } else if (result == 0) { + resolve([NSError cancelledError]); + } else { + resolve(@(result)); + } + retainCycle = nil; +} + +- (void)messageComposeViewController:(id)controller didFinishWithResult:(int)result { + if (result == 2) { + id userInfo = @{NSLocalizedDescriptionKey: @"The user’s attempt to save or send the message was unsuccessful."}; + id error = [NSError errorWithDomain:PMKErrorDomain code:PMKOperationFailed userInfo:userInfo]; + resolve(error); + } else { + resolve(@(result)); + } + retainCycle = nil; +} + +- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { + id img = info[UIImagePickerControllerEditedImage] ?: info[UIImagePickerControllerOriginalImage]; + resolve(PMKManifold(img, info)); + retainCycle = nil; +} + +- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { + resolve([NSError cancelledError]); + retainCycle = nil; +} + +@end diff --git a/Pods/PromiseKit/Categories/UIKit/UIViewController+Promise.swift b/Pods/PromiseKit/Categories/UIKit/UIViewController+Promise.swift new file mode 100644 index 0000000..c85a51b --- /dev/null +++ b/Pods/PromiseKit/Categories/UIKit/UIViewController+Promise.swift @@ -0,0 +1,145 @@ +import Foundation.NSError +import UIKit +#if !COCOAPODS +import PromiseKit +#endif + +/** + To import this `UIViewController` category: + + use_frameworks! + pod "PromiseKit/UIKit" + + Or `UIKit` is one of the categories imported by the umbrella pod: + + use_frameworks! + pod "PromiseKit" + + And then in your sources: + + import PromiseKit +*/ +extension UIViewController { + + public enum Error: ErrorType { + case NavigationControllerEmpty + case NoImageFound + case NotPromisable + case NotGenericallyPromisable + case NilPromisable + } + + public func promiseViewController(vc: UIViewController, animated: Bool = true, completion: (() -> Void)? = nil) -> Promise { + + let p: Promise = promise(vc) + if p.pending { + presentViewController(vc, animated: animated, completion: completion) + p.always { + vc.presentingViewController?.dismissViewControllerAnimated(animated, completion: nil) + } + } + + return p + } + + public func promiseViewController(nc: UINavigationController, animated: Bool = true, completion:(()->Void)? = nil) -> Promise { + if let vc = nc.viewControllers.first { + let p: Promise = promise(vc) + if p.pending { + presentViewController(nc, animated: animated, completion: completion) + p.always { + vc.presentingViewController?.dismissViewControllerAnimated(animated, completion: nil) + } + } + return p + } else { + return Promise(error: Error.NavigationControllerEmpty) + } + } + + public func promiseViewController(vc: UIImagePickerController, animated: Bool = true, completion: (() -> Void)? = nil) -> Promise { + let proxy = UIImagePickerControllerProxy() + vc.delegate = proxy + vc.mediaTypes = ["public.image"] // this promise can only resolve with a UIImage + presentViewController(vc, animated: animated, completion: completion) + return proxy.promise.then(on: zalgo) { info -> UIImage in + if let img = info[UIImagePickerControllerEditedImage] as? UIImage { + return img + } + if let img = info[UIImagePickerControllerOriginalImage] as? UIImage { + return img + } + throw Error.NoImageFound + }.always { + vc.presentingViewController?.dismissViewControllerAnimated(animated, completion: nil) + } + } + + public func promiseViewController(vc: UIImagePickerController, animated: Bool = true, completion: (() -> Void)? = nil) -> Promise<[String: AnyObject]> { + let proxy = UIImagePickerControllerProxy() + vc.delegate = proxy + presentViewController(vc, animated: animated, completion: completion) + return proxy.promise.always { + vc.presentingViewController?.dismissViewControllerAnimated(animated, completion: nil) + } + } +} + +@objc public protocol Promisable { + /** + Provide a promise for promiseViewController here. + + The resulting property must be annotated with @objc. + + Obviously return a Promise. There is an issue with generics and Swift and + protocols currently so we couldn't specify that. + */ + var promise: AnyObject! { get } +} + +private func promise(vc: UIViewController) -> Promise { + if !vc.conformsToProtocol(Promisable) { + return Promise(error: UIViewController.Error.NotPromisable) + } else if let promise = vc.valueForKeyPath("promise") as? Promise { + return promise + } else if let _: AnyObject = vc.valueForKeyPath("promise") { + return Promise(error: UIViewController.Error.NotGenericallyPromisable) + } else { + return Promise(error: UIViewController.Error.NilPromisable) + } +} + + +// internal scope because used by ALAssetsLibrary extension +@objc class UIImagePickerControllerProxy: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate { + let (promise, fulfill, reject) = Promise<[String : AnyObject]>.pendingPromise() + var retainCycle: AnyObject? + + required override init() { + super.init() + retainCycle = self + } + + func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { + fulfill(info) + retainCycle = nil + } + + func imagePickerControllerDidCancel(picker: UIImagePickerController) { + reject(UIImagePickerController.Error.Cancelled) + retainCycle = nil + } +} + + +extension UIImagePickerController { + public enum Error: CancellableErrorType { + case Cancelled + + public var cancelled: Bool { + switch self { + case .Cancelled: return true + } + } + } +} diff --git a/Pods/PromiseKit/README.markdown b/Pods/PromiseKit/README.markdown new file mode 100644 index 0000000..3a789fa --- /dev/null +++ b/Pods/PromiseKit/README.markdown @@ -0,0 +1,125 @@ +![PromiseKit](http://methylblue.com/junk/PMKBanner.png) + +Modern development is highly asynchronous: isn’t it about time we had tools that made programming asynchronously powerful, easy and delightful? + +```swift +UIApplication.sharedApplication().networkActivityIndicatorVisible = true + +when(fetchImage(), getLocation()).then { image, location in + self.imageView.image = image; + self.label.text = "Buy your cat a house in \(location)" +}.always { + UIApplication.sharedApplication().networkActivityIndicatorVisible = false +}.error { error in + UIAlertView(…).show() +} +``` + +PromiseKit is a thoughtful and complete implementation of promises for iOS and OS X with first-class support for **both** Objective-C *and* Swift. + +[![Join the chat at https://gitter.im/mxcl/PromiseKit](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mxcl/PromiseKit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![](https://img.shields.io/cocoapods/v/PromiseKit.svg?label=Current%20Release) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage) +[![codebeat](https://codebeat.co/badges/6a2fc7b4-cc8f-4865-a81d-644edd38c662)](https://codebeat.co/projects/github-com-mxcl-promisekit) + +# Which PromiseKit Should I Use? + +If you are writing a library, [**use PromiseKit 1.x**](https://github.com/mxcl/PromiseKit/tree/legacy-1.x). This is because PromiseKit > 2 breaks everytime Swift changes. While Swift is in flux it is not feasible to depend on a library that will break every time Xcode updates. + +If you are making an app then PromiseKit 3 is the best PromiseKit, you may have to make some fixes when Xcode updates, but probably you will be OK as long as you update PromiseKit when Xcode updates. + +PromiseKit 1 and 3 can be installed in parallel if necessary, but CocoaPods will not support this. + +Once Swift becomes ABI or API stable we can all just move to the latest PromiseKit. + +Thus we intend to support PromiseKit 1.x for longer than expected. + + +# PromiseKit 3 + +In Swift 2.0 `catch` and `defer` became reserved keywords mandating we rename our functions with these names. This forced a major semantic version change on PromiseKit and thus we took the opportunity to make other minor (source compatability breaking) improvements. + +Thus if you cannot afford to adapt to PromiseKit 3 but still want to use Xcode-7.0/Swift-2.0 we provide a [minimal changes branch] \(Swift 2.2 version [here](https://github.com/mxcl/PromiseKit/tree/swift-2.2-minimal-changes)\) where `catch` and `defer` are renamed `catch_` and `defer_` and all other changes are the bare minimum to make PromiseKit 2 compile against Swift 2. + +If you still are using Xcode 6 and Swift 1.2 then use PromiseKit 2. + +[minimal changes branch]: https://github.com/mxcl/PromiseKit/tree/swift-2.0-minimal-changes + +# PromiseKit 2 + +PromiseKit 2 contains many interesting and important additions. Check out our our [release announcement](http://promisekit.org/PromiseKit-2.0-Released) for full details. + +# PromiseKit 1 + +The original, nice to use with Objective-C, less nice to use with Swift, hence PromiseKit 2. + + +# How To Get Started + +* Check out the complete, comprehensive [PromiseKit documentation](http://promisekit.org). +* Read the [API documentation](http://cocoadocs.org/docsets/PromiseKit/), (note the documentation is not 100% currently as CocoaDocs is not good with Swift, you may have better luck reading the comments in the sources). +* [Integrate](http://promisekit.org/getting-started) promises into your existing projects. + +## Quick Start Guide + +### CocoaPods + +```ruby +use_frameworks! + +pod "PromiseKit", "~> 2.0" +``` + +### Carthage +```ruby +github "mxcl/PromiseKit" ~> 2.0 +``` + +*Note*: In order to avoid linking nearly all system frameworks with PromiseKit, the convenience categories have not been included with the Carthage framework . You must manually copy the categories you need in from the Carthage checkout. + +### Standalone Distributions + +* [iOS 8 & OS X 10.9 Frameworks](https://github.com/mxcl/PromiseKit/releases/download/2.2.2/PromiseKit-2.2.2.zip) (Binaries) + +*Please note*, the preferred way to integrate PromiseKit is CocoaPods or Carthage. + +### iOS 7 And Below + +Neither CocoaPods or Carthage will install PromiseKit 2 for an iOS 7 target. Your options are: + + 1. `pod "PromiseKit", "~> 1.7"` †‡ + 2. Use our [iOS 7 EZ-Bake](https://github.com/PromiseKit/EZiOS7) + 3. Download our pre-built static framework (coming soon!) + +† There is no Swift support with PromiseKit 1.x installed via CocoaPods.
‡ PromiseKit 1.x will work as far back as iOS 5 if required. + + +# Support + +PromiseKit is lucky enough to have a large community behind it which is reflected in our [Gitter chat](https://gitter.im/mxcl/PromiseKit). If you're new to PromiseKit and are stumped or otherwise have a question that doesn't feel like an issue (and isn't answered in our [documentation](http://promisekit.org/introduction)) then our Gitter is a great place to go for help. Of course if you're onto something that you believe is broken or could be improved then opening a new issue is still the way to go 👍. + + +# Donations + +PromiseKit is hundreds of hours of work almost completely by just me: [Max Howell](https://twitter.com/mxcl). I thoroughly enjoyed making PromiseKit, but nevertheless if you have found it useful then your bitcoin will give me a warm fuzzy feeling from my head right down to my toes: 1JDbV5zuym3jFw4kBCc5Z758maUD8e4dKR. + + +# License + +Copyright 2015, Max Howell; + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Pods/PromiseKit/Sources/AnyPromise+Private.h b/Pods/PromiseKit/Sources/AnyPromise+Private.h new file mode 100644 index 0000000..77376cc --- /dev/null +++ b/Pods/PromiseKit/Sources/AnyPromise+Private.h @@ -0,0 +1,47 @@ +@import Foundation.NSError; +@import Foundation.NSPointerArray; + +#if TARGET_OS_IPHONE + #define NSPointerArrayMake(N) ({ \ + NSPointerArray *aa = [NSPointerArray strongObjectsPointerArray]; \ + aa.count = N; \ + aa; \ + }) +#else + static inline NSPointerArray * __nonnull NSPointerArrayMake(NSUInteger count) { + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + NSPointerArray *aa = [[NSPointerArray class] respondsToSelector:@selector(strongObjectsPointerArray)] + ? [NSPointerArray strongObjectsPointerArray] + : [NSPointerArray pointerArrayWithStrongObjects]; + #pragma clang diagnostic pop + aa.count = count; + return aa; + } +#endif + +#define IsError(o) [o isKindOfClass:[NSError class]] +#define IsPromise(o) [o isKindOfClass:[AnyPromise class]] + +#import "AnyPromise.h" + +@interface AnyPromise (Swift) +- (void)pipe:(void (^ __nonnull)(id __nonnull))body; +- (AnyPromise * __nonnull)initWithBridge:(void (^ __nonnull)(PMKResolver __nonnull))resolver; +@end + +extern NSError * __nullable PMKProcessUnhandledException(id __nonnull thrown); + +// TODO really this is not valid, we should instead nest the errors with NSUnderlyingError +// since a special error subclass may be being used and we may not set it up correctly +// with our copy +#define NSErrorSupplement(_err, supplements) ({ \ + NSError *err = _err; \ + id userInfo = err.userInfo.mutableCopy ?: [NSMutableArray new]; \ + [userInfo addEntriesFromDictionary:supplements]; \ + [[[err class] alloc] initWithDomain:err.domain code:err.code userInfo:userInfo]; \ +}) + +@interface NSError (PMKUnhandledErrorHandler) +- (void)pmk_consume; +@end diff --git a/Pods/PromiseKit/Sources/AnyPromise.h b/Pods/PromiseKit/Sources/AnyPromise.h new file mode 100644 index 0000000..c83f56b --- /dev/null +++ b/Pods/PromiseKit/Sources/AnyPromise.h @@ -0,0 +1,274 @@ +#import +#import +#import +#import "Umbrella.h" + +typedef void (^PMKResolver)(id __nullable); + +typedef NS_ENUM(NSInteger, PMKCatchPolicy) { + PMKCatchPolicyAllErrors, + PMKCatchPolicyAllErrorsExceptCancellation +}; + +/** + This block lets you override the default dispatch queue for Promises. + + By default this returns dispatch_get_main_queue() + */ +extern __nonnull dispatch_queue_t (^__nonnull PMKDefaultDispatchQueue)(); + +/** + @see AnyPromise.swift +*/ +@interface AnyPromise (objc) + +/** + The provided block is executed when its receiver is resolved. + + If you provide a block that takes a parameter, the value of the receiver will be passed as that parameter. + + @param block The block that is executed when the receiver is resolved. + + [NSURLConnection GET:url].then(^(NSData *data){ + // do something with data + }); + + @return A new promise that is resolved with the value returned from the provided block. For example: + + [NSURLConnection GET:url].then(^(NSData *data){ + return data.length; + }).then(^(NSNumber *number){ + //… + }); + + @warning *Important* The block passed to `then` may take zero, one, two or three arguments, and return an object or return nothing. This flexibility is why the method signature for then is `id`, which means you will not get completion for the block parameter, and must type it yourself. It is safe to type any block syntax here, so to start with try just: `^{}`. + + @warning *Important* If an exception is thrown inside your block, or you return an `NSError` object the next `Promise` will be rejected. See `catch` for documentation on error handling. + + @warning *Important* `then` is always executed on the main queue. + + @see thenOn + @see thenInBackground +*/ +- (AnyPromise * __nonnull (^ __nonnull)(id __nonnull))then; + + +/** + The provided block is executed on the default queue when the receiver is fulfilled. + + This method is provided as a convenience for `thenOn`. + + @see then + @see thenOn +*/ +- (AnyPromise * __nonnull(^ __nonnull)(id __nonnull))thenInBackground; + +/** + The provided block is executed on the dispatch queue of your choice when the receiver is fulfilled. + + @see then + @see thenInBackground +*/ +- (AnyPromise * __nonnull(^ __nonnull)(dispatch_queue_t __nonnull, id __nonnull))thenOn; + +#ifndef __cplusplus +/** + The provided block is executed when the receiver is rejected. + + Provide a block of form `^(NSError *){}` or simply `^{}`. The parameter has type `id` to give you the freedom to choose either. + + The provided block always runs on the main queue. + + @warning *Note* Cancellation errors are not caught. + + @warning *Note* Since catch is a c++ keyword, this method is not availble in Objective-C++ files. Instead use catchWithPolicy. + + @see catchWithPolicy +*/ +- (AnyPromise * __nonnull(^ __nonnull)(id __nonnull))catch; +#endif + +/** + The provided block is executed when the receiver is rejected with the specified policy. + + @param policy The policy with which to catch. Either for all errors, or all errors *except* cancellation errors. + + @see catch +*/ +- (AnyPromise * __nonnull(^ __nonnull)(PMKCatchPolicy, id __nonnull))catchWithPolicy; + +/** + The provided block is executed when the receiver is resolved. + + The provided block always runs on the main queue. + + @see finallyOn +*/ +- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))finally; + +/** + The provided block is executed on the dispatch queue of your choice when the receiver is resolved. + + @see finally + */ +- (AnyPromise * __nonnull(^ __nonnull)(dispatch_queue_t __nonnull, dispatch_block_t __nonnull))finallyOn; + +/** + The value of the asynchronous task this promise represents. + + A promise has `nil` value if the asynchronous task it represents has not + finished. If the value is `nil` the promise is still `pending`. + + @warning *Note* Our Swift variant’s value property returns nil if the + promise is rejected where AnyPromise will return the error object. This + fits with the pattern where AnyPromise is not strictly typed and is more + dynamic, but you should be aware of the distinction. + + @return If `resolved`, the object that was used to resolve this promise; + if `pending`, nil. +*/ +- (id __nullable)value; + +/** + Creates a resolved promise. + + When developing your own promise systems, it is ocassionally useful to be able to return an already resolved promise. + + @param value The value with which to resolve this promise. Passing an `NSError` will cause the promise to be rejected, otherwise the promise will be fulfilled. + + @return A resolved promise. +*/ ++ (instancetype __nonnull)promiseWithValue:(id __nullable)value; + +/** + Create a new promise that resolves with the provided block. + + Use this method when wrapping asynchronous code that does *not* use + promises so that this code can be used in promise chains. + + If `resolve` is called with an `NSError` object, the promise is + rejected, otherwise the promise is fulfilled. + + Don’t use this method if you already have promises! Instead, just + return your promise. + + Should you need to fulfill a promise but have no sensical value to use: + your promise is a `void` promise: fulfill with `nil`. + + The block you pass is executed immediately on the calling thread. + + @param block The provided block is immediately executed, inside the block + call `resolve` to resolve this promise and cause any attached handlers to + execute. If you are wrapping a delegate-based system, we recommend + instead to use: initWithResolver: + + @return A new promise. + + @warning *Important* Resolving a promise with `nil` fulfills it. + + @see http://promisekit.org/sealing-your-own-promises/ + @see http://promisekit.org/wrapping-delegation/ +*/ ++ (instancetype __nonnull)promiseWithResolverBlock:(void (^ __nonnull)(PMKResolver __nonnull resolve))resolverBlock; + +/** + Create a new promise with an associated resolver. + + Use this method when wrapping asynchronous code that does *not* use + promises so that this code can be used in promise chains. Generally, + prefer resolverWithBlock: as the resulting code is more elegant. + + PMKResolver resolve; + AnyPromise *promise = [[AnyPromise alloc] initWithResolver:&resolve]; + + // later + resolve(@"foo"); + + @param resolver A reference to a block pointer of PMKResolver type. + You can then call your resolver to resolve this promise. + + @return A new promise. + + @warning *Important* The resolver strongly retains the promise. + + @see promiseWithResolverBlock: +*/ +- (instancetype __nonnull)initWithResolver:(PMKResolver __strong __nonnull * __nonnull)resolver; + +@end + + + +@interface AnyPromise (Unavailable) + +- (instancetype __nonnull)init __attribute__((unavailable("It is illegal to create an unresolvable promise."))); ++ (instancetype __nonnull)new __attribute__((unavailable("It is illegal to create an unresolvable promise."))); + +@end + + + +typedef void (^PMKAdapter)(id __nullable, NSError * __nullable); +typedef void (^PMKIntegerAdapter)(NSInteger, NSError * __nullable); +typedef void (^PMKBooleanAdapter)(BOOL, NSError * __nullable); + +@interface AnyPromise (Adapters) + +/** + Create a new promise by adapting an existing asynchronous system. + + The pattern of a completion block that passes two parameters, the first + the result and the second an `NSError` object is so common that we + provide this convenience adapter to make wrapping such systems more + elegant. + + return [PMKPromise promiseWithAdapterBlock:^(PMKAdapter adapter){ + PFQuery *query = [PFQuery …]; + [query findObjectsInBackgroundWithBlock:adapter]; + }]; + + @warning *Important* If both parameters are nil, the promise fulfills, + if both are non-nil the promise rejects. This is per the convention. + + @see http://promisekit.org/sealing-your-own-promises/ + */ ++ (instancetype __nonnull)promiseWithAdapterBlock:(void (^ __nonnull)(PMKAdapter __nonnull adapter))block; + +/** + Create a new promise by adapting an existing asynchronous system. + + Adapts asynchronous systems that complete with `^(NSInteger, NSError *)`. + NSInteger will cast to enums provided the enum has been wrapped with + `NS_ENUM`. All of Apple’s enums are, so if you find one that hasn’t you + may need to make a pull-request. + + @see promiseWithAdapter + */ ++ (instancetype __nonnull)promiseWithIntegerAdapterBlock:(void (^ __nonnull)(PMKIntegerAdapter __nonnull adapter))block; + +/** + Create a new promise by adapting an existing asynchronous system. + + Adapts asynchronous systems that complete with `^(BOOL, NSError *)`. + + @see promiseWithAdapter + */ ++ (instancetype __nonnull)promiseWithBooleanAdapterBlock:(void (^ __nonnull)(PMKBooleanAdapter __nonnull adapter))block; + +@end + + + +/** + Whenever resolving a promise you may resolve with a tuple, eg. + returning from a `then` or `catch` handler or resolving a new promise. + + Consumers of your Promise are not compelled to consume any arguments and + in fact will often only consume the first parameter. Thus ensure the + order of parameters is: from most-important to least-important. + + Currently PromiseKit limits you to THREE parameters to the manifold. +*/ +#define PMKManifold(...) __PMKManifold(__VA_ARGS__, 3, 2, 1) +#define __PMKManifold(_1, _2, _3, N, ...) __PMKArrayWithCount(N, _1, _2, _3) +extern id __nonnull __PMKArrayWithCount(NSUInteger, ...); diff --git a/Pods/PromiseKit/Sources/AnyPromise.m b/Pods/PromiseKit/Sources/AnyPromise.m new file mode 100644 index 0000000..6e219fd --- /dev/null +++ b/Pods/PromiseKit/Sources/AnyPromise.m @@ -0,0 +1,155 @@ +#import "AnyPromise.h" +#import "AnyPromise+Private.h" +@import Foundation.NSKeyValueCoding; +#import "PMKCallVariadicBlock.m" + +NSString *const PMKErrorDomain = @"PMKErrorDomain"; + +dispatch_queue_t (^PMKDefaultDispatchQueue)() = ^{ return dispatch_get_main_queue(); }; + +@implementation AnyPromise (objc) + +- (instancetype)initWithResolver:(PMKResolver __strong *)resolver { + return [self initWithBridge:^(PMKResolver resolve){ + *resolver = resolve; + }]; +} + ++ (instancetype)promiseWithResolverBlock:(void (^)(PMKResolver))resolveBlock { + return [[self alloc] initWithBridge:resolveBlock]; +} + ++ (instancetype)promiseWithValue:(id)value { + return [[self alloc] initWithBridge:^(PMKResolver resolve){ + resolve(value); + }]; +} + +static inline AnyPromise *AnyPromiseWhen(AnyPromise *when, void(^then)(id, PMKResolver)) { + return [[AnyPromise alloc] initWithBridge:^(PMKResolver resolve){ + [when pipe:^(id obj){ + then(obj, resolve); + }]; + }]; +} + +static inline AnyPromise *__then(AnyPromise *self, dispatch_queue_t queue, id block) { + return AnyPromiseWhen(self, ^(id obj, PMKResolver resolve) { + if (IsError(obj)) { + resolve(obj); + } else dispatch_async(queue, ^{ + resolve(PMKCallVariadicBlock(block, obj)); + }); + }); +} + +- (AnyPromise *(^)(id))then { + return ^(id block) { + return __then(self, PMKDefaultDispatchQueue(), block); + }; +} + +- (AnyPromise *(^)(dispatch_queue_t, id))thenOn { + return ^(dispatch_queue_t queue, id block) { + return __then(self, queue, block); + }; +} + +- (AnyPromise *(^)(id))thenInBackground { + return ^(id block) { + return __then(self, dispatch_get_global_queue(0, 0), block); + }; +} + +static inline AnyPromise *__catch(AnyPromise *self, BOOL includeCancellation, id block) { + return AnyPromiseWhen(self, ^(id obj, PMKResolver resolve) { + dispatch_async(PMKDefaultDispatchQueue(), ^{ + if (IsError(obj) && (includeCancellation || ![obj cancelled])) { + [obj pmk_consume]; + resolve(PMKCallVariadicBlock(block, obj)); + } else { + resolve(obj); + } + }); + }); +} + +- (AnyPromise *(^)(id))catch { + return ^(id block) { + return __catch(self, NO, block); + }; +} + +- (AnyPromise *(^)(PMKCatchPolicy, id))catchWithPolicy { + return ^(PMKCatchPolicy policy, id block) { + return __catch(self, policy == PMKCatchPolicyAllErrors, block); + }; +} + +static inline AnyPromise *__finally(AnyPromise *self, dispatch_queue_t queue, dispatch_block_t block) { + return AnyPromiseWhen(self, ^(id obj, PMKResolver resolve) { + dispatch_async(queue, ^{ + block(); + resolve(obj); + }); + }); +} + +- (AnyPromise *(^)(dispatch_block_t))finally { + return ^(dispatch_block_t block) { + return __finally(self, PMKDefaultDispatchQueue(), block); + }; +} + +- (AnyPromise *(^)(dispatch_queue_t, dispatch_block_t))finallyOn { + return ^(dispatch_queue_t queue, dispatch_block_t block) { + return __finally(self, queue, block); + }; +} + +- (id)value { + id result = [self valueForKey:@"__value"]; + return [result isKindOfClass:[PMKArray class]] + ? result[0] + : result; +} + +@end + + + +@implementation AnyPromise (Adapters) + ++ (instancetype)promiseWithAdapterBlock:(void (^)(PMKAdapter))block { + return [self promiseWithResolverBlock:^(PMKResolver resolve) { + block(^(id value, id error){ + resolve(error ?: value); + }); + }]; +} + ++ (instancetype)promiseWithIntegerAdapterBlock:(void (^)(PMKIntegerAdapter))block { + return [self promiseWithResolverBlock:^(PMKResolver resolve) { + block(^(NSInteger value, id error){ + if (error) { + resolve(error); + } else { + resolve(@(value)); + } + }); + }]; +} + ++ (instancetype)promiseWithBooleanAdapterBlock:(void (^)(PMKBooleanAdapter adapter))block { + return [self promiseWithResolverBlock:^(PMKResolver resolve) { + block(^(BOOL value, id error){ + if (error) { + resolve(error); + } else { + resolve(@(value)); + } + }); + }]; +} + +@end diff --git a/Pods/PromiseKit/Sources/AnyPromise.swift b/Pods/PromiseKit/Sources/AnyPromise.swift new file mode 100644 index 0000000..965e4cc --- /dev/null +++ b/Pods/PromiseKit/Sources/AnyPromise.swift @@ -0,0 +1,233 @@ +import Foundation.NSError + +@objc(AnyPromise) public class AnyPromise: NSObject { + + private var state: State + + /** + - Returns: A new AnyPromise bound to a Promise. + The two promises represent the same task, any changes to either will instantly reflect on both. + */ + public init(bound: Promise) { + var resolve: ((AnyObject?) -> Void)! + state = State(resolver: &resolve) + bound.pipe { resolution in + switch resolution { + case .Fulfilled(let value): + resolve(value) + case .Rejected(let error, let token): + let nserror = error as NSError + unconsume(error: nserror, reusingToken: token) + resolve(nserror) + } + } + } + + /** + - Returns: A new AnyPromise bound to a Promise. + The two promises represent the same task, any changes to either will instantly reflect on both. + */ + convenience public init(bound: Promise) { + // FIXME efficiency. Allocating the extra promise for conversion sucks. + self.init(bound: bound.then(on: zalgo){ Optional.Some($0) }) + } + + /** + - Returns: A new `AnyPromise` bound to a `Promise<[T]>`. + The two promises represent the same task, any changes to either will instantly reflect on both. + The value is converted to an NSArray so Objective-C can use it. + */ + convenience public init(bound: Promise<[T]>) { + self.init(bound: bound.then(on: zalgo) { NSArray(array: $0) }) + } + + /** + - Returns: A new AnyPromise bound to a `Promise<[T:U]>`. + The two promises represent the same task, any changes to either will instantly reflect on both. + The value is converted to an NSDictionary so Objective-C can use it. + */ + convenience public init(bound: Promise<[T:U]>) { + self.init(bound: bound.then(on: zalgo) { NSDictionary(dictionary: $0) }) + } + + /** + - Returns: A new AnyPromise bound to a `Promise`. + The two promises represent the same task, any changes to either will instantly reflect on both. + The value is converted to an NSString so Objective-C can use it. + */ + convenience public init(bound: Promise) { + self.init(bound: bound.then(on: zalgo) { NSString(string: $0) }) + } + + /** + - Returns: A new AnyPromise bound to a `Promise`. + The two promises represent the same task, any changes to either will instantly reflect on both. + The value is converted to an NSNumber so Objective-C can use it. + */ + convenience public init(bound: Promise) { + self.init(bound: bound.then(on: zalgo) { NSNumber(integer: $0) }) + } + + /** + - Returns: A new AnyPromise bound to a `Promise`. + The two promises represent the same task, any changes to either will instantly reflect on both. + The value is converted to an NSNumber so Objective-C can use it. + */ + convenience public init(bound: Promise) { + self.init(bound: bound.then(on: zalgo) { NSNumber(bool: $0) }) + } + + /** + - Returns: A new AnyPromise bound to a `Promise`. + The two promises represent the same task, any changes to either will instantly reflect on both. + */ + convenience public init(bound: Promise) { + self.init(bound: bound.then(on: zalgo) { Optional.None }) + } + + @objc init(@noescape bridge: ((AnyObject?) -> Void) -> Void) { + var resolve: ((AnyObject?) -> Void)! + state = State(resolver: &resolve) + bridge { result in + if let next = result as? AnyPromise { + next.pipe(resolve) + } else { + resolve(result) + } + } + } + + @objc func pipe(body: (AnyObject?) -> Void) { + state.get { seal in + switch seal { + case .Pending(let handlers): + handlers.append(body) + case .Resolved(let value): + body(value) + } + } + } + + @objc var __value: AnyObject? { + return state.get() ?? nil + } + + /** + A promise starts pending and eventually resolves. + - Returns: `true` if the promise has not yet resolved. + */ + @objc public var pending: Bool { + return state.get() == nil + } + + /** + A promise starts pending and eventually resolves. + - Returns: `true` if the promise has resolved. + */ + @objc public var resolved: Bool { + return !pending + } + + /** + A fulfilled promise has resolved successfully. + - Returns: `true` if the promise was fulfilled. + */ + @objc public var fulfilled: Bool { + switch state.get() { + case .Some(let obj) where obj is NSError: + return false + case .Some: + return true + case .None: + return false + } + } + + /** + A rejected promise has resolved without success. + - Returns: `true` if the promise was rejected. + */ + @objc public var rejected: Bool { + switch state.get() { + case .Some(let obj) where obj is NSError: + return true + default: + return false + } + } + + /** + Continue a Promise chain from an AnyPromise. + */ + public func then(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), body: (AnyObject?) throws -> T) -> Promise { + return Promise(sealant: { resolve in + pipe { object in + if let error = object as? NSError { + resolve(.Rejected(error, error.token)) + } else { + contain_zalgo(q, rejecter: resolve) { + resolve(.Fulfilled(try body(self.valueForKey("value")))) + } + } + } + }) + } + + /** + Continue a Promise chain from an AnyPromise. + */ + public func then(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), body: (AnyObject?) -> AnyPromise) -> Promise { + return Promise { fulfill, reject in + pipe { object in + if let error = object as? NSError { + reject(error) + } else { + contain_zalgo(q) { + body(object).pipe { object in + if let error = object as? NSError { + reject(error) + } else { + fulfill(object) + } + } + } + } + } + } + } + + /** + Continue a Promise chain from an AnyPromise. + */ + public func then(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), body: (AnyObject?) -> Promise) -> Promise { + return Promise(sealant: { resolve in + pipe { object in + if let error = object as? NSError { + resolve(.Rejected(error, error.token)) + } else { + contain_zalgo(q) { + body(object).pipe(resolve) + } + } + } + }) + } + + private class State: UnsealedState { + required init(inout resolver: ((AnyObject?) -> Void)!) { + var preresolve: ((AnyObject?) -> Void)! + super.init(resolver: &preresolve) + resolver = { obj in + if let error = obj as? NSError { unconsume(error: error) } + preresolve(obj) + } + } + } +} + + +extension AnyPromise { + override public var description: String { + return "AnyPromise: \(state)" + } +} diff --git a/Pods/PromiseKit/Sources/Error.swift b/Pods/PromiseKit/Sources/Error.swift new file mode 100644 index 0000000..8f41f7c --- /dev/null +++ b/Pods/PromiseKit/Sources/Error.swift @@ -0,0 +1,217 @@ +import Dispatch +import Foundation.NSError +import Foundation.NSURLError + +public enum Error: ErrorType { + /** + The ErrorType for a rejected `when`. + - Parameter 0: The index of the promise that was rejected. + - Parameter 1: The error from the promise that rejected this `when`. + */ + case When(Int, ErrorType) + + /** + The ErrorType for a rejected `join`. + - Parameter 0: The promises passed to this `join` that did not *all* fulfill. + - Note: The array is untyped because Swift generics are fussy with enums. + */ + case Join([AnyObject]) + + /** + The closure with form (T?, ErrorType?) was called with (nil, nil) + This is invalid as per the calling convention. + */ + case DoubleOhSux0r + + /** + A handler returned its own promise. 99% of the time, this is likely a + programming error. It is also invalid per Promises/A+. + */ + case ReturnedSelf +} + +public enum URLError: ErrorType { + /** + The URLRequest succeeded but a valid UIImage could not be decoded from + the data that was received. + */ + case InvalidImageData(NSURLRequest, NSData) + + /** + An NSError was received from an underlying Cocoa function. + FIXME sucks? + */ + case UnderlyingCocoaError(NSURLRequest, NSData?, NSURLResponse?, NSError) + + /** + The HTTP request returned a non-200 status code. + */ + case BadResponse(NSURLRequest, NSData?, NSURLResponse?) + + /** + The data could not be decoded using the encoding specified by the HTTP + response headers. + */ + case StringEncoding(NSURLRequest, NSData, NSURLResponse) + + /** + Usually the `NSURLResponse` is actually an `NSHTTPURLResponse`, if so you + can access it using this property. Since it is returned as an unwrapped + optional: be sure. + */ + public var NSHTTPURLResponse: Foundation.NSHTTPURLResponse! { + switch self { + case .InvalidImageData: + return nil + case .UnderlyingCocoaError(_, _, let rsp, _): + return rsp as! Foundation.NSHTTPURLResponse + case .BadResponse(_, _, let rsp): + return rsp as! Foundation.NSHTTPURLResponse + case .StringEncoding(_, _, let rsp): + return rsp as! Foundation.NSHTTPURLResponse + } + } +} + +public enum JSONError: ErrorType { + case UnexpectedRootNode(AnyObject) +} + + +//////////////////////////////////////////////////////////// Cancellation +private struct ErrorPair: Hashable { + let domain: String + let code: Int + init(_ d: String, _ c: Int) { + domain = d; code = c + } + var hashValue: Int { + return "\(domain):\(code)".hashValue + } +} + +private func ==(lhs: ErrorPair, rhs: ErrorPair) -> Bool { + return lhs.domain == rhs.domain && lhs.code == rhs.code +} + +extension NSError { + @objc public class func cancelledError() -> NSError { + let info: [NSObject: AnyObject] = [NSLocalizedDescriptionKey: "The operation was cancelled"] + return NSError(domain: PMKErrorDomain, code: PMKOperationCancelled, userInfo: info) + } + + /** + - Warning: You may only call this method on the main thread. + */ + @objc public class func registerCancelledErrorDomain(domain: String, code: Int) { + cancelledErrorIdentifiers.insert(ErrorPair(domain, code)) + } +} + +public protocol CancellableErrorType: ErrorType { + var cancelled: Bool { get } +} + +extension NSError: CancellableErrorType { + /** + - Warning: You may only call this method on the main thread. + */ + @objc public var cancelled: Bool { + if !NSThread.isMainThread() { + NSLog("PromiseKit: Warning: `cancelled` called on background thread.") + } + + return cancelledErrorIdentifiers.contains(ErrorPair(domain, code)) + } +} + + +////////////////////////////////////////// Predefined Cancellation Errors +private var cancelledErrorIdentifiers = Set([ + ErrorPair(PMKErrorDomain, PMKOperationCancelled), + ErrorPair(NSURLErrorDomain, NSURLErrorCancelled) +]) + +extension NSURLError: CancellableErrorType { + public var cancelled: Bool { + return self == .Cancelled + } +} + + +//////////////////////////////////////////////////////// Unhandled Errors +/** + The unhandled error handler. + + If a promise is rejected and no catch handler is called in its chain, + the provided handler is called. The default handler logs the error. + + PMKUnhandledErrorHandler = { error in + mylogf("Unhandled error: \(error)") + } + + - Warning: *Important* The handler is executed on an undefined queue. + - Warning: *Important* Don’t use promises in your handler, or you risk an infinite error loop. + - Returns: The previous unhandled error handler. +*/ +public var PMKUnhandledErrorHandler = { (error: ErrorType) -> Void in + dispatch_async(dispatch_get_main_queue()) { + let cancelled = (error as? CancellableErrorType)?.cancelled ?? false + // ^-------^ must be called on main queue + if !cancelled { + NSLog("PromiseKit: Unhandled Error: %@", "\(error)") + } + } +} + +class ErrorConsumptionToken { + var consumed = false + let error: ErrorType! + + init(_ error: ErrorType) { + self.error = error + } + + init(_ error: NSError) { + self.error = error.copy() as! NSError + } + + deinit { + if !consumed { + PMKUnhandledErrorHandler(error) + } + } +} + +private var handle: UInt8 = 0 + +extension NSError { + @objc func pmk_consume() { + // The association could be nil if the objc_setAssociatedObject + // has taken a *really* long time. Or perhaps the user has + // overused `zalgo`. Thus we ignore it. This is an unlikely edge + // case and the unhandled-error feature is not mission-critical. + + if let token = objc_getAssociatedObject(self, &handle) as? ErrorConsumptionToken { + token.consumed = true + } + } + + var token: ErrorConsumptionToken! { + return objc_getAssociatedObject(self, &handle) as? ErrorConsumptionToken + } +} + +func unconsume(error error: NSError, reusingToken t: ErrorConsumptionToken? = nil) { + var token = t + if token != nil { + objc_setAssociatedObject(error, &handle, token, .OBJC_ASSOCIATION_RETAIN) + } else { + token = objc_getAssociatedObject(error, &handle) as? ErrorConsumptionToken + if token == nil { + token = ErrorConsumptionToken(error) + objc_setAssociatedObject(error, &handle, token, .OBJC_ASSOCIATION_RETAIN) + } + } + token!.consumed = false +} diff --git a/Pods/PromiseKit/Sources/NSError+Cancellation.h b/Pods/PromiseKit/Sources/NSError+Cancellation.h new file mode 100644 index 0000000..99d1da6 --- /dev/null +++ b/Pods/PromiseKit/Sources/NSError+Cancellation.h @@ -0,0 +1,16 @@ +#import + +#if !defined(SWIFT_PASTE) +# define SWIFT_PASTE_HELPER(x, y) x##y +# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y) +#endif + +#if !defined(SWIFT_EXTENSION) +# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__) +#endif + +@interface NSError (SWIFT_EXTENSION(PromiseKit)) ++ (NSError * __nonnull)cancelledError; ++ (void)registerCancelledErrorDomain:(NSString * __nonnull)domain code:(NSInteger)code; +@property (nonatomic, readonly) BOOL cancelled; +@end diff --git a/Pods/PromiseKit/Sources/NSMethodSignatureForBlock.m b/Pods/PromiseKit/Sources/NSMethodSignatureForBlock.m new file mode 100644 index 0000000..700c1b3 --- /dev/null +++ b/Pods/PromiseKit/Sources/NSMethodSignatureForBlock.m @@ -0,0 +1,77 @@ +#import + +struct PMKBlockLiteral { + void *isa; // initialized to &_NSConcreteStackBlock or &_NSConcreteGlobalBlock + int flags; + int reserved; + void (*invoke)(void *, ...); + struct block_descriptor { + unsigned long int reserved; // NULL + unsigned long int size; // sizeof(struct Block_literal_1) + // optional helper functions + void (*copy_helper)(void *dst, void *src); // IFF (1<<25) + void (*dispose_helper)(void *src); // IFF (1<<25) + // required ABI.2010.3.16 + const char *signature; // IFF (1<<30) + } *descriptor; + // imported variables +}; + +typedef NS_OPTIONS(NSUInteger, PMKBlockDescriptionFlags) { + PMKBlockDescriptionFlagsHasCopyDispose = (1 << 25), + PMKBlockDescriptionFlagsHasCtor = (1 << 26), // helpers have C++ code + PMKBlockDescriptionFlagsIsGlobal = (1 << 28), + PMKBlockDescriptionFlagsHasStret = (1 << 29), // IFF BLOCK_HAS_SIGNATURE + PMKBlockDescriptionFlagsHasSignature = (1 << 30) +}; + +// It appears 10.7 doesn't support quotes in method signatures. Remove them +// via @rabovik's method. See https://github.com/OliverLetterer/SLObjectiveCRuntimeAdditions/pull/2 +#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8 +NS_INLINE static const char * pmk_removeQuotesFromMethodSignature(const char *str){ + char *result = malloc(strlen(str) + 1); + BOOL skip = NO; + char *to = result; + char c; + while ((c = *str++)) { + if ('"' == c) { + skip = !skip; + continue; + } + if (skip) continue; + *to++ = c; + } + *to = '\0'; + return result; +} +#endif + +static NSMethodSignature *NSMethodSignatureForBlock(id block) { + if (!block) + return nil; + + struct PMKBlockLiteral *blockRef = (__bridge struct PMKBlockLiteral *)block; + PMKBlockDescriptionFlags flags = (PMKBlockDescriptionFlags)blockRef->flags; + + if (flags & PMKBlockDescriptionFlagsHasSignature) { + void *signatureLocation = blockRef->descriptor; + signatureLocation += sizeof(unsigned long int); + signatureLocation += sizeof(unsigned long int); + + if (flags & PMKBlockDescriptionFlagsHasCopyDispose) { + signatureLocation += sizeof(void(*)(void *dst, void *src)); + signatureLocation += sizeof(void (*)(void *src)); + } + + const char *signature = (*(const char **)signatureLocation); +#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8 + signature = pmk_removeQuotesFromMethodSignature(signature); + NSMethodSignature *nsSignature = [NSMethodSignature signatureWithObjCTypes:signature]; + free((void *)signature); + + return nsSignature; +#endif + return [NSMethodSignature signatureWithObjCTypes:signature]; + } + return 0; +} diff --git a/Pods/PromiseKit/Sources/PMK.modulemap b/Pods/PromiseKit/Sources/PMK.modulemap new file mode 100644 index 0000000..7e55ef9 --- /dev/null +++ b/Pods/PromiseKit/Sources/PMK.modulemap @@ -0,0 +1,32 @@ +framework module PromiseKit { + umbrella header "Umbrella.h" + + header "NSError+Cancellation.h" + + exclude header "AnyPromise.h" + exclude header "PromiseKit.h" + exclude header "PMKPromise.h" + exclude header "Promise.h" + + exclude header "Pods-PromiseKit-umbrella.h" + + exclude header "ACAccountStore+AnyPromise.h" + exclude header "AVAudioSession+AnyPromise.h" + exclude header "CKContainer+AnyPromise.h" + exclude header "CKDatabase+AnyPromise.h" + exclude header "CLGeocoder+AnyPromise.h" + exclude header "CLLocationManager+AnyPromise.h" + exclude header "NSNotificationCenter+AnyPromise.h" + exclude header "NSTask+AnyPromise.h" + exclude header "NSURLConnection+AnyPromise.h" + exclude header "MKDirections+AnyPromise.h" + exclude header "MKMapSnapshotter+AnyPromise.h" + exclude header "CALayer+AnyPromise.h" + exclude header "SLRequest+AnyPromise.h" + exclude header "SKRequest+AnyPromise.h" + exclude header "SCNetworkReachability+AnyPromise.h" + exclude header "UIActionSheet+AnyPromise.h" + exclude header "UIAlertView+AnyPromise.h" + exclude header "UIView+AnyPromise.h" + exclude header "UIViewController+AnyPromise.h" +} diff --git a/Pods/PromiseKit/Sources/PMKCallVariadicBlock.m b/Pods/PromiseKit/Sources/PMKCallVariadicBlock.m new file mode 100644 index 0000000..a3d4511 --- /dev/null +++ b/Pods/PromiseKit/Sources/PMKCallVariadicBlock.m @@ -0,0 +1,145 @@ +#import +#import +#import +#import +#import "NSMethodSignatureForBlock.m" +#import +#import +#import + +#ifndef PMKLog +#define PMKLog NSLog +#endif + +@interface PMKArray : NSObject { +@public + id objs[3]; + NSUInteger count; +} @end + +@implementation PMKArray + +- (id)objectAtIndexedSubscript:(NSUInteger)idx { + if (count <= idx) { + // this check is necessary due to lack of checks in `pmk_safely_call_block` + return nil; + } + return objs[idx]; +} + +@end + +id __PMKArrayWithCount(NSUInteger count, ...) { + PMKArray *this = [PMKArray new]; + this->count = count; + va_list args; + va_start(args, count); + for (NSUInteger x = 0; x < count; ++x) + this->objs[x] = va_arg(args, id); + va_end(args); + return this; +} + + +static inline id _PMKCallVariadicBlock(id frock, id result) { + NSCAssert(frock, @""); + + NSMethodSignature *sig = NSMethodSignatureForBlock(frock); + const NSUInteger nargs = sig.numberOfArguments; + const char rtype = sig.methodReturnType[0]; + + #define call_block_with_rtype(type) ({^type{ \ + switch (nargs) { \ + case 1: \ + return ((type(^)(void))frock)(); \ + case 2: { \ + const id arg = [result class] == [PMKArray class] ? result[0] : result; \ + return ((type(^)(id))frock)(arg); \ + } \ + case 3: { \ + type (^block)(id, id) = frock; \ + return [result class] == [PMKArray class] \ + ? block(result[0], result[1]) \ + : block(result, nil); \ + } \ + case 4: { \ + type (^block)(id, id, id) = frock; \ + return [result class] == [PMKArray class] \ + ? block(result[0], result[1], result[2]) \ + : block(result, nil, nil); \ + } \ + default: \ + @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"PromiseKit: The provided block’s argument count is unsupported." userInfo:nil]; \ + }}();}) + + switch (rtype) { + case 'v': + call_block_with_rtype(void); + return nil; + case '@': + return call_block_with_rtype(id) ?: nil; + case '*': { + char *str = call_block_with_rtype(char *); + return str ? @(str) : nil; + } + case 'c': return @(call_block_with_rtype(char)); + case 'i': return @(call_block_with_rtype(int)); + case 's': return @(call_block_with_rtype(short)); + case 'l': return @(call_block_with_rtype(long)); + case 'q': return @(call_block_with_rtype(long long)); + case 'C': return @(call_block_with_rtype(unsigned char)); + case 'I': return @(call_block_with_rtype(unsigned int)); + case 'S': return @(call_block_with_rtype(unsigned short)); + case 'L': return @(call_block_with_rtype(unsigned long)); + case 'Q': return @(call_block_with_rtype(unsigned long long)); + case 'f': return @(call_block_with_rtype(float)); + case 'd': return @(call_block_with_rtype(double)); + case 'B': return @(call_block_with_rtype(_Bool)); + case '^': + if (strcmp(sig.methodReturnType, "^v") == 0) { + call_block_with_rtype(void); + return nil; + } + // else fall through! + default: + @throw [NSException exceptionWithName:@"PromiseKit" reason:@"PromiseKit: Unsupported method signature." userInfo:nil]; + } +} + +static id PMKCallVariadicBlock(id frock, id result) { + @try { + return _PMKCallVariadicBlock(frock, result); + } @catch (id thrown) { + return PMKProcessUnhandledException(thrown); + } +} + + +static dispatch_once_t onceToken; +static NSError *(^PMKUnhandledExceptionHandler)(id); + +NSError *PMKProcessUnhandledException(id thrown) { + + dispatch_once(&onceToken, ^{ + PMKUnhandledExceptionHandler = ^id(id reason){ + if ([reason isKindOfClass:[NSError class]]) + return reason; + if ([reason isKindOfClass:[NSString class]]) + return [NSError errorWithDomain:PMKErrorDomain code:PMKUnexpectedError userInfo:@{NSLocalizedDescriptionKey: reason}]; + return nil; + }; + }); + + id err = PMKUnhandledExceptionHandler(thrown); + if (!err) { + NSLog(@"PromiseKit no longer catches *all* exceptions. However you can change this behavior by setting a new PMKProcessUnhandledException handler."); + @throw thrown; + } + return err; +} + +void PMKSetUnhandledExceptionHandler(NSError *(^newHandler)(id)) { + dispatch_once(&onceToken, ^{ + PMKUnhandledExceptionHandler = newHandler; + }); +} diff --git a/Pods/PromiseKit/Sources/Promise+Properties.swift b/Pods/PromiseKit/Sources/Promise+Properties.swift new file mode 100644 index 0000000..fc1b335 --- /dev/null +++ b/Pods/PromiseKit/Sources/Promise+Properties.swift @@ -0,0 +1,76 @@ +extension Promise { + /** + - Returns: The error with which this promise was rejected; `nil` if this promise is not rejected. + */ + public var error: ErrorType? { + switch state.get() { + case .None: + return nil + case .Some(.Fulfilled): + return nil + case .Some(.Rejected(let error, _)): + return error + } + } + + /** + Provides an alias for the `error` property for cases where the Swift + compiler cannot disambiguate from our `error` function. + + More than likely use of this alias will never be necessary as it's + the inverse situation where Swift usually becomes confused. But + we provide this anyway just in case. + + If you absolutely cannot get Swift to accept `error` then + `errorValue` may be used instead as it returns the same thing. + + - Warning: This alias will be unavailable in PromiseKit 4.0.0 + - SeeAlso: [https://github.com/mxcl/PromiseKit/issues/347](https://github.com/mxcl/PromiseKit/issues/347) + */ + @available(*, deprecated, renamed="error", message="Temporary alias `errorValue` will eventually be removed and should only be used when the Swift compiler cannot be satisfied with `error`") + public var errorValue: ErrorType? { + return self.error + } + + /** + - Returns: `true` if the promise has not yet resolved. + */ + public var pending: Bool { + return state.get() == nil + } + + /** + - Returns: `true` if the promise has resolved. + */ + public var resolved: Bool { + return !pending + } + + /** + - Returns: `true` if the promise was fulfilled. + */ + public var fulfilled: Bool { + return value != nil + } + + /** + - Returns: `true` if the promise was rejected. + */ + public var rejected: Bool { + return error != nil + } + + /** + - Returns: The value with which this promise was fulfilled or `nil` if this promise is pending or rejected. + */ + public var value: T? { + switch state.get() { + case .None: + return nil + case .Some(.Fulfilled(let value)): + return value + case .Some(.Rejected): + return nil + } + } +} diff --git a/Pods/PromiseKit/Sources/Promise.swift b/Pods/PromiseKit/Sources/Promise.swift new file mode 100644 index 0000000..813038c --- /dev/null +++ b/Pods/PromiseKit/Sources/Promise.swift @@ -0,0 +1,711 @@ +import Dispatch +import Foundation.NSError + +/** + A *promise* represents the future value of a task. + + To obtain the value of a promise we call `then`. + + Promises are chainable: `then` returns a promise, you can call `then` on + that promise, which returns a promise, you can call `then` on that + promise, et cetera. + + Promises start in a pending state and *resolve* with a value to become + *fulfilled* or with an `ErrorType` to become rejected. + + - SeeAlso: [PromiseKit `then` Guide](http://promisekit.org/then/) + - SeeAlso: [PromiseKit Chaining Guide](http://promisekit.org/chaining/) +*/ +public class Promise { + let state: State> + + /** + Create a new pending promise. + + Use this method when wrapping asynchronous systems that do *not* use + promises so that they can be involved in promise chains. + + Don’t use this method if you already have promises! Instead, just return + your promise! + + The closure you pass is executed immediately on the calling thread. + + func fetchKitten() -> Promise { + return Promise { fulfill, reject in + KittenFetcher.fetchWithCompletionBlock({ img, err in + if err == nil { + if img.size.width > 0 { + fulfill(img) + } else { + reject(Error.ImageTooSmall) + } + } else { + reject(err) + } + }) + } + } + + - Parameter resolvers: The provided closure is called immediately. + Inside, execute your asynchronous system, calling fulfill if it suceeds + and reject for any errors. + + - Returns: return A new promise. + + - Note: If you are wrapping a delegate-based system, we recommend + to use instead: Promise.pendingPromise() + + - SeeAlso: http://promisekit.org/sealing-your-own-promises/ + - SeeAlso: http://promisekit.org/wrapping-delegation/ + - SeeAlso: init(resolver:) + */ + public init(@noescape resolvers: (fulfill: (T) -> Void, reject: (ErrorType) -> Void) throws -> Void) { + var resolve: ((Resolution) -> Void)! + state = UnsealedState(resolver: &resolve) + do { + try resolvers(fulfill: { resolve(.Fulfilled($0)) }, reject: { error in + if self.pending { + resolve(.Rejected(error, ErrorConsumptionToken(error))) + } else { + NSLog("PromiseKit: Warning: reject called on already rejected Promise: %@", "\(error)") + } + }) + } catch { + resolve(.Rejected(error, ErrorConsumptionToken(error))) + } + } + + /** + Create a new pending promise. + + This initializer is convenient when wrapping asynchronous systems that + use common patterns. For example: + + func fetchKitten() -> Promise { + return Promise { resolve in + KittenFetcher.fetchWithCompletionBlock(resolve) + } + } + + - SeeAlso: init(resolvers:) + */ + public convenience init(@noescape resolver: ((T?, NSError?) -> Void) throws -> Void) { + self.init(sealant: { resolve in + try resolver { obj, err in + if let obj = obj { + resolve(.Fulfilled(obj)) + } else if let err = err { + resolve(.Rejected(err, ErrorConsumptionToken(err as ErrorType))) + } else { + resolve(.Rejected(Error.DoubleOhSux0r, ErrorConsumptionToken(Error.DoubleOhSux0r))) + } + } + }) + } + + /** + Create a new pending promise. + + This initializer is convenient when wrapping asynchronous systems that + use common patterns. For example: + + func fetchKitten() -> Promise { + return Promise { resolve in + KittenFetcher.fetchWithCompletionBlock(resolve) + } + } + + - SeeAlso: init(resolvers:) + */ + public convenience init(@noescape resolver: ((T, NSError?) -> Void) throws -> Void) { + self.init(sealant: { resolve in + try resolver { obj, err in + if let err = err { + resolve(.Rejected(err, ErrorConsumptionToken(err))) + } else { + resolve(.Fulfilled(obj)) + } + } + }) + } + + /** + Create a new fulfilled promise. + */ + public init(_ value: T) { + state = SealedState(resolution: .Fulfilled(value)) + } + + @available(*, unavailable, message="T cannot conform to ErrorType") + public init(_ value: T) { abort() } + + /** + Create a new rejected promise. + */ + public init(error: ErrorType) { + /** + Implementation note, the error label is necessary to prevent: + + let p = Promise(ErrorType()) + + Resulting in Promise. The above @available annotation + does not help for some reason. A work-around is: + + let p: Promise = Promise(ErrorType()) + + But I can’t expect users to do this. + */ + state = SealedState(resolution: .Rejected(error, ErrorConsumptionToken(error))) + } + + /** + Careful with this, it is imperative that sealant can only be called once + or you will end up with spurious unhandled-errors due to possible double + rejections and thus immediately deallocated ErrorConsumptionTokens. + */ + init(@noescape sealant: ((Resolution) -> Void) throws -> Void) { + var resolve: ((Resolution) -> Void)! + state = UnsealedState(resolver: &resolve) + do { + try sealant(resolve) + } catch { + resolve(.Rejected(error, ErrorConsumptionToken(error))) + } + } + + /** + A `typealias` for the return values of `pendingPromise()`. Simplifies declaration of properties that reference the values' containing tuple when this is necessary. For example, when working with multiple `pendingPromise()`s within the same scope, or when the promise initialization must occur outside of the caller's initialization. + + class Foo: BarDelegate { + var pendingPromise: Promise.PendingPromise? + } + + - SeeAlso: pendingPromise() + */ + public typealias PendingPromise = (promise: Promise, fulfill: (T) -> Void, reject: (ErrorType) -> Void) + + /** + Making promises that wrap asynchronous delegation systems or other larger asynchronous systems without a simple completion handler is easier with pendingPromise. + + class Foo: BarDelegate { + let (promise, fulfill, reject) = Promise.pendingPromise() + + func barDidFinishWithResult(result: Int) { + fulfill(result) + } + + func barDidError(error: NSError) { + reject(error) + } + } + + - Returns: A tuple consisting of: + 1) A promise + 2) A function that fulfills that promise + 3) A function that rejects that promise + */ + public class func pendingPromise() -> PendingPromise { + var fulfill: ((T) -> Void)! + var reject: ((ErrorType) -> Void)! + let promise = Promise { fulfill = $0; reject = $1 } + return (promise, fulfill, reject) + } + + func pipe(body: (Resolution) -> Void) { + state.get { seal in + switch seal { + case .Pending(let handlers): + handlers.append(body) + case .Resolved(let resolution): + body(resolution) + } + } + } + + private convenience init(when: Promise, body: (Resolution, (Resolution) -> Void) -> Void) { + self.init { resolve in + when.pipe { resolution in + body(resolution, resolve) + } + } + } + + /** + The provided closure is executed when this Promise is resolved. + + - Parameter on: The queue on which body should be executed. + - Parameter body: The closure that is executed when this Promise is fulfilled. + - Returns: A new promise that is resolved with the value returned from the provided closure. For example: + + NSURLConnection.GET(url).then { (data: NSData) -> Int in + //… + return data.length + }.then { length in + //… + } + + - SeeAlso: `thenInBackground` + */ + public func then(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: (T) throws -> U) -> Promise { + return Promise(when: self) { resolution, resolve in + switch resolution { + case .Rejected(let error): + resolve(.Rejected((error.0, error.1))) + case .Fulfilled(let value): + contain_zalgo(q, rejecter: resolve) { + resolve(.Fulfilled(try body(value))) + } + } + } + } + + /** + The provided closure is executed when this Promise is resolved. + + - Parameter on: The queue on which body should be executed. + - Parameter body: The closure that is executed when this Promise is fulfilled. + - Returns: A new promise that is resolved when the Promise returned from the provided closure resolves. For example: + + NSURLSession.GET(url1).then { (data: NSData) -> Promise in + //… + return NSURLSession.GET(url2) + }.then { data in + //… + } + + - SeeAlso: `thenInBackground` + */ + public func then(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: (T) throws -> Promise) -> Promise { + return Promise(when: self) { resolution, resolve in + switch resolution { + case .Rejected(let error): + resolve(.Rejected((error.0, error.1))) + case .Fulfilled(let value): + contain_zalgo(q, rejecter: resolve) { + let promise = try body(value) + guard promise !== self else { throw Error.ReturnedSelf } + promise.pipe(resolve) + } + } + } + } + + @available(*, unavailable) + public func then(on: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: (T) throws -> Promise?) -> Promise { abort() } + + /** + The provided closure is executed when this Promise is resolved. + + - Parameter on: The queue on which body should be executed. + - Parameter body: The closure that is executed when this Promise is fulfilled. + - Returns: A new promise that is resolved when the AnyPromise returned from the provided closure resolves. For example: + + NSURLSession.GET(url).then { (data: NSData) -> AnyPromise in + //… + return SCNetworkReachability() + }.then { _ in + //… + } + + - SeeAlso: `thenInBackground` + */ + public func then(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), body: (T) throws -> AnyPromise) -> Promise { + return Promise(when: self) { resolution, resolve in + switch resolution { + case .Rejected(let error): + resolve(.Rejected((error.0, error.1))) + case .Fulfilled(let value): + contain_zalgo(q, rejecter: resolve) { + try body(value).pipe(resolve) + } + } + } + } + + @available(*, unavailable) + public func then(on: dispatch_queue_t = PMKDefaultDispatchQueue(), body: (T) throws -> AnyPromise?) -> Promise { abort() } + + /** + The provided closure is executed on the default background queue when this Promise is fulfilled. + + This method is provided as a convenience for `then`. + + - SeeAlso: `then` + */ + public func thenInBackground(body: (T) throws -> U) -> Promise { + return then(on: dispatch_get_global_queue(0, 0), body) + } + + /** + The provided closure is executed on the default background queue when this Promise is fulfilled. + + This method is provided as a convenience for `then`. + + - SeeAlso: `then` + */ + public func thenInBackground(body: (T) throws -> Promise) -> Promise { + return then(on: dispatch_get_global_queue(0, 0), body) + } + + @available(*, unavailable) + public func thenInBackground(body: (T) throws -> Promise?) -> Promise { abort() } + + /** + The provided closure is executed when this promise is rejected. + + Rejecting a promise cascades: rejecting all subsequent promises (unless + recover is invoked) thus you will typically place your catch at the end + of a chain. Often utility promises will not have a catch, instead + delegating the error handling to the caller. + + The provided closure runs on PMKDefaultDispatchQueue by default. + + - Parameter policy: The default policy does not execute your handler for cancellation errors. See registerCancellationError for more documentation. + - Parameter body: The handler to execute if this promise is rejected. + - SeeAlso: `errorOnQueue` + */ + public func error(policy policy: ErrorPolicy = .AllErrorsExceptCancellation, _ body: (ErrorType) -> Void) { + errorOnQueue(policy: policy, body) + } + + /** + The provided closure is executed when this promise is rejected. + + Rejecting a promise cascades: rejecting all subsequent promises (unless + recover is invoked) thus you will typically place your catch at the end + of a chain. Often utility promises will not have a catch, instead + delegating the error handling to the caller. + + The provided closure runs on PMKDefaultDispatchQueue by default. + + - Parameter on: The queue on which body should be executed. + - Parameter policy: The default policy does not execute your handler for cancellation errors. See registerCancellationError for more documentation. + - Parameter body: The handler to execute if this promise is rejected. + - SeeAlso: `registerCancellationError` + */ + public func errorOnQueue(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), policy: ErrorPolicy = .AllErrorsExceptCancellation, _ body: (ErrorType) -> Void) { + + func consume(error: ErrorType, _ token: ErrorConsumptionToken) { + token.consumed = true + body(error) + } + + pipe { resolution in + switch (resolution, policy) { + case (let .Rejected(error, token), .AllErrorsExceptCancellation): + contain_zalgo(q) { + guard let cancellableError = error as? CancellableErrorType where cancellableError.cancelled else { + consume(error, token) + return + } + } + case (let .Rejected(error, token), _): + contain_zalgo(q) { + consume(error, token) + } + case (.Fulfilled, _): + break + } + } + } + + /** + Provides an alias for the `error` function for cases where the Swift + compiler cannot disambiguate from our `error` property. If you're + having trouble with `error`, before using this alias, first try + being as explicit as possible with the types e.g.: + + }.error { (error:ErrorType) -> Void in + //... + } + + Or even using verbose function syntax: + + }.error({ (error:ErrorType) -> Void in + //... + }) + + If you absolutely cannot get Swift to accept `error` then `onError` + may be used instead as it does the same thing. + + - Warning: This alias will be unavailable in PromiseKit 4.0.0 + - SeeAlso: [https://github.com/mxcl/PromiseKit/issues/347](https://github.com/mxcl/PromiseKit/issues/347) + */ + @available(*, deprecated, renamed="error", message="Temporary alias `onError` will eventually be removed and should only be used when the Swift compiler cannot be satisfied with `error`") + public func onError(policy policy: ErrorPolicy = .AllErrorsExceptCancellation, _ body: (ErrorType) -> Void) { + error(policy: policy, body) + } + + /** + The provided closure is executed when this promise is rejected giving you + an opportunity to recover from the error and continue the promise chain. + */ + public func recover(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: (ErrorType) throws -> Promise) -> Promise { + return Promise(when: self) { resolution, resolve in + switch resolution { + case .Rejected(let error, let token): + contain_zalgo(q, rejecter: resolve) { + token.consumed = true + let promise = try body(error) + guard promise !== self else { throw Error.ReturnedSelf } + promise.pipe(resolve) + } + case .Fulfilled: + resolve(resolution) + } + } + } + + @available(*, unavailable) + public func recover(on: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: (ErrorType) throws -> Promise?) -> Promise { abort() } + + public func recover(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: (ErrorType) throws -> T) -> Promise { + return Promise(when: self) { resolution, resolve in + switch resolution { + case .Rejected(let error, let token): + contain_zalgo(q, rejecter: resolve) { + token.consumed = true + resolve(.Fulfilled(try body(error))) + } + case .Fulfilled: + resolve(resolution) + } + } + } + + /** + The provided closure is executed when this Promise is resolved. + + UIApplication.sharedApplication().networkActivityIndicatorVisible = true + somePromise().then { + //… + }.always { + UIApplication.sharedApplication().networkActivityIndicatorVisible = false + } + + - Parameter on: The queue on which body should be executed. + - Parameter body: The closure that is executed when this Promise is resolved. + */ + public func always(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: () -> Void) -> Promise { + return Promise(when: self) { resolution, resolve in + contain_zalgo(q) { + body() + resolve(resolution) + } + } + } + + @available(*, unavailable, renamed="ensure") + public func finally(on: dispatch_queue_t = PMKDefaultDispatchQueue(), body: () -> Void) -> Promise { abort() } + + @available(*, unavailable, renamed="report") + public func catch_(policy policy: ErrorPolicy = .AllErrorsExceptCancellation, body: () -> Void) -> Promise { abort() } + + @available(*, unavailable, renamed="pendingPromise") + public class func defer_() -> (promise: Promise, fulfill: (T) -> Void, reject: (ErrorType) -> Void) { abort() } + + @available(*, deprecated, renamed="error") + public func report(policy policy: ErrorPolicy = .AllErrorsExceptCancellation, _ body: (ErrorType) -> Void) { error(policy: policy, body) } + + @available(*, deprecated, renamed="always") + public func ensure(on q: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: () -> Void) -> Promise { return always(on: q, body) } +} + +/** + Zalgo is dangerous. + + Pass as the `on` parameter for a `then`. Causes the handler to be executed + as soon as it is resolved. That means it will be executed on the queue it + is resolved. This means you cannot predict the queue. + + In the case that the promise is already resolved the handler will be + executed immediately. + + zalgo is provided for libraries providing promises that have good tests + that prove unleashing zalgo is safe. You can also use it in your + application code in situations where performance is critical, but be + careful: read the essay at the provided link to understand the risks. + + - SeeAlso: http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony +*/ +public let zalgo: dispatch_queue_t = dispatch_queue_create("Zalgo", nil) + +/** + Waldo is dangerous. + + Waldo is zalgo, unless the current queue is the main thread, in which case + we dispatch to the default background queue. + + If your block is likely to take more than a few milliseconds to execute, + then you should use waldo: 60fps means the main thread cannot hang longer + than 17 milliseconds. Don’t contribute to UI lag. + + Conversely if your then block is trivial, use zalgo: GCD is not free and + for whatever reason you may already be on the main thread so just do what + you are doing quickly and pass on execution. + + It is considered good practice for asynchronous APIs to complete onto the + main thread. Apple do not always honor this, nor do other developers. + However, they *should*. In that respect waldo is a good choice if your + then is going to take a while and doesn’t interact with the UI. + + Please note (again) that generally you should not use zalgo or waldo. The + performance gains are neglible and we provide these functions only out of + a misguided sense that library code should be as optimized as possible. + If you use zalgo or waldo without tests proving their correctness you may + unwillingly introduce horrendous, near-impossible-to-trace bugs. + + - SeeAlso: zalgo +*/ +public let waldo: dispatch_queue_t = dispatch_queue_create("Waldo", nil) + +func contain_zalgo(q: dispatch_queue_t, block: () -> Void) { + if q === zalgo { + block() + } else if q === waldo { + if NSThread.isMainThread() { + dispatch_async(dispatch_get_global_queue(0, 0), block) + } else { + block() + } + } else { + dispatch_async(q, block) + } +} + +func contain_zalgo(q: dispatch_queue_t, rejecter resolve: (Resolution) -> Void, block: () throws -> Void) { + contain_zalgo(q) { + do { + try block() + } catch { + resolve(.Rejected(error, ErrorConsumptionToken(error))) + } + } +} + + +extension Promise { + /** + Void promises are less prone to generics-of-doom scenarios. + - SeeAlso: when.swift contains enlightening examples of using `Promise` to simplify your code. + */ + public func asVoid() -> Promise { + return then(on: zalgo) { _ in return } + } +} + + +extension Promise: CustomStringConvertible { + public var description: String { + return "Promise: \(state)" + } +} + +/** + `firstly` can make chains more readable. + + Compare: + + NSURLConnection.GET(url1).then { + NSURLConnection.GET(url2) + }.then { + NSURLConnection.GET(url3) + } + + With: + + firstly { + NSURLConnection.GET(url1) + }.then { + NSURLConnection.GET(url2) + }.then { + NSURLConnection.GET(url3) + } +*/ +public func firstly(@noescape promise: () throws -> Promise) -> Promise { + do { + return try promise() + } catch { + return Promise(error: error) + } +} + +/** + `firstly` can make chains more readable. + + Compare: + + SCNetworkReachability().then { + NSURLSession.GET(url2) + }.then { + NSURLSession.GET(url3) + } + + With: + + firstly { + SCNetworkReachability() + }.then { + NSURLSession.GET(url2) + }.then { + NSURLSession.GET(url3) + } +*/ +public func firstly(@noescape promise: () throws -> AnyPromise) -> Promise { + return Promise { resolve in + try promise().pipe(resolve) + } +} + +@available(*, unavailable, message="Instead, throw") +public func firstly(@noescape promise: () throws -> Promise) -> Promise { + fatalError("Unavailable function") +} + + +public enum ErrorPolicy { + case AllErrors + case AllErrorsExceptCancellation +} + + +extension AnyPromise { + private func pipe(resolve: (Resolution) -> Void) -> Void { + pipe { (obj: AnyObject?) in + if let error = obj as? NSError { + resolve(.Rejected(error, ErrorConsumptionToken(error))) + } else { + // possibly the value of this promise is a PMKManifold, if so + // calling the objc `value` method will return the first item. + resolve(.Fulfilled(self.valueForKey("value"))) + } + } + } +} + + +extension Promise { + @available(*, unavailable, message="T cannot conform to ErrorType") + public convenience init(@noescape resolvers: (fulfill: (T) -> Void, reject: (ErrorType) -> Void) throws -> Void) { abort() } + + @available(*, unavailable, message="T cannot conform to ErrorType") + public convenience init(@noescape resolver: ((T?, NSError?) -> Void) throws -> Void) { abort() } + + @available(*, unavailable, message="T cannot conform to ErrorType") + public convenience init(@noescape resolver: ((T, NSError?) -> Void) throws -> Void) { abort() } + + @available(*, unavailable, message="T cannot conform to ErrorType") + public class func pendingPromise() -> (promise: Promise, fulfill: (T) -> Void, reject: (ErrorType) -> Void) { abort() } + + @available (*, unavailable, message="U cannot conform to ErrorType") + public func then(on: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: (T) throws -> U) -> Promise { abort() } + + @available (*, unavailable, message="U cannot conform to ErrorType") + public func then(on: dispatch_queue_t = PMKDefaultDispatchQueue(), _ body: (T) throws -> Promise) -> Promise { abort() } + + @available(*, unavailable, message="U cannot conform to ErrorType") + public func thenInBackground(body: (T) throws -> U) -> Promise { abort() } + + @available(*, unavailable, message="U cannot conform to ErrorType") + public func thenInBackground(body: (T) throws -> Promise) -> Promise { abort() } +} diff --git a/Pods/PromiseKit/Sources/PromiseKit.h b/Pods/PromiseKit/Sources/PromiseKit.h new file mode 100644 index 0000000..a83b3da --- /dev/null +++ b/Pods/PromiseKit/Sources/PromiseKit.h @@ -0,0 +1,252 @@ +#if defined(__cplusplus) + #import +#else + #import +#endif +#import +#import +#import +#import +#import + + + +/** + @return A new promise that resolves after the specified duration. + + @parameter duration The duration in seconds to wait before this promise is resolve. + + For example: + + PMKAfter(1).then(^{ + //… + }); +*/ +extern AnyPromise * __nonnull PMKAfter(NSTimeInterval duration); + + + +/** + `when` is a mechanism for waiting more than one asynchronous task and responding when they are all complete. + + `PMKWhen` accepts varied input. If an array is passed then when those promises fulfill, when’s promise fulfills with an array of fulfillment values. If a dictionary is passed then the same occurs, but when’s promise fulfills with a dictionary of fulfillments keyed as per the input. + + Interestingly, if a single promise is passed then when waits on that single promise, and if a single non-promise object is passed then when fulfills immediately with that object. If the array or dictionary that is passed contains objects that are not promises, then these objects are considered fulfilled promises. The reason we do this is to allow a pattern know as "abstracting away asynchronicity". + + If *any* of the provided promises reject, the returned promise is immediately rejected with that promise’s rejection. The error’s `userInfo` object is supplemented with `PMKFailingPromiseIndexKey`. + + For example: + + PMKWhen(@[promise1, promise2]).then(^(NSArray *results){ + //… + }); + + @warning *Important* In the event of rejection the other promises will continue to resolve and as per any other promise will eithe fulfill or reject. This is the right pattern for `getter` style asynchronous tasks, but often for `setter` tasks (eg. storing data on a server), you most likely will need to wait on all tasks and then act based on which have succeeded and which have failed. In such situations use `PMKJoin`. + + @param input The input upon which to wait before resolving this promise. + + @return A promise that is resolved with either: + + 1. An array of values from the provided array of promises. + 2. The value from the provided promise. + 3. The provided non-promise object. + + @see PMKJoin + +*/ +extern AnyPromise * __nonnull PMKWhen(id __nonnull input); + + + +/** + Creates a new promise that resolves only when all provided promises have resolved. + + Typically, you should use `PMKWhen`. + + For example: + + PMKJoin(@[promise1, promise2]).then(^(NSArray *resultingValues){ + //… + }).catch(^(NSError *error){ + assert(error.domain == PMKErrorDomain); + assert(error.code == PMKJoinError); + + NSArray *promises = error.userInfo[PMKJoinPromisesKey]; + for (AnyPromise *promise in promises) { + if (promise.rejected) { + //… + } + } + }); + + @param promises An array of promises. + + @return A promise that thens three parameters: + + 1) An array of mixed values and errors from the resolved input. + 2) An array of values from the promises that fulfilled. + 3) An array of errors from the promises that rejected or nil if all promises fulfilled. + + @see when +*/ +AnyPromise *__nonnull PMKJoin(NSArray * __nonnull promises); + + + +/** + Literally hangs this thread until the promise has resolved. + + Do not use hang… unless you are testing, playing or debugging. + + If you use it in production code I will literally and honestly cry like a child. + + @return The resolved value of the promise. + + @warning T SAFE. IT IS NOT SAFE. IT IS NOT SAFE. IT IS NOT SAFE. IT IS NO +*/ +extern id __nullable PMKHang(AnyPromise * __nonnull promise); + + + +/** + Sets the unhandled exception handler. + + If an exception is thrown inside an AnyPromise handler it is caught and + this handler is executed to determine if the promise is rejected. + + The default handler rejects the promise if an NSError or an NSString is + thrown. + + The default handler in PromiseKit 1.x would reject whatever object was + thrown (including nil). + + @warning *Important* This handler is provided to allow you to customize + which exceptions cause rejection and which abort. You should either + return a fully-formed NSError object or nil. Returning nil causes the + exception to be re-thrown. + + @warning *Important* The handler is executed on an undefined queue. + + @warning *Important* This function is thread-safe, but to facilitate this + it can only be called once per application lifetime and it must be called + before any promise in the app throws an exception. Subsequent calls will + silently fail. +*/ +extern void PMKSetUnhandledExceptionHandler(NSError * __nullable (^__nonnull handler)(id __nullable)); + + + +/** + Executes the provided block on a background queue. + + dispatch_promise is a convenient way to start a promise chain where the + first step needs to run synchronously on a background queue. + + dispatch_promise(^{ + return md5(input); + }).then(^(NSString *md5){ + NSLog(@"md5: %@", md5); + }); + + @param block The block to be executed in the background. Returning an `NSError` will reject the promise, everything else (including void) fulfills the promise. + + @return A promise resolved with the return value of the provided block. + + @see dispatch_async +*/ +extern AnyPromise * __nonnull dispatch_promise(id __nonnull block); + + + +/** + Executes the provided block on the specified background queue. + + dispatch_promise_on(myDispatchQueue, ^{ + return md5(input); + }).then(^(NSString *md5){ + NSLog(@"md5: %@", md5); + }); + + @param block The block to be executed in the background. Returning an `NSError` will reject the promise, everything else (including void) fulfills the promise. + + @return A promise resolved with the return value of the provided block. + + @see dispatch_promise +*/ +extern AnyPromise * __nonnull dispatch_promise_on(dispatch_queue_t __nonnull queue, id __nonnull block); + + + +#define PMKJSONDeserializationOptions ((NSJSONReadingOptions)(NSJSONReadingAllowFragments | NSJSONReadingMutableContainers)) + +/** + Really we shouldn’t assume JSON for (application|text)/(x-)javascript, + really we should return a String of Javascript. However in practice + for the apps we write it *will be* JSON. Thus if you actually want + a Javascript String, use the promise variant of our category functions. +*/ +#define PMKHTTPURLResponseIsJSON(rsp) [@[@"application/json", @"text/json", @"text/javascript", @"application/x-javascript", @"application/javascript"] containsObject:[rsp MIMEType]] +#define PMKHTTPURLResponseIsImage(rsp) [@[@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap"] containsObject:[rsp MIMEType]] +#define PMKHTTPURLResponseIsText(rsp) [[rsp MIMEType] hasPrefix:@"text/"] + + + +#if defined(__has_include) + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif + #if __has_include() + #import + #endif +#endif diff --git a/Pods/PromiseKit/Sources/State.swift b/Pods/PromiseKit/Sources/State.swift new file mode 100644 index 0000000..bb8eeb1 --- /dev/null +++ b/Pods/PromiseKit/Sources/State.swift @@ -0,0 +1,156 @@ +import Dispatch +import Foundation // NSLog + +enum Seal { + case Pending(Handlers) + case Resolved(R) +} + +enum Resolution { + case Fulfilled(T) + case Rejected(ErrorType, ErrorConsumptionToken) +} + +// would be a protocol, but you can't have typed variables of “generic” +// protocols in Swift 2. That is, I couldn’t do var state: State when +// it was a protocol. There is no work around. +class State { + func get() -> R? { fatalError("Abstract Base Class") } + func get(body: (Seal) -> Void) { fatalError("Abstract Base Class") } +} + +class UnsealedState: State { + private let barrier = dispatch_queue_create("org.promisekit.barrier", DISPATCH_QUEUE_CONCURRENT) + private var seal: Seal + + /** + Quick return, but will not provide the handlers array because + it could be modified while you are using it by another thread. + If you need the handlers, use the second `get` variant. + */ + override func get() -> R? { + var result: R? + dispatch_sync(barrier) { + if case .Resolved(let resolution) = self.seal { + result = resolution + } + } + return result + } + + override func get(body: (Seal) -> Void) { + var sealed = false + dispatch_sync(barrier) { + switch self.seal { + case .Resolved: + sealed = true + case .Pending: + sealed = false + } + } + if !sealed { + dispatch_barrier_sync(barrier) { + switch (self.seal) { + case .Pending: + body(self.seal) + case .Resolved: + sealed = true // welcome to race conditions + } + } + } + if sealed { + body(seal) + } + } + + required init(inout resolver: ((R) -> Void)!) { + seal = .Pending(Handlers()) + super.init() + resolver = { resolution in + var handlers: Handlers? + dispatch_barrier_sync(self.barrier) { + if case .Pending(let hh) = self.seal { + self.seal = .Resolved(resolution) + handlers = hh + } + } + if let handlers = handlers { + for handler in handlers { + handler(resolution) + } + } + } + } + + deinit { + if case .Pending = seal { + NSLog("PromiseKit: Pending Promise deallocated! This is usually a bug") + } + } +} + +class SealedState: State { + private let resolution: R + + init(resolution: R) { + self.resolution = resolution + } + + override func get() -> R? { + return resolution + } + + override func get(body: (Seal) -> Void) { + body(.Resolved(resolution)) + } +} + + +class Handlers: SequenceType { + var bodies: [(R)->Void] = [] + + func append(body: (R)->Void) { + bodies.append(body) + } + + func generate() -> IndexingGenerator<[(R)->Void]> { + return bodies.generate() + } + + var count: Int { + return bodies.count + } +} + + +extension Resolution: CustomStringConvertible { + var description: String { + switch self { + case .Fulfilled(let value): + return "Fulfilled with value: \(value)" + case .Rejected(let error): + return "Rejected with error: \(error)" + } + } +} + +extension UnsealedState: CustomStringConvertible { + var description: String { + var rv: String! + get { seal in + switch seal { + case .Pending(let handlers): + rv = "Pending with \(handlers.count) handlers" + case .Resolved(let resolution): + rv = "\(resolution)" + } + } + return "UnsealedState: \(rv)" + } +} + +extension SealedState: CustomStringConvertible { + var description: String { + return "SealedState: \(resolution)" + } +} diff --git a/Pods/PromiseKit/Sources/URLDataPromise.swift b/Pods/PromiseKit/Sources/URLDataPromise.swift new file mode 100644 index 0000000..00cd7a7 --- /dev/null +++ b/Pods/PromiseKit/Sources/URLDataPromise.swift @@ -0,0 +1,106 @@ +import Foundation + +public enum Encoding { + case JSON(NSJSONReadingOptions) +} + +public class URLDataPromise: Promise { + public func asDataAndResponse() -> Promise<(NSData, NSURLResponse)> { + return then(on: zalgo) { ($0, self.URLResponse) } + } + + public func asString() -> Promise { + return then(on: waldo) { data -> String in + guard let str = NSString(data: data, encoding: self.URLResponse.stringEncoding ?? NSUTF8StringEncoding) else { + throw URLError.StringEncoding(self.URLRequest, data, self.URLResponse) + } + return str as String + } + } + + public func asArray(encoding: Encoding = .JSON(.AllowFragments)) -> Promise { + return then(on: waldo) { data -> NSArray in + switch encoding { + case .JSON(let options): + guard !data.b0rkedEmptyRailsResponse else { return NSArray() } + let json = try NSJSONSerialization.JSONObjectWithData(data, options: options) + guard let array = json as? NSArray else { throw JSONError.UnexpectedRootNode(json) } + return array + } + } + } + + public func asDictionary(encoding: Encoding = .JSON(.AllowFragments)) -> Promise { + return then(on: waldo) { data -> NSDictionary in + switch encoding { + case .JSON(let options): + guard !data.b0rkedEmptyRailsResponse else { return NSDictionary() } + let json = try NSJSONSerialization.JSONObjectWithData(data, options: options) + guard let dict = json as? NSDictionary else { throw JSONError.UnexpectedRootNode(json) } + return dict + } + } + } + + private override init(@noescape resolvers: (fulfill: (NSData) -> Void, reject: (ErrorType) -> Void) throws -> Void) { + super.init(resolvers: resolvers) + } + + public override init(error: ErrorType) { + super.init(error: error) + } + + private var URLRequest: NSURLRequest! + private var URLResponse: NSURLResponse! + + public class func go(request: NSURLRequest, @noescape body: ((NSData?, NSURLResponse?, NSError?) -> Void) -> Void) -> URLDataPromise { + var promise: URLDataPromise! + promise = URLDataPromise { fulfill, reject in + body { data, rsp, error in + promise.URLRequest = request + promise.URLResponse = rsp + + if let error = error { + reject(URLError.UnderlyingCocoaError(request, data, rsp, error)) + } else if let data = data, rsp = rsp as? NSHTTPURLResponse where rsp.statusCode >= 200 && rsp.statusCode < 300 { + fulfill(data) + } else if let data = data where !(rsp is NSHTTPURLResponse) { + fulfill(data) + } else { + reject(URLError.BadResponse(request, data, rsp)) + } + } + } + return promise + } +} + +#if os(iOS) + import UIKit.UIImage + + extension URLDataPromise { + public func asImage() -> Promise { + return then(on: waldo) { data -> UIImage in + guard let img = UIImage(data: data), cgimg = img.CGImage else { + throw URLError.InvalidImageData(self.URLRequest, data) + } + return UIImage(CGImage: cgimg, scale: img.scale, orientation: img.imageOrientation) + } + } + } +#endif + +extension NSURLResponse { + private var stringEncoding: UInt? { + guard let encodingName = textEncodingName else { return nil } + let encoding = CFStringConvertIANACharSetNameToEncoding(encodingName) + guard encoding != kCFStringEncodingInvalidId else { return nil } + return CFStringConvertEncodingToNSStringEncoding(encoding) + } +} + +extension NSData { + private var b0rkedEmptyRailsResponse: Bool { + return self == NSData(bytes: " ", length: 1) + } +} diff --git a/Pods/PromiseKit/Sources/Umbrella.h b/Pods/PromiseKit/Sources/Umbrella.h new file mode 100644 index 0000000..658f067 --- /dev/null +++ b/Pods/PromiseKit/Sources/Umbrella.h @@ -0,0 +1,67 @@ +#import +#import +#import + +FOUNDATION_EXPORT double PromiseKitVersionNumber; +FOUNDATION_EXPORT const unsigned char PromiseKitVersionString[]; + +extern NSString * const PMKErrorDomain; + +#define PMKFailingPromiseIndexKey @"PMKFailingPromiseIndexKey" +#define PMKURLErrorFailingURLResponseKey @"PMKURLErrorFailingURLResponseKey" +#define PMKURLErrorFailingDataKey @"PMKURLErrorFailingDataKey" +#define PMKURLErrorFailingStringKey @"PMKURLErrorFailingStringKey" +#define PMKJSONErrorJSONObjectKey @"PMKJSONErrorJSONObjectKey" +#define PMKJoinPromisesKey @"PMKJoinPromisesKey" + +#define PMKUnexpectedError 1l +#define PMKUnknownError 2l +#define PMKInvalidUsageError 3l +#define PMKAccessDeniedError 4l +#define PMKOperationCancelled 5l +#define PMKNotFoundError 6l +#define PMKJSONError 7l +#define PMKOperationFailed 8l +#define PMKTaskError 9l +#define PMKJoinError 10l + +/** + This block lets you override the default dispatch queue for Promises. + + By default this returns dispatch_get_main_queue() + */ +FOUNDATION_EXPORT dispatch_queue_t (^PMKDefaultDispatchQueue)(); + +#if !(defined(PMKEZBake) && defined(SWIFT_CLASS)) + #if !defined(SWIFT_PASTE) + # define SWIFT_PASTE_HELPER(x, y) x##y + # define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y) + #endif + #if !defined(SWIFT_METATYPE) + # define SWIFT_METATYPE(X) Class + #endif + + #if defined(__has_attribute) && __has_attribute(objc_runtime_name) + # define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X))) + #else + # define SWIFT_RUNTIME_NAME(X) + #endif + #if !defined(SWIFT_CLASS_EXTRA) + # define SWIFT_CLASS_EXTRA + #endif + #if !defined(SWIFT_CLASS) + # if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted) + # define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA + # else + # define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA + # endif + #endif + + SWIFT_CLASS("AnyPromise") + @interface AnyPromise : NSObject + @property (nonatomic, readonly) BOOL pending; + @property (nonatomic, readonly) BOOL resolved; + @property (nonatomic, readonly) BOOL fulfilled; + @property (nonatomic, readonly) BOOL rejected; + @end +#endif diff --git a/Pods/PromiseKit/Sources/after.m b/Pods/PromiseKit/Sources/after.m new file mode 100644 index 0000000..c5f7a3b --- /dev/null +++ b/Pods/PromiseKit/Sources/after.m @@ -0,0 +1,13 @@ +#import "AnyPromise.h" +@import Dispatch; +@import Foundation.NSDate; +@import Foundation.NSValue; + +AnyPromise *PMKAfter(NSTimeInterval duration) { + return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) { + dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)); + dispatch_after(time, dispatch_get_global_queue(0, 0), ^{ + resolve(@(duration)); + }); + }]; +} diff --git a/Pods/PromiseKit/Sources/after.swift b/Pods/PromiseKit/Sources/after.swift new file mode 100644 index 0000000..f5bcd3d --- /dev/null +++ b/Pods/PromiseKit/Sources/after.swift @@ -0,0 +1,20 @@ +import Dispatch +import Foundation.NSDate + +/** + ``` + after(1).then { + //… + } + ``` + + - Returns: A new promise that resolves after the specified duration. + - Parameter duration: The duration in seconds to wait before this promise is resolve. +*/ +public func after(delay: NSTimeInterval) -> Promise { + return Promise { fulfill, _ in + let delta = delay * NSTimeInterval(NSEC_PER_SEC) + let when = dispatch_time(DISPATCH_TIME_NOW, Int64(delta)) + dispatch_after(when, dispatch_get_global_queue(0, 0), fulfill) + } +} diff --git a/Pods/PromiseKit/Sources/dispatch_promise.m b/Pods/PromiseKit/Sources/dispatch_promise.m new file mode 100644 index 0000000..71c8e74 --- /dev/null +++ b/Pods/PromiseKit/Sources/dispatch_promise.m @@ -0,0 +1,10 @@ +@import Dispatch; +#import "PromiseKit.h" + +AnyPromise *dispatch_promise(id block) { + return dispatch_promise_on(dispatch_get_global_queue(0, 0), block); +} + +AnyPromise *dispatch_promise_on(dispatch_queue_t queue, id block) { + return [AnyPromise promiseWithValue:nil].thenOn(queue, block); +} diff --git a/Pods/PromiseKit/Sources/dispatch_promise.swift b/Pods/PromiseKit/Sources/dispatch_promise.swift new file mode 100644 index 0000000..4a8133e --- /dev/null +++ b/Pods/PromiseKit/Sources/dispatch_promise.swift @@ -0,0 +1,23 @@ +import Dispatch +import Foundation.NSError + +/** + ``` + dispatch_promise { + try md5(input) + }.then { md5 in + //… + } + ``` + + - Parameter on: The queue on which to dispatch `body`. + - Parameter body: The closure that resolves this promise. + - Returns: A new promise resolved by the provided closure. +*/ +public func dispatch_promise(on queue: dispatch_queue_t = dispatch_get_global_queue(0, 0), body: () throws -> T) -> Promise { + return Promise(sealant: { resolve in + contain_zalgo(queue, rejecter: resolve) { + resolve(.Fulfilled(try body())) + } + }) +} diff --git a/Pods/PromiseKit/Sources/hang.m b/Pods/PromiseKit/Sources/hang.m new file mode 100644 index 0000000..ee3d9de --- /dev/null +++ b/Pods/PromiseKit/Sources/hang.m @@ -0,0 +1,24 @@ +#import "AnyPromise.h" +#import "AnyPromise+Private.h" +@import CoreFoundation.CFRunLoop; + +id PMKHang(AnyPromise *promise) { + if (promise.pending) { + static CFRunLoopSourceContext context; + + CFRunLoopRef runLoop = CFRunLoopGetCurrent(); + CFRunLoopSourceRef runLoopSource = CFRunLoopSourceCreate(NULL, 0, &context); + CFRunLoopAddSource(runLoop, runLoopSource, kCFRunLoopDefaultMode); + + promise.finally(^{ + CFRunLoopStop(runLoop); + }); + while (promise.pending) { + CFRunLoopRun(); + } + CFRunLoopRemoveSource(runLoop, runLoopSource, kCFRunLoopDefaultMode); + CFRelease(runLoopSource); + } + + return promise.value; +} diff --git a/Pods/PromiseKit/Sources/join.m b/Pods/PromiseKit/Sources/join.m new file mode 100644 index 0000000..b18e052 --- /dev/null +++ b/Pods/PromiseKit/Sources/join.m @@ -0,0 +1,47 @@ +#import "AnyPromise.h" +#import "AnyPromise+Private.h" +@import Foundation.NSDictionary; +@import Foundation.NSError; +@import Foundation.NSNull; +#import +#import + +@implementation AnyPromise (join) + +AnyPromise *PMKJoin(NSArray *promises) { + if (promises == nil) + return [AnyPromise promiseWithValue:[NSError errorWithDomain:PMKErrorDomain code:PMKInvalidUsageError userInfo:@{NSLocalizedDescriptionKey: @"PMKJoin(nil)"}]]; + + if (promises.count == 0) + return [AnyPromise promiseWithValue:promises]; + + return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) { + NSPointerArray *results = NSPointerArrayMake(promises.count); + __block int32_t countdown = (int32_t)promises.count; + __block BOOL rejected = NO; + + [promises enumerateObjectsUsingBlock:^(AnyPromise *promise, NSUInteger ii, BOOL *stop) { + [promise pipe:^(id value) { + + if (IsError(value)) { + [value pmk_consume]; + rejected = YES; + } + + [results replacePointerAtIndex:ii withPointer:(__bridge void *)(value ?: [NSNull null])]; + + if (OSAtomicDecrement32(&countdown) == 0) { + if (!rejected) { + resolve(results.allObjects); + } else { + id userInfo = @{PMKJoinPromisesKey: promises}; + id err = [NSError errorWithDomain:PMKErrorDomain code:PMKJoinError userInfo:userInfo]; + resolve(err); + } + } + }]; + }]; + }]; +} + +@end diff --git a/Pods/PromiseKit/Sources/join.swift b/Pods/PromiseKit/Sources/join.swift new file mode 100644 index 0000000..b543a66 --- /dev/null +++ b/Pods/PromiseKit/Sources/join.swift @@ -0,0 +1,50 @@ +import Dispatch + +/** + Waits on all provided promises. + + `when` rejects as soon as one of the provided promises rejects. `join` waits on all provided promises, then rejects if any of those promises rejected, otherwise it fulfills with values from the provided promises. + + join(promise1, promise2, promise3).then { results in + //… + }.error { error in + switch error { + case Error.Join(let promises): + //… + } + } + + - Returns: A new promise that resolves once all the provided promises resolve. +*/ +public func join(promises: Promise...) -> Promise<[T]> { + return join(promises) +} + +public func join(promises: [Promise]) -> Promise<[T]> { + guard !promises.isEmpty else { return Promise<[T]>([]) } + + var countdown = promises.count + let barrier = dispatch_queue_create("org.promisekit.barrier.join", DISPATCH_QUEUE_CONCURRENT) + var rejected = false + + return Promise { fulfill, reject in + for promise in promises { + promise.pipe { resolution in + dispatch_barrier_sync(barrier) { + if case .Rejected(_, let token) = resolution { + token.consumed = true // the parent Error.Join consumes all + rejected = true + } + countdown -= 1 + if countdown == 0 { + if rejected { + reject(Error.Join(promises)) + } else { + fulfill(promises.map{ $0.value! }) + } + } + } + } + } + } +} diff --git a/Pods/PromiseKit/Sources/race.swift b/Pods/PromiseKit/Sources/race.swift new file mode 100644 index 0000000..4cfb1b0 --- /dev/null +++ b/Pods/PromiseKit/Sources/race.swift @@ -0,0 +1,31 @@ +import Foundation.NSError + +/** + Resolves with the first resolving promise from a set of promises. + + ``` + race(promise1, promise2, promise3).then { winner in + //… + } + ``` + + - Returns: A new promise that resolves when the first promise in the provided promises resolves. + - Warning: If any of the provided promises reject, the returned promise is rejected. +*/ +public func race(promises: Promise...) -> Promise { + return try! race(promises) // race only throws when the array param is empty, which is not possible from this + // variadic paramater version, so we can safely use `try!` +} + +public func race(promises: [Promise]) throws -> Promise { + guard !promises.isEmpty else { + let message = "Cannot race with an empty list of runners (Promises)" + throw NSError(domain: PMKErrorDomain, code: PMKInvalidUsageError, userInfo: ["messaage": message]) + } + + return Promise(sealant: { resolve in + for promise in promises { + promise.pipe(resolve) + } + }) +} diff --git a/Pods/PromiseKit/Sources/when.m b/Pods/PromiseKit/Sources/when.m new file mode 100644 index 0000000..b4f21f2 --- /dev/null +++ b/Pods/PromiseKit/Sources/when.m @@ -0,0 +1,86 @@ +#import "AnyPromise.h" +#import "AnyPromise+Private.h" +@import Foundation.NSDictionary; +@import Foundation.NSError; +@import Foundation.NSProgress; +@import Foundation.NSNull; +#import +#import "Umbrella.h" + +// NSProgress resources: +// * https://robots.thoughtbot.com/asynchronous-nsprogress +// * http://oleb.net/blog/2014/03/nsprogress/ +// NSProgress! Beware! +// * https://github.com/AFNetworking/AFNetworking/issues/2261 + +AnyPromise *PMKWhen(id promises) { + if (promises == nil) + return [AnyPromise promiseWithValue:[NSError errorWithDomain:PMKErrorDomain code:PMKInvalidUsageError userInfo:@{NSLocalizedDescriptionKey: @"PMKWhen(nil)"}]]; + + if ([promises isKindOfClass:[NSArray class]] || [promises isKindOfClass:[NSDictionary class]]) { + if ([promises count] == 0) + return [AnyPromise promiseWithValue:promises]; + } else if ([promises isKindOfClass:[AnyPromise class]]) { + promises = @[promises]; + } else { + return [AnyPromise promiseWithValue:promises]; + } + +#ifndef PMKDisableProgress + NSProgress *progress = [NSProgress progressWithTotalUnitCount:[promises count]]; + progress.pausable = NO; + progress.cancellable = NO; +#else + struct PMKProgress { + int completedUnitCount; + int totalUnitCount; + }; + __block struct PMKProgress progress; +#endif + + __block int32_t countdown = (int32_t)[promises count]; + BOOL const isdict = [promises isKindOfClass:[NSDictionary class]]; + + return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) { + NSInteger index = 0; + + for (__strong id key in promises) { + AnyPromise *promise = isdict ? promises[key] : key; + if (!isdict) key = @(index); + + if (![promise isKindOfClass:[AnyPromise class]]) + promise = [AnyPromise promiseWithValue:promise]; + + [promise pipe:^(id value){ + if (progress.fractionCompleted >= 1) + return; + + if (IsError(value)) { + progress.completedUnitCount = progress.totalUnitCount; + resolve(NSErrorSupplement(value, @{PMKFailingPromiseIndexKey: key})); + } + else if (OSAtomicDecrement32(&countdown) == 0) { + progress.completedUnitCount = progress.totalUnitCount; + + id results; + if (isdict) { + results = [NSMutableDictionary new]; + for (id key in promises) { + id promise = promises[key]; + results[key] = IsPromise(promise) ? ((AnyPromise *)promise).value : promise; + } + } else { + results = [NSMutableArray new]; + for (AnyPromise *promise in promises) { + id value = IsPromise(promise) ? (promise.value ?: [NSNull null]) : promise; + [results addObject:value]; + } + } + resolve(results); + } else { + progress.completedUnitCount++; + } + }]; + } + }]; +} diff --git a/Pods/PromiseKit/Sources/when.swift b/Pods/PromiseKit/Sources/when.swift new file mode 100644 index 0000000..7c01db4 --- /dev/null +++ b/Pods/PromiseKit/Sources/when.swift @@ -0,0 +1,88 @@ +import Foundation.NSProgress + +private func _when(promises: [Promise]) -> Promise { + let (rootPromise, fulfill, reject) = Promise.pendingPromise() +#if !PMKDisableProgress + let progress = NSProgress(totalUnitCount: Int64(promises.count)) + progress.cancellable = false + progress.pausable = false +#else + var progress: (completedUnitCount: Int, totalUnitCount: Int) = (0, 0) +#endif + var countdown = promises.count + if countdown == 0 { + fulfill() + return rootPromise + } + let barrier = dispatch_queue_create("org.promisekit.barrier.when", DISPATCH_QUEUE_CONCURRENT) + + for (index, promise) in promises.enumerate() { + promise.pipe { resolution in + dispatch_barrier_sync(barrier) { + switch resolution { + case .Rejected(let error, let token): + token.consumed = true // all errors are consumed by the parent Error.When + if rootPromise.pending { + progress.completedUnitCount = progress.totalUnitCount + reject(Error.When(index, error)) + } + case .Fulfilled: + guard rootPromise.pending else { return } + progress.completedUnitCount += 1 + countdown -= 1 + if countdown == 0 { + fulfill() + } + } + } + } + } + + return rootPromise +} + +/** + Wait for all promises in a set to resolve. + + For example: + + when(promise1, promise2).then { results in + //… + }.error { error in + switch error { + case Error.When(let index, NSURLError.NoConnection): + //… + case Error.When(let index, CLError.NotAuthorized): + //… + } + } + + - Warning: If *any* of the provided promises reject, the returned promise is immediately rejected with that promise’s rejection. The error’s `userInfo` object is supplemented with `PMKFailingPromiseIndexKey`. + - Warning: In the event of rejection the other promises will continue to resolve and, as per any other promise, will either fulfill or reject. This is the right pattern for `getter` style asynchronous tasks, but often for `setter` tasks (eg. storing data on a server), you most likely will need to wait on all tasks and then act based on which have succeeded and which have failed, in such situations use `join`. + - Parameter promises: The promises upon which to wait before the returned promise resolves. + - Returns: A new promise that resolves when all the provided promises fulfill or one of the provided promises rejects. + - SeeAlso: `join()` +*/ +public func when(promises: [Promise]) -> Promise<[T]> { + return _when(promises).then(on: zalgo) { promises.map{ $0.value! } } +} + +public func when(promises: Promise...) -> Promise<[T]> { + return when(promises) +} + +public func when(promises: Promise...) -> Promise { + return _when(promises) +} + +public func when(promises: [Promise]) -> Promise { + return _when(promises) +} + +public func when(pu: Promise, _ pv: Promise) -> Promise<(U, V)> { + return _when([pu.asVoid(), pv.asVoid()]).then(on: zalgo) { (pu.value!, pv.value!) } +} + +public func when(pu: Promise, _ pv: Promise, _ px: Promise) -> Promise<(U, V, X)> { + return _when([pu.asVoid(), pv.asVoid(), px.asVoid()]).then(on: zalgo) { (pu.value!, pv.value!, px.value!) } +} diff --git a/Pods/Target Support Files/OMGHTTPURLRQ/Info.plist b/Pods/Target Support Files/OMGHTTPURLRQ/Info.plist new file mode 100644 index 0000000..60d0f97 --- /dev/null +++ b/Pods/Target Support Files/OMGHTTPURLRQ/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.cocoapods.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 3.1.2 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-dummy.m b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-dummy.m new file mode 100644 index 0000000..1449708 --- /dev/null +++ b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_OMGHTTPURLRQ : NSObject +@end +@implementation PodsDummy_OMGHTTPURLRQ +@end diff --git a/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-prefix.pch b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-umbrella.h b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-umbrella.h new file mode 100644 index 0000000..e6ad2ae --- /dev/null +++ b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ-umbrella.h @@ -0,0 +1,9 @@ +#import + +#import "OMGFormURLEncode.h" +#import "OMGHTTPURLRQ.h" +#import "OMGUserAgent.h" + +FOUNDATION_EXPORT double OMGHTTPURLRQVersionNumber; +FOUNDATION_EXPORT const unsigned char OMGHTTPURLRQVersionString[]; + diff --git a/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.modulemap b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.modulemap new file mode 100644 index 0000000..f508eea --- /dev/null +++ b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.modulemap @@ -0,0 +1,6 @@ +framework module OMGHTTPURLRQ { + umbrella header "OMGHTTPURLRQ-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.xcconfig b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.xcconfig new file mode 100644 index 0000000..13e88fd --- /dev/null +++ b/Pods/Target Support Files/OMGHTTPURLRQ/OMGHTTPURLRQ.xcconfig @@ -0,0 +1,4 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/OMGHTTPURLRQ" "${PODS_ROOT}/Headers/Public" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/Pods/Target Support Files/Pods/Info.plist b/Pods/Target Support Files/Pods/Info.plist new file mode 100644 index 0000000..6974542 --- /dev/null +++ b/Pods/Target Support Files/Pods/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.cocoapods.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown b/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown new file mode 100644 index 0000000..ef47c62 --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown @@ -0,0 +1,11 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## OMGHTTPURLRQ + +See README.markdown for full license text. + +## PromiseKit + +@see README +Generated by CocoaPods - http://cocoapods.org diff --git a/Pods/Target Support Files/Pods/Pods-acknowledgements.plist b/Pods/Target Support Files/Pods/Pods-acknowledgements.plist new file mode 100644 index 0000000..73fc8a0 --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods-acknowledgements.plist @@ -0,0 +1,45 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + See README.markdown for full license text. + Title + OMGHTTPURLRQ + Type + PSGroupSpecifier + + + FooterText + @see README + Title + PromiseKit + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - http://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Pods/Target Support Files/Pods/Pods-dummy.m b/Pods/Target Support Files/Pods/Pods-dummy.m new file mode 100644 index 0000000..ade64bd --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods : NSObject +@end +@implementation PodsDummy_Pods +@end diff --git a/Pods/Target Support Files/Pods/Pods-frameworks.sh b/Pods/Target Support Files/Pods/Pods-frameworks.sh new file mode 100755 index 0000000..8df2ca9 --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods-frameworks.sh @@ -0,0 +1,105 @@ +#!/bin/sh +set -e + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # use filter instead of exclude so missing patterns dont' throw errors + echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" + /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current file + archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" + stripped="" + for arch in $archs; do + if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi +} + + +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_framework "Pods/OMGHTTPURLRQ.framework" + install_framework "Pods/PromiseKit.framework" +fi +if [[ "$CONFIGURATION" == "Beta" ]]; then + install_framework "Pods/OMGHTTPURLRQ.framework" + install_framework "Pods/PromiseKit.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "Pods/OMGHTTPURLRQ.framework" + install_framework "Pods/PromiseKit.framework" +fi +if [[ "$CONFIGURATION" == "Release Beta" ]]; then + install_framework "Pods/OMGHTTPURLRQ.framework" + install_framework "Pods/PromiseKit.framework" +fi +if [[ "$CONFIGURATION" == "Distribution" ]]; then + install_framework "Pods/OMGHTTPURLRQ.framework" + install_framework "Pods/PromiseKit.framework" +fi diff --git a/Pods/Target Support Files/Pods/Pods-resources.sh b/Pods/Target Support Files/Pods/Pods-resources.sh new file mode 100755 index 0000000..16774fb --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods-resources.sh @@ -0,0 +1,95 @@ +#!/bin/sh +set -e + +mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +realpath() { + DIRECTORY="$(cd "${1%/*}" && pwd)" + FILENAME="${1##*/}" + echo "$DIRECTORY/$FILENAME" +} + +install_resource() +{ + case $1 in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" + ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" + ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" + ;; + *.framework) + echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" + xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" + xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" + xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + /*) + echo "$1" + echo "$1" >> "$RESOURCES_TO_COPY" + ;; + *) + echo "${PODS_ROOT}/$1" + echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" + ;; + esac +} + +mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; + esac + + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "`realpath $PODS_ROOT`*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi diff --git a/Pods/Target Support Files/Pods/Pods-umbrella.h b/Pods/Target Support Files/Pods/Pods-umbrella.h new file mode 100644 index 0000000..21dcfd2 --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods-umbrella.h @@ -0,0 +1,6 @@ +#import + + +FOUNDATION_EXPORT double PodsVersionNumber; +FOUNDATION_EXPORT const unsigned char PodsVersionString[]; + diff --git a/Pods/Target Support Files/Pods/Pods.beta.xcconfig b/Pods/Target Support Files/Pods/Pods.beta.xcconfig new file mode 100644 index 0000000..0f418bc --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods.beta.xcconfig @@ -0,0 +1,9 @@ +EMBEDDED_CONTENT_CONTAINS_SWIFT = YES +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OMGHTTPURLRQ.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/PromiseKit.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "OMGHTTPURLRQ" -framework "PromiseKit" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods +PODS_ROOT = ${SRCROOT}/Pods +SWIFT_INSTALL_OBJC_HEADER = NO \ No newline at end of file diff --git a/Pods/Target Support Files/Pods/Pods.debug.xcconfig b/Pods/Target Support Files/Pods/Pods.debug.xcconfig new file mode 100644 index 0000000..0f418bc --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods.debug.xcconfig @@ -0,0 +1,9 @@ +EMBEDDED_CONTENT_CONTAINS_SWIFT = YES +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OMGHTTPURLRQ.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/PromiseKit.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "OMGHTTPURLRQ" -framework "PromiseKit" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods +PODS_ROOT = ${SRCROOT}/Pods +SWIFT_INSTALL_OBJC_HEADER = NO \ No newline at end of file diff --git a/Pods/Target Support Files/Pods/Pods.distribution.xcconfig b/Pods/Target Support Files/Pods/Pods.distribution.xcconfig new file mode 100644 index 0000000..0f418bc --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods.distribution.xcconfig @@ -0,0 +1,9 @@ +EMBEDDED_CONTENT_CONTAINS_SWIFT = YES +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OMGHTTPURLRQ.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/PromiseKit.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "OMGHTTPURLRQ" -framework "PromiseKit" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods +PODS_ROOT = ${SRCROOT}/Pods +SWIFT_INSTALL_OBJC_HEADER = NO \ No newline at end of file diff --git a/Pods/Target Support Files/Pods/Pods.modulemap b/Pods/Target Support Files/Pods/Pods.modulemap new file mode 100644 index 0000000..8413413 --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods.modulemap @@ -0,0 +1,6 @@ +framework module Pods { + umbrella header "Pods-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/Pods/Pods.release beta.xcconfig b/Pods/Target Support Files/Pods/Pods.release beta.xcconfig new file mode 100644 index 0000000..0f418bc --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods.release beta.xcconfig @@ -0,0 +1,9 @@ +EMBEDDED_CONTENT_CONTAINS_SWIFT = YES +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OMGHTTPURLRQ.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/PromiseKit.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "OMGHTTPURLRQ" -framework "PromiseKit" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods +PODS_ROOT = ${SRCROOT}/Pods +SWIFT_INSTALL_OBJC_HEADER = NO \ No newline at end of file diff --git a/Pods/Target Support Files/Pods/Pods.release.xcconfig b/Pods/Target Support Files/Pods/Pods.release.xcconfig new file mode 100644 index 0000000..0f418bc --- /dev/null +++ b/Pods/Target Support Files/Pods/Pods.release.xcconfig @@ -0,0 +1,9 @@ +EMBEDDED_CONTENT_CONTAINS_SWIFT = YES +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OMGHTTPURLRQ.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/PromiseKit.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "OMGHTTPURLRQ" -framework "PromiseKit" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods +PODS_ROOT = ${SRCROOT}/Pods +SWIFT_INSTALL_OBJC_HEADER = NO \ No newline at end of file diff --git a/Pods/Target Support Files/PromiseKit/Info.plist b/Pods/Target Support Files/PromiseKit/Info.plist new file mode 100644 index 0000000..4071dac --- /dev/null +++ b/Pods/Target Support Files/PromiseKit/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.cocoapods.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 3.2.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/PromiseKit/PromiseKit-dummy.m b/Pods/Target Support Files/PromiseKit/PromiseKit-dummy.m new file mode 100644 index 0000000..ce92451 --- /dev/null +++ b/Pods/Target Support Files/PromiseKit/PromiseKit-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_PromiseKit : NSObject +@end +@implementation PodsDummy_PromiseKit +@end diff --git a/Pods/Target Support Files/PromiseKit/PromiseKit-prefix.pch b/Pods/Target Support Files/PromiseKit/PromiseKit-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/Pods/Target Support Files/PromiseKit/PromiseKit-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/Pods/Target Support Files/PromiseKit/PromiseKit.modulemap b/Pods/Target Support Files/PromiseKit/PromiseKit.modulemap new file mode 100644 index 0000000..7e55ef9 --- /dev/null +++ b/Pods/Target Support Files/PromiseKit/PromiseKit.modulemap @@ -0,0 +1,32 @@ +framework module PromiseKit { + umbrella header "Umbrella.h" + + header "NSError+Cancellation.h" + + exclude header "AnyPromise.h" + exclude header "PromiseKit.h" + exclude header "PMKPromise.h" + exclude header "Promise.h" + + exclude header "Pods-PromiseKit-umbrella.h" + + exclude header "ACAccountStore+AnyPromise.h" + exclude header "AVAudioSession+AnyPromise.h" + exclude header "CKContainer+AnyPromise.h" + exclude header "CKDatabase+AnyPromise.h" + exclude header "CLGeocoder+AnyPromise.h" + exclude header "CLLocationManager+AnyPromise.h" + exclude header "NSNotificationCenter+AnyPromise.h" + exclude header "NSTask+AnyPromise.h" + exclude header "NSURLConnection+AnyPromise.h" + exclude header "MKDirections+AnyPromise.h" + exclude header "MKMapSnapshotter+AnyPromise.h" + exclude header "CALayer+AnyPromise.h" + exclude header "SLRequest+AnyPromise.h" + exclude header "SKRequest+AnyPromise.h" + exclude header "SCNetworkReachability+AnyPromise.h" + exclude header "UIActionSheet+AnyPromise.h" + exclude header "UIAlertView+AnyPromise.h" + exclude header "UIView+AnyPromise.h" + exclude header "UIViewController+AnyPromise.h" +} diff --git a/Pods/Target Support Files/PromiseKit/PromiseKit.xcconfig b/Pods/Target Support Files/PromiseKit/PromiseKit.xcconfig new file mode 100644 index 0000000..66f974a --- /dev/null +++ b/Pods/Target Support Files/PromiseKit/PromiseKit.xcconfig @@ -0,0 +1,7 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/PromiseKit" "${PODS_ROOT}/Headers/Public" +OTHER_LDFLAGS = -framework "Foundation" -framework "QuartzCore" -framework "UIKit" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES +SWIFT_INSTALL_OBJC_HEADER = NO \ No newline at end of file diff --git a/README.md b/README.md index 0136d9e..acf91aa 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#CycleAtanta +#CycleAtlanta iOS ## Introduction Cycle Atlanta is a smartphone app for recording your bicycle trips. When you use the app, you are giving transportation planners with the City of Atlanta the data they need to make Atlanta a better place to ride. diff --git a/RegionManager.swift b/RegionManager.swift new file mode 100644 index 0000000..4549ea6 --- /dev/null +++ b/RegionManager.swift @@ -0,0 +1,21 @@ +// +// RegionManager.swift +// Cycle Atlanta +// +// +// + +import Foundation + +class RegionManager { + + var region: OBARegionV2? + + class var sharedInstance :RegionManager { + struct Singleton { + static let instance = RegionManager() + } + + return Singleton.instance + } +}