diff --git a/HeadsUpper/.DS_Store b/HeadsUpper/.DS_Store new file mode 100644 index 0000000..14b43a6 Binary files /dev/null and b/HeadsUpper/.DS_Store differ diff --git a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj index fb900f8..9a1547e 100644 --- a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj +++ b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj @@ -13,9 +13,13 @@ 8D8969651C755D0200D32E8A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D8969631C755D0200D32E8A /* Main.storyboard */; }; 8D8969671C755D0200D32E8A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8D8969661C755D0200D32E8A /* Assets.xcassets */; }; 8D89696A1C755D0200D32E8A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D8969681C755D0200D32E8A /* LaunchScreen.storyboard */; }; + B2C45988F93DAF20E7E44A26 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE86313080561EF5C41DC294 /* Pods.framework */; }; + F030B06A1C7A0E1A00407A9D /* topicsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F030B0691C7A0E1A00407A9D /* topicsTableViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 0905DEB147669BEDF7DEAAA1 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + 4DF2ED69A2638C8BF0823992 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; 8D8969571C755D0200D32E8A /* HeadsUpper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HeadsUpper.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8D89695B1C755D0200D32E8A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8D89695D1C755D0200D32E8A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -26,6 +30,9 @@ 8D8969661C755D0200D32E8A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 8D8969691C755D0200D32E8A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 8D89696B1C755D0200D32E8A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + DE86313080561EF5C41DC294 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F030B0681C7A0E1A00407A9D /* topicsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = topicsTableViewController.h; sourceTree = ""; }; + F030B0691C7A0E1A00407A9D /* topicsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = topicsTableViewController.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -33,17 +40,29 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + B2C45988F93DAF20E7E44A26 /* Pods.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 42407C4B314E1BC02A8BCF40 /* Pods */ = { + isa = PBXGroup; + children = ( + 4DF2ED69A2638C8BF0823992 /* Pods.debug.xcconfig */, + 0905DEB147669BEDF7DEAAA1 /* Pods.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; 8D89694E1C755D0200D32E8A = { isa = PBXGroup; children = ( 8D8969591C755D0200D32E8A /* HeadsUpper */, 8D8969581C755D0200D32E8A /* Products */, + 42407C4B314E1BC02A8BCF40 /* Pods */, + C864A2927E4F4F78A9E5DA14 /* Frameworks */, ); sourceTree = ""; }; @@ -63,6 +82,8 @@ 8D8969601C755D0200D32E8A /* ViewController.h */, 8D8969611C755D0200D32E8A /* ViewController.m */, 8D8969631C755D0200D32E8A /* Main.storyboard */, + F030B0681C7A0E1A00407A9D /* topicsTableViewController.h */, + F030B0691C7A0E1A00407A9D /* topicsTableViewController.m */, 8D8969661C755D0200D32E8A /* Assets.xcassets */, 8D8969681C755D0200D32E8A /* LaunchScreen.storyboard */, 8D89696B1C755D0200D32E8A /* Info.plist */, @@ -79,6 +100,14 @@ name = "Supporting Files"; sourceTree = ""; }; + C864A2927E4F4F78A9E5DA14 /* Frameworks */ = { + isa = PBXGroup; + children = ( + DE86313080561EF5C41DC294 /* Pods.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -86,9 +115,12 @@ isa = PBXNativeTarget; buildConfigurationList = 8D89696E1C755D0200D32E8A /* Build configuration list for PBXNativeTarget "HeadsUpper" */; buildPhases = ( + 59EB75DB03FA7B27CF5811DB /* Check Pods Manifest.lock */, 8D8969531C755D0200D32E8A /* Sources */, 8D8969541C755D0200D32E8A /* Frameworks */, 8D8969551C755D0200D32E8A /* Resources */, + 276B3B68C2243967EEF45D74 /* Embed Pods Frameworks */, + 77AC60D5140B18F5D302311F /* Copy Pods Resources */, ); buildRules = ( ); @@ -110,6 +142,7 @@ TargetAttributes = { 8D8969561C755D0200D32E8A = { CreatedOnToolsVersion = 7.2.1; + DevelopmentTeam = 788Q6NYZ88; }; }; }; @@ -144,6 +177,54 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 276B3B68C2243967EEF45D74 /* 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; + }; + 59EB75DB03FA7B27CF5811DB /* 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; + }; + 77AC60D5140B18F5D302311F /* 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; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 8D8969531C755D0200D32E8A /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -152,6 +233,7 @@ 8D8969621C755D0200D32E8A /* ViewController.m in Sources */, 8D89695F1C755D0200D32E8A /* AppDelegate.m in Sources */, 8D89695C1C755D0200D32E8A /* main.m in Sources */, + F030B06A1C7A0E1A00407A9D /* topicsTableViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -259,25 +341,33 @@ }; 8D89696F1C755D0200D32E8A /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 4DF2ED69A2638C8BF0823992 /* Pods.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = HeadsUpper/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.HeadsUpper; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; }; name = Debug; }; 8D8969701C755D0200D32E8A /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 0905DEB147669BEDF7DEAAA1 /* Pods.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = HeadsUpper/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.HeadsUpper; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; }; name = Release; }; @@ -300,6 +390,7 @@ 8D8969701C755D0200D32E8A /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/HeadsUpper/HeadsUpper.xcworkspace/contents.xcworkspacedata b/HeadsUpper/HeadsUpper.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..9b6faaf --- /dev/null +++ b/HeadsUpper/HeadsUpper.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/HeadsUpper/HeadsUpper/Base.lproj/LaunchScreen.storyboard b/HeadsUpper/HeadsUpper/Base.lproj/LaunchScreen.storyboard index 2e721e1..980ec3c 100644 --- a/HeadsUpper/HeadsUpper/Base.lproj/LaunchScreen.storyboard +++ b/HeadsUpper/HeadsUpper/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -15,7 +16,6 @@ - diff --git a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard index f56d2f3..e587c58 100644 --- a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard +++ b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard @@ -1,13 +1,76 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -15,11 +78,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HeadsUpper/HeadsUpper/Info.plist b/HeadsUpper/HeadsUpper/Info.plist index 6905cc6..db26bc0 100644 --- a/HeadsUpper/HeadsUpper/Info.plist +++ b/HeadsUpper/HeadsUpper/Info.plist @@ -2,6 +2,11 @@ + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + CFBundleDevelopmentRegion en CFBundleExecutable diff --git a/HeadsUpper/HeadsUpper/ViewController.h b/HeadsUpper/HeadsUpper/ViewController.h index 65d6cf5..bdc6ff4 100644 --- a/HeadsUpper/HeadsUpper/ViewController.h +++ b/HeadsUpper/HeadsUpper/ViewController.h @@ -10,6 +10,7 @@ @interface ViewController : UIViewController +@property (nonatomic) NSArray * answers; @end diff --git a/HeadsUpper/HeadsUpper/ViewController.m b/HeadsUpper/HeadsUpper/ViewController.m index 14ce57a..f3ea235 100644 --- a/HeadsUpper/HeadsUpper/ViewController.m +++ b/HeadsUpper/HeadsUpper/ViewController.m @@ -7,8 +7,25 @@ // #import "ViewController.h" +#import +#import +#import +#import @interface ViewController () +@property (nonatomic) NSInteger timerCount; +@property (nonatomic) NSInteger readyTimerCount; +@property (weak, nonatomic) IBOutlet UILabel *timerLabel; +@property (weak, nonatomic) IBOutlet UILabel *guess; +@property (nonatomic) NSInteger rightCount; +@property (weak, nonatomic) IBOutlet UIView *readyView; +@property (weak, nonatomic) IBOutlet UILabel *readyLabel; + +@property (nonatomic) NSInteger whichAnswerAreWeAt; +@property (nonatomic) NSInteger totalGuesses; +@property (nonatomic) AFHTTPSessionManager *manager; +@property (weak, nonatomic) IBOutlet UIImageView *backgroundImage; +@property (nonatomic) SDWebImageManager *SDmanager; @end @@ -16,7 +33,177 @@ @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + self.SDmanager = [SDWebImageManager sharedManager]; + self.whichAnswerAreWeAt = 0; + self.rightCount = 0; + self.totalGuesses = 1; +// self.guess.text = self.answers[self.whichAnswerAreWeAt]; + self.readyLabel.text = @"3"; + + [self setupReadyTimer]; + self.readyView.backgroundColor = [UIColor colorWithGradientStyle:UIGradientStyleTopToBottom withFrame: self.view.frame andColors:@[[UIColor flatWhiteColorDark], [UIColor flatWhiteColor]]]; + + self.manager = [[AFHTTPSessionManager alloc] init]; + self.manager.responseSerializer = [AFHTTPResponseSerializer serializer]; + [self showNextGuess]; + + +} + +# pragma mark - gesture methods +- (void) setUpGestureRecognizers { + UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)]; + leftSwipe.direction= UISwipeGestureRecognizerDirectionLeft; + + UISwipeGestureRecognizer *rightSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)]; + rightSwipe.direction = UISwipeGestureRecognizerDirectionRight; + + + + [self.view addGestureRecognizer:leftSwipe]; + [self.view addGestureRecognizer:rightSwipe]; + +} + +- (void) handleSwipe: (UISwipeGestureRecognizer *) gesture { + if (self.whichAnswerAreWeAt==self.answers.count-1) { + self.whichAnswerAreWeAt = 0; + } + else{ + self.whichAnswerAreWeAt++; + } + + switch (gesture.direction) { + case UISwipeGestureRecognizerDirectionRight: + [self animateViewWith:[UIColor flatWatermelonColorDark]]; + self.totalGuesses++; + [self showNextGuess]; + break; + case UISwipeGestureRecognizerDirectionLeft: + [self animateViewWith:[UIColor flatMintColorDark]]; + self.rightCount++; + self.totalGuesses++; + [self showNextGuess]; + break; + default: + break; + } +} + +-(void) showNextGuess{ + NSString *currGuess = self.answers[self.whichAnswerAreWeAt]; + self.backgroundImage.image = nil; + self.guess.text = currGuess; + NSString * url = [[NSString stringWithFormat:@"http://api.duckduckgo.com/?q=%@&format=json", currGuess] stringByAddingPercentEscapesUsingEncoding: + NSASCIIStringEncoding]; + + [self. manager GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + NSError *error; + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:&error]; + + NSURL * imageUrl = [NSURL URLWithString:[json objectForKey:@"Image"]]; + [self.SDmanager downloadImageWithURL:imageUrl + options:0 + progress:^(NSInteger receivedSize, NSInteger expectedSize) { + // progression tracking code + } + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (image) { + self.backgroundImage.image = image; + } + + }]; + + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { + NSLog(@"%@", error); + }]; + +} + +-(void) animateViewWith:(UIColor* )color{ + [UIView animateWithDuration:0.5 + animations:^{ + self.view.backgroundColor = color; + } completion:^(BOOL finished) { + self.view.backgroundColor = [UIColor whiteColor]; + }]; +} + +# pragma mark - timer methods +-(void) setupReadyTimer +{ + self.readyTimerCount = 2; + NSTimer *timer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(handleReadyTimer:) userInfo:nil repeats:YES]; + + [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; + +} + +- (void) handleReadyTimer: (NSTimer * ) timer { + + + self.readyLabel.text = [NSString stringWithFormat: @"%ld", (long)self.readyTimerCount]; + self.readyTimerCount--; + + if (self.readyTimerCount < 0 ) { + self.readyLabel.text = @"Go!"; + [UIView animateWithDuration:1.0 + animations:^{ + self.readyView.transform = CGAffineTransformMakeScale(1.5, 1.5); + } completion:^(BOOL finished) { + self.readyView.hidden = YES; + }]; + + [self setupTimer]; + [timer invalidate]; + //hide ready screen + } + +} + +-(void) setupTimer +{ + self.timerCount = 30; + NSTimer *timer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(handleGameTimer:) userInfo:nil repeats:YES]; + + [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; + //[timer fire]; + [self setUpGestureRecognizers]; +} + +- (void) handleGameTimer: (NSTimer * ) timer { + + + self.timerLabel.text = [NSString stringWithFormat: @"%ld", (long)self.timerCount]; + self.timerCount--; + + if (self.timerCount < 0 ) { + [timer invalidate]; + + //show score + NSString * endGameText = [NSString stringWithFormat:@"you got %ld out of %ld right", (long)self.rightCount, self.totalGuesses]; + SIAlertView *alertView = [[SIAlertView alloc] initWithTitle:@"Game Over" andMessage:endGameText]; + + [alertView addButtonWithTitle:@"Play Again" + type:SIAlertViewButtonTypeDefault + handler:^(SIAlertView *alert) { + + }]; + + alertView.didDismissHandler = ^(SIAlertView *alertView) { + [self dismissViewControllerAnimated:YES completion:nil]; + }; + + alertView.transitionStyle = SIAlertViewTransitionStyleBounce; + + [alertView show]; + + + //end game + + // + } + } - (void)didReceiveMemoryWarning { diff --git a/HeadsUpper/HeadsUpper/topicsTableViewController.h b/HeadsUpper/HeadsUpper/topicsTableViewController.h new file mode 100644 index 0000000..f752249 --- /dev/null +++ b/HeadsUpper/HeadsUpper/topicsTableViewController.h @@ -0,0 +1,13 @@ +// +// topicsTableViewController.h +// HeadsUpper +// +// Created by Henna Ahmed on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface topicsTableViewController : UITableViewController + +@end diff --git a/HeadsUpper/HeadsUpper/topicsTableViewController.m b/HeadsUpper/HeadsUpper/topicsTableViewController.m new file mode 100644 index 0000000..babc4d5 --- /dev/null +++ b/HeadsUpper/HeadsUpper/topicsTableViewController.m @@ -0,0 +1,157 @@ +// +// topicsTableViewController.m +// HeadsUpper +// +// Created by Henna Ahmed on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "topicsTableViewController.h" +#import "ViewController.h" +#import +#import + + +@interface topicsTableViewController () + +@property (nonatomic) NSDictionary * topics; +@property (nonatomic) SDWebImageManager *manager; +@property (nonatomic) NSURL * imageUrl; + +@end + +@implementation topicsTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.manager = [SDWebImageManager sharedManager]; + + + self.title = @"Heads Up"; + [self.navigationController.navigationBar setTitleTextAttributes: + @{NSForegroundColorAttributeName:[UIColor whiteColor]}]; + + + [self.navigationController.navigationBar setBarTintColor:FlatWatermelon]; + self.navigationController.hidesNavigationBarHairline = YES; + + self.topics = @{ + @"Superstars" : @[@"Janet Jackson", @"Leighton Meester", @"Willow Smith", @"Matt Lauer", @"Josh Duhamel", @"Sharon Osbourne", @"Spencer Pratt", @"Demi Moore", @"Whitney Houston", @"Nicole Kidman", @"Miley Cyrus", @"Victoria Beckham", @"LeAnn Rimes", @"Dakota Fanning", @"Dr. Seuss", @"Ryan Phillippe", @"Steve Carell", @"Chris Rock", @"Collin Ferell", @"Drake", @"Rachel McAdams", @"Maya Rudolph"], + @"That's so 90s" : @[@"El Niño", @"Viagra", @"Animaniacs", @"League of their Own", @"Happy Gilmore", @"Nick Carter", @"My Heart Will Go On", @"I Know What You Did Last Summer", @"Can You Feel The Love Tonight", @"The Macarana", @"Light-up Sneakers", @"Boy Meets World", @"Baby Got Back", @"Smells Like Teen Spirit", @"Super Soakers", @"7th Heaven", @"Garth Brooks", @"Floppy Discs", @"Kramer", @"Blink 182", @"Surge"], + @"Hey Mr. DJ" : @[@"\"Girl On Fire\" Alicia Keys", @"\"U Can't Touch This\" MC Hammer", @"\"Hello\" Lionel Richie", @"\"Dark Horse\" Katy Perry", @"\"Someboyd To Love\" Queen", @"\"No Scrubs\" TLC", @"\"Happy\" Pharrell Williams", @"\"Piano Man\" Billy Joel", @"\"Blurred Lines\" Robin Thicke", @"\"Fantasy\" Mariah Carey", @"\"I Will Survive\" Gloria Gaynor", @"\"Come and Get it\" Selena Gomez", @"\"Halo\" Beyonce", @"\"I Believe I Can Fly\" R.Kelly", @"\"The Sign\" Ace of Base", @"\"Diamonds\" Rihanna", @"\"A Thousand Miles\" Vanessa Carlton", @"\"What a Wonderful World\" Louis Armstrong", @"\"We Belong Together\" Mariah Carey", @"\"(I Can't Get No) Satisfaction\""], + @"Icons" : @[@"Colin Farrell", @"Mozart", @"Billy Joel", @"Judy Garland", @"Napoleon Bonaparte", @"Queen Elizabeth II", @"Fred Armisen", @"Henry Ford", @"Jon Lovitz", @"Julia Child", @"Catherine the Great", @"Magic Johnson", @"Uma Thurman", @"Orson Welles", @"Kathy Bates", @"George Orwell", @"Billy Crystal", @"Farrah Fawcett", @"Gary Busey", @"Chris Farley", @"Tom Selleck", @"Alexander the Great"], + @"Animals Gone Wild" : @[@"Chipmunk", @"Dragon", @"Wasp", @"Snake", @"Jellyfish", @"Emu", @"Boar", @"Crocodile", @"Shrimp", @"Lemur", @"Caterpillar", @"Sea Urchain", @"Dolphin ", @"Camel", @"Viper", @"Fox", @"Tuna", @"Baboon", @"Chinchilla", @"Human", @"Crawfish", @"Cricket", @"Frog", @"Tiger", @"Guinea Pig", @"Gnat", @"Killer Whale", @"Coral", @"T-Rex", @"Oyster"] + }; + + //http://api.search.live.net/json.aspx?AppId=YOUR_APPID&Query=xbox%20site:microsoft.com&Sources=Image&Version=2.0&Market=en-us&Adult=Moderate&Image.Count=10&Image.Offset=0 + + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + return self.topics.allKeys.count; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"topicCellIdentifier" forIndexPath:indexPath]; + cell.textLabel.text = self.topics.allKeys[indexPath.row]; + cell.textLabel.textColor = [UIColor flatWhiteColorDark]; + cell.textLabel.shadowColor = [UIColor flatPlumColorDark]; + cell.textLabel.shadowOffset = CGSizeMake(1, 1); + cell.backgroundColor = [UIColor clearColor]; + self.imageUrl = [NSURL URLWithString:[NSString stringWithFormat:@"https://unsplash.it/400/600?image=%u", arc4random_uniform(1000)]]; + + [self.manager downloadImageWithURL:self.imageUrl + options:0 + progress:^(NSInteger receivedSize, NSInteger expectedSize) { + // progression tracking code + } + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (image) { + UIImageView *imageview = [[UIImageView alloc] initWithImage:image]; + imageview.contentMode = UIViewContentModeScaleAspectFill; + cell.backgroundView = imageview; + } + + }]; + + + + + + return cell; +} + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ + NSIndexPath *indexPath = [self.tableView indexPathForCell:sender]; + NSString *key = self.topics.allKeys[indexPath.row]; + + ViewController *vc = segue.destinationViewController; + vc.answers = [self.topics objectForKey:key]; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return 100; +} + + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/HeadsUpper/Podfile b/HeadsUpper/Podfile new file mode 100644 index 0000000..1fcd0ae --- /dev/null +++ b/HeadsUpper/Podfile @@ -0,0 +1,5 @@ +use_frameworks! +pod 'ChameleonFramework', '~> 2.1' +pod 'SIAlertView', '~> 1.3' +pod 'SDWebImage', '~> 3.7' +pod 'AFNetworking', '~> 3.0' \ No newline at end of file diff --git a/HeadsUpper/Podfile.lock b/HeadsUpper/Podfile.lock new file mode 100644 index 0000000..1d642d7 --- /dev/null +++ b/HeadsUpper/Podfile.lock @@ -0,0 +1,37 @@ +PODS: + - AFNetworking (3.0.4): + - AFNetworking/NSURLSession (= 3.0.4) + - AFNetworking/Reachability (= 3.0.4) + - AFNetworking/Security (= 3.0.4) + - AFNetworking/Serialization (= 3.0.4) + - AFNetworking/UIKit (= 3.0.4) + - AFNetworking/NSURLSession (3.0.4): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (3.0.4) + - AFNetworking/Security (3.0.4) + - AFNetworking/Serialization (3.0.4) + - AFNetworking/UIKit (3.0.4): + - AFNetworking/NSURLSession + - ChameleonFramework (2.1.0): + - ChameleonFramework/Default (= 2.1.0) + - ChameleonFramework/Default (2.1.0) + - SDWebImage (3.7.5): + - SDWebImage/Core (= 3.7.5) + - SDWebImage/Core (3.7.5) + - SIAlertView (1.3) + +DEPENDENCIES: + - AFNetworking (~> 3.0) + - ChameleonFramework (~> 2.1) + - SDWebImage (~> 3.7) + - SIAlertView (~> 1.3) + +SPEC CHECKSUMS: + AFNetworking: a0075feb321559dc78d9d85b55d11caa19eabb93 + ChameleonFramework: d21a3cc247abfe5e37609a283a8238b03575cf64 + SDWebImage: 69c6303e3348fba97e03f65d65d4fbc26740f461 + SIAlertView: 20c794b55eaf44d888773ea51647cf8907723919 + +COCOAPODS: 0.39.0 diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h new file mode 100644 index 0000000..55ed92e --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1,295 @@ +// AFHTTPSessionManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import +#if !TARGET_OS_WATCH +#import +#endif +#import + +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV +#import +#else +#import +#endif + +#import "AFURLSessionManager.h" + +/** + `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths. + + ## Subclassing Notes + + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:completionHandler:`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFHTTPSessionManager : AFURLSessionManager + +/** + The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong, nullable) NSURL *baseURL; + +/** + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns an `AFHTTPSessionManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + @param configuration The configuration used to create the managed session. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url + sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `NSURLSessionDataTask` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; + + +/** + Creates and runs an `NSURLSessionDataTask` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param progress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(nullable id)parameters + progress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; + +/** + Creates and runs an `NSURLSessionDataTask` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param progress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + progress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; + +/** + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param progress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + progress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m new file mode 100644 index 0000000..a28cc6e --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m @@ -0,0 +1,361 @@ +// AFHTTPSessionManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "AFHTTPSessionManager.h" + +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" + +#import +#import +#import + +#import +#import +#import +#import +#import + +#if TARGET_OS_IOS || TARGET_OS_TV +#import +#elif TARGET_OS_WATCH +#import +#endif + +@interface AFHTTPSessionManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPSessionManager +@dynamic responseSerializer; + ++ (instancetype)manager { + return [[[self class] alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + return [self initWithBaseURL:url sessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + return [self initWithBaseURL:nil sessionConfiguration:configuration]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url + sessionConfiguration:(NSURLSessionConfiguration *)configuration +{ + self = [super initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + return self; +} + +#pragma mark - + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [super setResponseSerializer:responseSerializer]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + + return [self GET:URLString parameters:parameters progress:nil success:success failure:failure]; +} + +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + progress:(void (^)(NSProgress * _Nonnull))downloadProgress + success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success + failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure +{ + + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET" + URLString:URLString + parameters:parameters + uploadProgress:nil + downloadProgress:downloadProgress + success:success + failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) { + if (success) { + success(task); + } + } failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + return [self POST:URLString parameters:parameters progress:nil success:success failure:failure]; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + progress:(void (^)(NSProgress * _Nonnull))uploadProgress + success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success + failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id _Nonnull))block + success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure +{ + return [self POST:URLString parameters:parameters constructingBodyWithBlock:block progress:nil success:success failure:failure]; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(task, error); + } + } else { + if (success) { + success(task, responseObject); + } + } + }]; + + [task resume]; + + return task; +} + +- (NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress + success:(void (^)(NSURLSessionDataTask *, id))success + failure:(void (^)(NSURLSessionDataTask *, NSError *))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *dataTask = nil; + dataTask = [self dataTaskWithRequest:request + uploadProgress:uploadProgress + downloadProgress:downloadProgress + completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(dataTask, error); + } + } else { + if (success) { + success(dataTask, responseObject); + } + } + }]; + + return dataTask; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))]; + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + if (!configuration) { + NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"]; + if (configurationIdentifier) { +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100) + configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier]; +#else + configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier]; +#endif + } + } + + self = [self initWithBaseURL:baseURL sessionConfiguration:configuration]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))]; + if (decodedPolicy) { + self.securityPolicy = decodedPolicy; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; + } else { + [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"]; + } + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; + [coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone]; + return HTTPClient; +} + +@end diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h new file mode 100644 index 0000000..4cf0496 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1,206 @@ +// AFNetworkReachabilityManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#if !TARGET_OS_WATCH +#import + +typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { + AFNetworkReachabilityStatusUnknown = -1, + AFNetworkReachabilityStatusNotReachable = 0, + AFNetworkReachabilityStatusReachableViaWWAN = 1, + AFNetworkReachabilityStatusReachableViaWiFi = 2, +}; + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + + Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. + + See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/) + + @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. + */ +@interface AFNetworkReachabilityManager : NSObject + +/** + The current network reachability status. + */ +@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; + +/** + Whether or not the network is currently reachable. + */ +@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; + +/** + Whether or not the network is currently reachable via WWAN. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; + +/** + Whether or not the network is currently reachable via WiFi. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Returns the shared network reachability manager. + */ ++ (instancetype)sharedManager; + +/** + Creates and returns a network reachability manager with the default socket address. + + @return An initialized network reachability manager, actively monitoring the default socket address. + */ ++ (instancetype)manager; + +/** + Creates and returns a network reachability manager for the specified domain. + + @param domain The domain used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified domain. + */ ++ (instancetype)managerForDomain:(NSString *)domain; + +/** + Creates and returns a network reachability manager for the socket address. + + @param address The socket address (`sockaddr_in6`) used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified socket address. + */ ++ (instancetype)managerForAddress:(const void *)address; + +/** + Initializes an instance of a network reachability manager from the specified reachability object. + + @param reachability The reachability object to monitor. + + @return An initialized network reachability manager, actively monitoring the specified reachability. + */ +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; + +///-------------------------------------------------- +/// @name Starting & Stopping Reachability Monitoring +///-------------------------------------------------- + +/** + Starts monitoring for changes in network reachability status. + */ +- (void)startMonitoring; + +/** + Stops monitoring for changes in network reachability status. + */ +- (void)stopMonitoring; + +///------------------------------------------------- +/// @name Getting Localized Reachability Description +///------------------------------------------------- + +/** + Returns a localized string representation of the current network reachability status. + */ +- (NSString *)localizedNetworkReachabilityStatusString; + +///--------------------------------------------------- +/// @name Setting Network Reachability Change Callback +///--------------------------------------------------- + +/** + Sets a callback to be executed when the network availability of the `baseURL` host changes. + + @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. + */ +- (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Network Reachability + + The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. + + enum { + AFNetworkReachabilityStatusUnknown, + AFNetworkReachabilityStatusNotReachable, + AFNetworkReachabilityStatusReachableViaWWAN, + AFNetworkReachabilityStatusReachableViaWiFi, + } + + `AFNetworkReachabilityStatusUnknown` + The `baseURL` host reachability is not known. + + `AFNetworkReachabilityStatusNotReachable` + The `baseURL` host cannot be reached. + + `AFNetworkReachabilityStatusReachableViaWWAN` + The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. + + `AFNetworkReachabilityStatusReachableViaWiFi` + The `baseURL` host can be reached via a Wi-Fi connection. + + ### Keys for Notification UserInfo Dictionary + + Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. + + `AFNetworkingReachabilityNotificationStatusItem` + A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. + The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. + */ + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when network reachability changes. + This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. + + @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). + */ +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification; +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem; + +///-------------------- +/// @name Functions +///-------------------- + +/** + Returns a localized string representation of an `AFNetworkReachabilityStatus` value. + */ +FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); + +NS_ASSUME_NONNULL_END +#endif diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m new file mode 100644 index 0000000..5fba0f7 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m @@ -0,0 +1,260 @@ +// AFNetworkReachabilityManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "AFNetworkReachabilityManager.h" +#if !TARGET_OS_WATCH + +#import +#import +#import +#import +#import + +NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; +NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; + +typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); + +NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusNotReachable: + return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWWAN: + return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWiFi: + return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); + case AFNetworkReachabilityStatusUnknown: + default: + return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); + } +} + +static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { + BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); + BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); + BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); + BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); + BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); + + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; + if (isNetworkReachable == NO) { + status = AFNetworkReachabilityStatusNotReachable; + } +#if TARGET_OS_IPHONE + else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { + status = AFNetworkReachabilityStatusReachableViaWWAN; + } +#endif + else { + status = AFNetworkReachabilityStatusReachableViaWiFi; + } + + return status; +} + +/** + * Queue a status change notification for the main thread. + * + * This is done to ensure that the notifications are received in the same order + * as they are sent. If notifications are sent directly, it is possible that + * a queued notification (for an earlier status condition) is processed after + * the later update, resulting in the listener being left in the wrong state. + */ +static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) { + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + dispatch_async(dispatch_get_main_queue(), ^{ + if (block) { + block(status); + } + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; + }); +} + +static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { + AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info); +} + + +static const void * AFNetworkReachabilityRetainCallback(const void *info) { + return Block_copy(info); +} + +static void AFNetworkReachabilityReleaseCallback(const void *info) { + if (info) { + Block_release(info); + } +} + +@interface AFNetworkReachabilityManager () +@property (readwrite, nonatomic, strong) id networkReachability; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; +@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; +@end + +@implementation AFNetworkReachabilityManager + ++ (instancetype)sharedManager { + static AFNetworkReachabilityManager *_sharedManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _sharedManager = [self manager]; + }); + + return _sharedManager; +} + +#ifndef __clang_analyzer__ ++ (instancetype)managerForDomain:(NSString *)domain { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + + return manager; +} +#endif + +#ifndef __clang_analyzer__ ++ (instancetype)managerForAddress:(const void *)address { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + + return manager; +} +#endif + ++ (instancetype)manager +{ +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) + struct sockaddr_in6 address; + bzero(&address, sizeof(address)); + address.sin6_len = sizeof(address); + address.sin6_family = AF_INET6; +#else + struct sockaddr_in address; + bzero(&address, sizeof(address)); + address.sin_len = sizeof(address); + address.sin_family = AF_INET; +#endif + return [self managerForAddress:&address]; +} + +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { + self = [super init]; + if (!self) { + return nil; + } + + self.networkReachability = CFBridgingRelease(reachability); + self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; + + return self; +} + +- (instancetype)init NS_UNAVAILABLE +{ + return nil; +} + +- (void)dealloc { + [self stopMonitoring]; +} + +#pragma mark - + +- (BOOL)isReachable { + return [self isReachableViaWWAN] || [self isReachableViaWiFi]; +} + +- (BOOL)isReachableViaWWAN { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; +} + +- (BOOL)isReachableViaWiFi { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; +} + +#pragma mark - + +- (void)startMonitoring { + [self stopMonitoring]; + + if (!self.networkReachability) { + return; + } + + __weak __typeof(self)weakSelf = self; + AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + + strongSelf.networkReachabilityStatus = status; + if (strongSelf.networkReachabilityStatusBlock) { + strongSelf.networkReachabilityStatusBlock(status); + } + + }; + + id networkReachability = self.networkReachability; + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; + SCNetworkReachabilitySetCallback((__bridge SCNetworkReachabilityRef)networkReachability, AFNetworkReachabilityCallback, &context); + SCNetworkReachabilityScheduleWithRunLoop((__bridge SCNetworkReachabilityRef)networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ + SCNetworkReachabilityFlags flags; + if (SCNetworkReachabilityGetFlags((__bridge SCNetworkReachabilityRef)networkReachability, &flags)) { + AFPostReachabilityStatusChange(flags, callback); + } + }); +} + +- (void)stopMonitoring { + if (!self.networkReachability) { + return; + } + + SCNetworkReachabilityUnscheduleFromRunLoop((__bridge SCNetworkReachabilityRef)self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); +} + +#pragma mark - + +- (NSString *)localizedNetworkReachabilityStatusString { + return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); +} + +#pragma mark - + +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { + self.networkReachabilityStatusBlock = block; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { + return [NSSet setWithObject:@"networkReachabilityStatus"]; + } + + return [super keyPathsForValuesAffectingValueForKey:key]; +} + +@end +#endif diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFNetworking.h b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFNetworking.h new file mode 100644 index 0000000..e2fb2f4 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFNetworking.h @@ -0,0 +1,41 @@ +// AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// 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. + +#import +#import +#import + +#ifndef _AFNETWORKING_ + #define _AFNETWORKING_ + + #import "AFURLRequestSerialization.h" + #import "AFURLResponseSerialization.h" + #import "AFSecurityPolicy.h" + +#if !TARGET_OS_WATCH + #import "AFNetworkReachabilityManager.h" +#endif + + #import "AFURLSessionManager.h" + #import "AFHTTPSessionManager.h" + +#endif /* _AFNETWORKING_ */ diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h new file mode 100644 index 0000000..90fa212 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1,154 @@ +// AFSecurityPolicy.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import +#import + +typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, +}; + +/** + `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + + Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFSecurityPolicy : NSObject + +/** + The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. + */ +@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; + +/** + The certificates used to evaluate server trust according to the SSL pinning mode. + + By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`. + + Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. + */ +@property (nonatomic, strong, nullable) NSSet *pinnedCertificates; + +/** + Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL allowInvalidCertificates; + +/** + Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. + */ +@property (nonatomic, assign) BOOL validatesDomainName; + +///----------------------------------------- +/// @name Getting Certificates from the Bundle +///----------------------------------------- + +/** + Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`. + + @return The certificates included in the given bundle. + */ ++ (NSSet *)certificatesInBundle:(NSBundle *)bundle; + +///----------------------------------------- +/// @name Getting Specific Security Policies +///----------------------------------------- + +/** + Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. + + @return The default security policy. + */ ++ (instancetype)defaultPolicy; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a security policy with the specified pinning mode. + + @param pinningMode The SSL pinning mode. + + @return A new security policy. + */ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; + +/** + Creates and returns a security policy with the specified pinning mode. + + @param pinningMode The SSL pinning mode. + @param pinnedCertificates The certificates to pin against. + + @return A new security policy. + */ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates; + +///------------------------------ +/// @name Evaluating Server Trust +///------------------------------ + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + @param domain The domain of serverTrust. If `nil`, the domain will not be validated. + + @return Whether or not to trust the server. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(nullable NSString *)domain; + +@end + +NS_ASSUME_NONNULL_END + +///---------------- +/// @name Constants +///---------------- + +/** + ## SSL Pinning Modes + + The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. + + enum { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, + } + + `AFSSLPinningModeNone` + Do not used pinned certificates to validate servers. + + `AFSSLPinningModePublicKey` + Validate host certificates against public keys of pinned certificates. + + `AFSSLPinningModeCertificate` + Validate host certificates against pinned certificates. +*/ diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m new file mode 100644 index 0000000..3704cca --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m @@ -0,0 +1,353 @@ +// AFSecurityPolicy.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "AFSecurityPolicy.h" + +#import + +#if !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV +static NSData * AFSecKeyGetData(SecKeyRef key) { + CFDataRef data = NULL; + + __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); + + return (__bridge_transfer NSData *)data; + +_out: + if (data) { + CFRelease(data); + } + + return nil; +} +#endif + +static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV + return [(__bridge id)key1 isEqual:(__bridge id)key2]; +#else + return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; +#endif +} + +static id AFPublicKeyForCertificate(NSData *certificate) { + id allowedPublicKey = nil; + SecCertificateRef allowedCertificate; + SecCertificateRef allowedCertificates[1]; + CFArrayRef tempCertificates = nil; + SecPolicyRef policy = nil; + SecTrustRef allowedTrust = nil; + SecTrustResultType result; + + allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); + __Require_Quiet(allowedCertificate != NULL, _out); + + allowedCertificates[0] = allowedCertificate; + tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); + + policy = SecPolicyCreateBasicX509(); + __Require_noErr_Quiet(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out); + __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out); + + allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); + +_out: + if (allowedTrust) { + CFRelease(allowedTrust); + } + + if (policy) { + CFRelease(policy); + } + + if (tempCertificates) { + CFRelease(tempCertificates); + } + + if (allowedCertificate) { + CFRelease(allowedCertificate); + } + + return allowedPublicKey; +} + +static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { + BOOL isValid = NO; + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out); + + isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); + +_out: + return isValid; +} + +static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + } + + return [NSArray arrayWithArray:trustChain]; +} + +static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { + SecPolicyRef policy = SecPolicyCreateBasicX509(); + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + + SecCertificateRef someCertificates[] = {certificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); + + SecTrustRef trust; + __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); + + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out); + + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; + + _out: + if (trust) { + CFRelease(trust); + } + + if (certificates) { + CFRelease(certificates); + } + + continue; + } + CFRelease(policy); + + return [NSArray arrayWithArray:trustChain]; +} + +#pragma mark - + +@interface AFSecurityPolicy() +@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode; +@property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys; +@end + +@implementation AFSecurityPolicy + ++ (NSSet *)certificatesInBundle:(NSBundle *)bundle { + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; + + NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]]; + for (NSString *path in paths) { + NSData *certificateData = [NSData dataWithContentsOfFile:path]; + [certificates addObject:certificateData]; + } + + return [NSSet setWithSet:certificates]; +} + ++ (NSSet *)defaultPinnedCertificates { + static NSSet *_defaultPinnedCertificates = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + _defaultPinnedCertificates = [self certificatesInBundle:bundle]; + }); + + return _defaultPinnedCertificates; +} + ++ (instancetype)defaultPolicy { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = AFSSLPinningModeNone; + + return securityPolicy; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { + return [self policyWithPinningMode:pinningMode withPinnedCertificates:[self defaultPinnedCertificates]]; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = pinningMode; + + [securityPolicy setPinnedCertificates:pinnedCertificates]; + + return securityPolicy; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.validatesDomainName = YES; + + return self; +} + +- (void)setPinnedCertificates:(NSSet *)pinnedCertificates { + _pinnedCertificates = pinnedCertificates; + + if (self.pinnedCertificates) { + NSMutableSet *mutablePinnedPublicKeys = [NSMutableSet setWithCapacity:[self.pinnedCertificates count]]; + for (NSData *certificate in self.pinnedCertificates) { + id publicKey = AFPublicKeyForCertificate(certificate); + if (!publicKey) { + continue; + } + [mutablePinnedPublicKeys addObject:publicKey]; + } + self.pinnedPublicKeys = [NSSet setWithSet:mutablePinnedPublicKeys]; + } else { + self.pinnedPublicKeys = nil; + } +} + +#pragma mark - + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(NSString *)domain +{ + if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) { + // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html + // According to the docs, you should only trust your provided certs for evaluation. + // Pinned certificates are added to the trust. Without pinned certificates, + // there is nothing to evaluate against. + // + // From Apple Docs: + // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors). + // Instead, add your own (self-signed) CA certificate to the list of trusted anchors." + NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning."); + return NO; + } + + NSMutableArray *policies = [NSMutableArray array]; + if (self.validatesDomainName) { + [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; + } else { + [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; + } + + SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); + + if (self.SSLPinningMode == AFSSLPinningModeNone) { + return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust); + } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { + return NO; + } + + switch (self.SSLPinningMode) { + case AFSSLPinningModeNone: + default: + return NO; + case AFSSLPinningModeCertificate: { + NSMutableArray *pinnedCertificates = [NSMutableArray array]; + for (NSData *certificateData in self.pinnedCertificates) { + [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; + } + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); + + if (!AFServerTrustIsValid(serverTrust)) { + return NO; + } + + // obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA) + NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); + + for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) { + if ([self.pinnedCertificates containsObject:trustChainCertificate]) { + return YES; + } + } + + return NO; + } + case AFSSLPinningModePublicKey: { + NSUInteger trustedPublicKeyCount = 0; + NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); + + for (id trustChainPublicKey in publicKeys) { + for (id pinnedPublicKey in self.pinnedPublicKeys) { + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { + trustedPublicKeyCount += 1; + } + } + } + return trustedPublicKeyCount > 0; + } + } + + return NO; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { + return [NSSet setWithObject:@"pinnedCertificates"]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + + self = [self init]; + if (!self) { + return nil; + } + + self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue]; + self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))]; + self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))]; + self.pinnedCertificates = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(pinnedCertificates))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:[NSNumber numberWithUnsignedInteger:self.SSLPinningMode] forKey:NSStringFromSelector(@selector(SSLPinningMode))]; + [coder encodeBool:self.allowInvalidCertificates forKey:NSStringFromSelector(@selector(allowInvalidCertificates))]; + [coder encodeBool:self.validatesDomainName forKey:NSStringFromSelector(@selector(validatesDomainName))]; + [coder encodeObject:self.pinnedCertificates forKey:NSStringFromSelector(@selector(pinnedCertificates))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init]; + securityPolicy.SSLPinningMode = self.SSLPinningMode; + securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates; + securityPolicy.validatesDomainName = self.validatesDomainName; + securityPolicy.pinnedCertificates = [self.pinnedCertificates copyWithZone:zone]; + + return securityPolicy; +} + +@end diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h new file mode 100644 index 0000000..134b7dd --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1,454 @@ +// AFURLRequestSerialization.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import +#import + +#if TARGET_OS_IOS || TARGET_OS_TV +#import +#elif TARGET_OS_WATCH +#import +#endif + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary. + + For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`. + */ +@protocol AFURLRequestSerialization + +/** + Returns a request with the specified parameters encoded into a copy of the original request. + + @param request The original request. + @param parameters The parameters to be encoded. + @param error The error that occurred while attempting to encode the request parameters. + + @return A serialized request. + */ +- (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(nullable id)parameters + error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW; + +@end + +#pragma mark - + +/** + + */ +typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) { + AFHTTPRequestQueryStringDefaultStyle = 0, +}; + +@protocol AFMultipartFormData; + +/** + `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPRequestSerializer : NSObject + +/** + The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Whether created requests can use the device’s cellular radio (if present). `YES` by default. + + @see NSMutableURLRequest -setAllowsCellularAccess: + */ +@property (nonatomic, assign) BOOL allowsCellularAccess; + +/** + The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default. + + @see NSMutableURLRequest -setCachePolicy: + */ +@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy; + +/** + Whether created requests should use the default cookie handling. `YES` by default. + + @see NSMutableURLRequest -setHTTPShouldHandleCookies: + */ +@property (nonatomic, assign) BOOL HTTPShouldHandleCookies; + +/** + Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default + + @see NSMutableURLRequest -setHTTPShouldUsePipelining: + */ +@property (nonatomic, assign) BOOL HTTPShouldUsePipelining; + +/** + The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default. + + @see NSMutableURLRequest -setNetworkServiceType: + */ +@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType; + +/** + The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds. + + @see NSMutableURLRequest -setTimeoutInterval: + */ +@property (nonatomic, assign) NSTimeInterval timeoutInterval; + +///--------------------------------------- +/// @name Configuring HTTP Request Headers +///--------------------------------------- + +/** + Default HTTP header field values to be applied to serialized requests. By default, these include the following: + + - `Accept-Language` with the contents of `NSLocale +preferredLanguages` + - `User-Agent` with the contents of various bundle identifiers and OS designations + + @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +/** + Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header. + + @param field The HTTP header to set a default value for + @param value The value set as default for the specified header, or `nil` + */ +- (void)setValue:(nullable NSString *)value +forHTTPHeaderField:(NSString *)field; + +/** + Returns the value for the HTTP headers set in the request serializer. + + @param field The HTTP header to retrieve the default value for + + @return The value set as default for the specified header, or `nil` + */ +- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field; + +/** + Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header. + + @param username The HTTP basic auth username + @param password The HTTP basic auth password + */ +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password; + +/** + Clears any existing value for the "Authorization" HTTP header. + */ +- (void)clearAuthorizationHeader; + +///------------------------------------------------------- +/// @name Configuring Query String Parameter Serialization +///------------------------------------------------------- + +/** + HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default. + */ +@property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI; + +/** + Set the method of query string serialization according to one of the pre-defined styles. + + @param style The serialization style. + + @see AFHTTPRequestQueryStringSerializationStyle + */ +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style; + +/** + Set the a custom method of query string serialization according to the specified block. + + @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request. + */ +- (void)setQueryStringSerializationWithBlock:(nullable NSString * (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block; + +///------------------------------- +/// @name Creating Request Objects +///------------------------------- + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string. + + If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body. + + @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable id)parameters + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 + + Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. + + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable NSDictionary *)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished. + + @param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`. + @param fileURL The file URL to write multipart form contents to. + @param handler A handler block to execute. + + @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request. + + @see https://github.com/AFNetworking/AFNetworking/issues/1398 + */ +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(nullable void (^)(NSError * _Nullable error))handler; + +@end + +#pragma mark - + +/** + The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`. + */ +@protocol AFMultipartFormData + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. + + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended, otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. + + @param inputStream The input stream to be appended to the form data + @param name The name to be associated with the specified input stream. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. + @param length The length of the specified input stream in bytes. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + */ + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name; + + +/** + Appends HTTP headers, followed by the encoded data and the multipart form boundary. + + @param headers The HTTP headers to be appended to the form data. + @param body The data to be encoded and appended to the form data. This parameter must not be `nil`. + */ +- (void)appendPartWithHeaders:(nullable NSDictionary *)headers + body:(NSData *)body; + +/** + Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. + + When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. + + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb. + @param delay Duration of delay each time a packet is read. By default, no delay is set. + */ +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay; + +@end + +#pragma mark - + +/** + `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`. + */ +@interface AFJSONRequestSerializer : AFHTTPRequestSerializer + +/** + Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONWritingOptions writingOptions; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param writingOptions The specified JSON writing options. + */ ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions; + +@end + +#pragma mark - + +/** + `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`. + */ +@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + @warning The `writeOptions` property is currently unused. + */ +@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param writeOptions The property list write options. + + @warning The `writeOptions` property is currently unused. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions; + +@end + +#pragma mark - + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLRequestSerializationErrorDomain` + + ### Constants + + `AFURLRequestSerializationErrorDomain` + AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLRequestErrorKey` + The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey; + +/** + ## Throttling Bandwidth for HTTP Request Input Streams + + @see -throttleBandwidthWithPacketSize:delay: + + ### Constants + + `kAFUploadStream3GSuggestedPacketSize` + Maximum packet size, in number of bytes. Equal to 16kb. + + `kAFUploadStream3GSuggestedDelay` + Duration of delay each time a packet is read. Equal to 0.2 seconds. + */ +FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize; +FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay; + +NS_ASSUME_NONNULL_END diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m new file mode 100644 index 0000000..bbab7c4 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m @@ -0,0 +1,1376 @@ +// AFURLRequestSerialization.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "AFURLRequestSerialization.h" + +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV +#import +#else +#import +#endif + +NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request"; +NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response"; + +typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error); + +/** + Returns a percent-escaped string following RFC 3986 for a query string key or value. + RFC 3986 states that the following characters are "reserved" characters. + - General Delimiters: ":", "#", "[", "]", "@", "?", "/" + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" + + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" + should be percent-escaped in the query string. + - parameter string: The string to be percent-escaped. + - returns: The percent-escaped string. + */ +static NSString * AFPercentEscapedStringFromString(NSString *string) { + static NSString * const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4 + static NSString * const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;="; + + NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; + [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]]; + + // FIXME: https://github.com/AFNetworking/AFNetworking/pull/3028 + // return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + + static NSUInteger const batchSize = 50; + + NSUInteger index = 0; + NSMutableString *escaped = @"".mutableCopy; + + while (index < string.length) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wgnu" + NSUInteger length = MIN(string.length - index, batchSize); +#pragma GCC diagnostic pop + NSRange range = NSMakeRange(index, length); + + // To avoid breaking up character sequences such as 👴🏻👮🏽 + range = [string rangeOfComposedCharacterSequencesForRange:range]; + + NSString *substring = [string substringWithRange:range]; + NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + [escaped appendString:encoded]; + + index += range.length; + } + + return escaped; +} + +#pragma mark - + +@interface AFQueryStringPair : NSObject +@property (readwrite, nonatomic, strong) id field; +@property (readwrite, nonatomic, strong) id value; + +- (instancetype)initWithField:(id)field value:(id)value; + +- (NSString *)URLEncodedStringValue; +@end + +@implementation AFQueryStringPair + +- (instancetype)initWithField:(id)field value:(id)value { + self = [super init]; + if (!self) { + return nil; + } + + self.field = field; + self.value = value; + + return self; +} + +- (NSString *)URLEncodedStringValue { + if (!self.value || [self.value isEqual:[NSNull null]]) { + return AFPercentEscapedStringFromString([self.field description]); + } else { + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedStringFromString([self.field description]), AFPercentEscapedStringFromString([self.value description])]; + } +} + +@end + +#pragma mark - + +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary); +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value); + +static NSString * AFQueryStringFromParameters(NSDictionary *parameters) { + NSMutableArray *mutablePairs = [NSMutableArray array]; + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + [mutablePairs addObject:[pair URLEncodedStringValue]]; + } + + return [mutablePairs componentsJoinedByString:@"&"]; +} + +NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) { + return AFQueryStringPairsFromKeyAndValue(nil, dictionary); +} + +NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; + + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)]; + + if ([value isKindOfClass:[NSDictionary class]]) { + NSDictionary *dictionary = value; + // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = dictionary[nestedKey]; + if (nestedValue) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; + } + } + } else if ([value isKindOfClass:[NSArray class]]) { + NSArray *array = value; + for (id nestedValue in array) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; + } + } else if ([value isKindOfClass:[NSSet class]]) { + NSSet *set = value; + for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; + } + } else { + [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; + } + + return mutableQueryStringComponents; +} + +#pragma mark - + +@interface AFStreamingMultipartFormData : NSObject +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding; + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; +@end + +#pragma mark - + +static NSArray * AFHTTPRequestSerializerObservedKeyPaths() { + static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _AFHTTPRequestSerializerObservedKeyPaths = @[NSStringFromSelector(@selector(allowsCellularAccess)), NSStringFromSelector(@selector(cachePolicy)), NSStringFromSelector(@selector(HTTPShouldHandleCookies)), NSStringFromSelector(@selector(HTTPShouldUsePipelining)), NSStringFromSelector(@selector(networkServiceType)), NSStringFromSelector(@selector(timeoutInterval))]; + }); + + return _AFHTTPRequestSerializerObservedKeyPaths; +} + +static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerObserverContext; + +@interface AFHTTPRequestSerializer () +@property (readwrite, nonatomic, strong) NSMutableSet *mutableObservedChangedKeyPaths; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders; +@property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle; +@property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization; +@end + +@implementation AFHTTPRequestSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary]; + + // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 + NSMutableArray *acceptLanguagesComponents = [NSMutableArray array]; + [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + float q = 1.0f - (idx * 0.1f); + [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; + *stop = q <= 0.5f; + }]; + [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"]; + + NSString *userAgent = nil; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" +#if TARGET_OS_IOS + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif TARGET_OS_WATCH + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]]; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; +#endif +#pragma clang diagnostic pop + if (userAgent) { + if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) { + NSMutableString *mutableUserAgent = [userAgent mutableCopy]; + if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) { + userAgent = mutableUserAgent; + } + } + [self setValue:userAgent forHTTPHeaderField:@"User-Agent"]; + } + + // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html + self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil]; + + self.mutableObservedChangedKeyPaths = [NSMutableSet set]; + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext]; + } + } + + return self; +} + +- (void)dealloc { + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self removeObserver:self forKeyPath:keyPath context:AFHTTPRequestSerializerObserverContext]; + } + } +} + +#pragma mark - + +// Workarounds for crashing behavior using Key-Value Observing with XCTest +// See https://github.com/AFNetworking/AFNetworking/issues/2523 + +- (void)setAllowsCellularAccess:(BOOL)allowsCellularAccess { + [self willChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; + _allowsCellularAccess = allowsCellularAccess; + [self didChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; +} + +- (void)setCachePolicy:(NSURLRequestCachePolicy)cachePolicy { + [self willChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; + _cachePolicy = cachePolicy; + [self didChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; +} + +- (void)setHTTPShouldHandleCookies:(BOOL)HTTPShouldHandleCookies { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; + _HTTPShouldHandleCookies = HTTPShouldHandleCookies; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; +} + +- (void)setHTTPShouldUsePipelining:(BOOL)HTTPShouldUsePipelining { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; + _HTTPShouldUsePipelining = HTTPShouldUsePipelining; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; +} + +- (void)setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType { + [self willChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; + _networkServiceType = networkServiceType; + [self didChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; +} + +- (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval { + [self willChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; + _timeoutInterval = timeoutInterval; + [self didChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; +} + +#pragma mark - + +- (NSDictionary *)HTTPRequestHeaders { + return [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders]; +} + +- (void)setValue:(NSString *)value +forHTTPHeaderField:(NSString *)field +{ + [self.mutableHTTPRequestHeaders setValue:value forKey:field]; +} + +- (NSString *)valueForHTTPHeaderField:(NSString *)field { + return [self.mutableHTTPRequestHeaders valueForKey:field]; +} + +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password +{ + NSData *basicAuthCredentials = [[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding]; + NSString *base64AuthCredentials = [basicAuthCredentials base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0]; + [self setValue:[NSString stringWithFormat:@"Basic %@", base64AuthCredentials] forHTTPHeaderField:@"Authorization"]; +} + +- (void)clearAuthorizationHeader { + [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; +} + +#pragma mark - + +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style { + self.queryStringSerializationStyle = style; + self.queryStringSerialization = nil; +} + +- (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, id, NSError *__autoreleasing *))block { + self.queryStringSerialization = block; +} + +#pragma mark - + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(URLString); + + NSURL *url = [NSURL URLWithString:URLString]; + + NSParameterAssert(url); + + NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url]; + mutableRequest.HTTPMethod = method; + + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) { + [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath]; + } + } + + mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy]; + + return mutableRequest; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); + + NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error]; + + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding]; + + if (parameters) { + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + NSData *data = nil; + if ([pair.value isKindOfClass:[NSData class]]) { + data = pair.value; + } else if ([pair.value isEqual:[NSNull null]]) { + data = [NSData data]; + } else { + data = [[pair.value description] dataUsingEncoding:self.stringEncoding]; + } + + if (data) { + [formData appendPartWithFormData:data name:[pair.field description]]; + } + } + } + + if (block) { + block(formData); + } + + return [formData requestByFinalizingMultipartFormData]; +} + +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(void (^)(NSError *error))handler +{ + NSParameterAssert(request.HTTPBodyStream); + NSParameterAssert([fileURL isFileURL]); + + NSInputStream *inputStream = request.HTTPBodyStream; + NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO]; + __block NSError *error = nil; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + [inputStream open]; + [outputStream open]; + + while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) { + uint8_t buffer[1024]; + + NSInteger bytesRead = [inputStream read:buffer maxLength:1024]; + if (inputStream.streamError || bytesRead < 0) { + error = inputStream.streamError; + break; + } + + NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead]; + if (outputStream.streamError || bytesWritten < 0) { + error = outputStream.streamError; + break; + } + + if (bytesRead == 0 && bytesWritten == 0) { + break; + } + } + + [outputStream close]; + [inputStream close]; + + if (handler) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler(error); + }); + } + }); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + mutableRequest.HTTPBodyStream = nil; + + return mutableRequest; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + NSString *query = nil; + if (parameters) { + if (self.queryStringSerialization) { + NSError *serializationError; + query = self.queryStringSerialization(request, parameters, &serializationError); + + if (serializationError) { + if (error) { + *error = serializationError; + } + + return nil; + } + } else { + switch (self.queryStringSerializationStyle) { + case AFHTTPRequestQueryStringDefaultStyle: + query = AFQueryStringFromParameters(parameters); + break; + } + } + } + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + if (query) { + mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]]; + } + } else { + // #2864: an empty string is a valid x-www-form-urlencoded payload + if (!query) { + query = @""; + } + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; + } + [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]]; + } + + return mutableRequest; +} + +#pragma mark - NSKeyValueObserving + ++ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key { + if ([AFHTTPRequestSerializerObservedKeyPaths() containsObject:key]) { + return NO; + } + + return [super automaticallyNotifiesObserversForKey:key]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(__unused id)object + change:(NSDictionary *)change + context:(void *)context +{ + if (context == AFHTTPRequestSerializerObserverContext) { + if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) { + [self.mutableObservedChangedKeyPaths removeObject:keyPath]; + } else { + [self.mutableObservedChangedKeyPaths addObject:keyPath]; + } + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy]; + self.queryStringSerializationStyle = (AFHTTPRequestQueryStringSerializationStyle)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))]; + [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone]; + serializer.queryStringSerializationStyle = self.queryStringSerializationStyle; + serializer.queryStringSerialization = self.queryStringSerialization; + + return serializer; +} + +@end + +#pragma mark - + +static NSString * AFCreateMultipartFormBoundary() { + return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; +} + +static NSString * const kAFMultipartFormCRLF = @"\r\n"; + +static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFContentTypeForPathExtension(NSString *extension) { + NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + if (!contentType) { + return @"application/octet-stream"; + } else { + return contentType; + } +} + +NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16; +NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; + +@interface AFHTTPBodyPart : NSObject +@property (nonatomic, assign) NSStringEncoding stringEncoding; +@property (nonatomic, strong) NSDictionary *headers; +@property (nonatomic, copy) NSString *boundary; +@property (nonatomic, strong) id body; +@property (nonatomic, assign) unsigned long long bodyContentLength; +@property (nonatomic, strong) NSInputStream *inputStream; + +@property (nonatomic, assign) BOOL hasInitialBoundary; +@property (nonatomic, assign) BOOL hasFinalBoundary; + +@property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (readonly, nonatomic, assign) unsigned long long contentLength; + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@interface AFMultipartBodyStream : NSInputStream +@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; +@property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, strong) NSInputStream *inputStream; +@property (readonly, nonatomic, assign) unsigned long long contentLength; +@property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty; + +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding; +- (void)setInitialAndFinalBoundaries; +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; +@end + +#pragma mark - + +@interface AFStreamingMultipartFormData () +@property (readwrite, nonatomic, copy) NSMutableURLRequest *request; +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, copy) NSString *boundary; +@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream; +@end + +@implementation AFStreamingMultipartFormData + +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding +{ + self = [super init]; + if (!self) { + return nil; + } + + self.request = urlRequest; + self.stringEncoding = encoding; + self.boundary = AFCreateMultipartFormBoundary(); + self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; + + return self; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + + NSString *fileName = [fileURL lastPathComponent]; + NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); + + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + if (![fileURL isFileURL]) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } + + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error]; + if (!fileAttributes) { + return NO; + } + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = fileURL; + bodyPart.bodyContentLength = [fileAttributes[NSFileSize] unsignedLongLongValue]; + [self.bodyStream appendHTTPBodyPart:bodyPart]; + + return YES; +} + +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = (unsigned long long)length; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name +{ + NSParameterAssert(name); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithHeaders:(NSDictionary *)headers + body:(NSData *)body +{ + NSParameterAssert(body); + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = headers; + bodyPart.boundary = self.boundary; + bodyPart.bodyContentLength = [body length]; + bodyPart.body = body; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay +{ + self.bodyStream.numberOfBytesInPacket = numberOfBytes; + self.bodyStream.delay = delay; +} + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData { + if ([self.bodyStream isEmpty]) { + return self.request; + } + + // Reset the initial and final boundaries to ensure correct Content-Length + [self.bodyStream setInitialAndFinalBoundaries]; + [self.request setHTTPBodyStream:self.bodyStream]; + + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"]; + [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; + + return self.request; +} + +@end + +#pragma mark - + +@interface NSStream () +@property (readwrite) NSStreamStatus streamStatus; +@property (readwrite, copy) NSError *streamError; +@end + +@interface AFMultipartBodyStream () +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts; +@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; +@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; +@property (readwrite, nonatomic, strong) NSOutputStream *outputStream; +@property (readwrite, nonatomic, strong) NSMutableData *buffer; +@end + +@implementation AFMultipartBodyStream +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-atomic-properties" +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100) +@synthesize delegate; +#endif +@synthesize streamStatus; +@synthesize streamError; +#pragma clang diagnostic pop + +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = encoding; + self.HTTPBodyParts = [NSMutableArray array]; + self.numberOfBytesInPacket = NSIntegerMax; + + return self; +} + +- (void)setInitialAndFinalBoundaries { + if ([self.HTTPBodyParts count] > 0) { + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + bodyPart.hasInitialBoundary = NO; + bodyPart.hasFinalBoundary = NO; + } + + [[self.HTTPBodyParts firstObject] setHasInitialBoundary:YES]; + [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; + } +} + +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { + [self.HTTPBodyParts addObject:bodyPart]; +} + +- (BOOL)isEmpty { + return [self.HTTPBodyParts count] == 0; +} + +#pragma mark - NSInputStream + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + if ([self streamStatus] == NSStreamStatusClosed) { + return 0; + } + + NSInteger totalNumberOfBytesRead = 0; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) { + if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { + if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { + break; + } + } else { + NSUInteger maxLength = MIN(length, self.numberOfBytesInPacket) - (NSUInteger)totalNumberOfBytesRead; + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength]; + if (numberOfBytesRead == -1) { + self.streamError = self.currentHTTPBodyPart.inputStream.streamError; + break; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if (self.delay > 0.0f) { + [NSThread sleepForTimeInterval:self.delay]; + } + } + } + } +#pragma clang diagnostic pop + + return totalNumberOfBytesRead; +} + +- (BOOL)getBuffer:(__unused uint8_t **)buffer + length:(__unused NSUInteger *)len +{ + return NO; +} + +- (BOOL)hasBytesAvailable { + return [self streamStatus] == NSStreamStatusOpen; +} + +#pragma mark - NSStream + +- (void)open { + if (self.streamStatus == NSStreamStatusOpen) { + return; + } + + self.streamStatus = NSStreamStatusOpen; + + [self setInitialAndFinalBoundaries]; + self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; +} + +- (void)close { + self.streamStatus = NSStreamStatusClosed; +} + +- (id)propertyForKey:(__unused NSString *)key { + return nil; +} + +- (BOOL)setProperty:(__unused id)property + forKey:(__unused NSString *)key +{ + return NO; +} + +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + length += [bodyPart contentLength]; + } + + return length; +} + +#pragma mark - Undocumented CFReadStream Bridged Methods + +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags + callback:(__unused CFReadStreamClientCallBack)inCallback + context:(__unused CFStreamClientContext *)inContext { + return NO; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; + } + + [bodyStreamCopy setInitialAndFinalBoundaries]; + + return bodyStreamCopy; +} + +@end + +#pragma mark - + +typedef enum { + AFEncapsulationBoundaryPhase = 1, + AFHeaderPhase = 2, + AFBodyPhase = 3, + AFFinalBoundaryPhase = 4, +} AFHTTPBodyPartReadPhase; + +@interface AFHTTPBodyPart () { + AFHTTPBodyPartReadPhase _phase; + NSInputStream *_inputStream; + unsigned long long _phaseReadOffset; +} + +- (BOOL)transitionToNextPhase; +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@implementation AFHTTPBodyPart + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + [self transitionToNextPhase]; + + return self; +} + +- (void)dealloc { + if (_inputStream) { + [_inputStream close]; + _inputStream = nil; + } +} + +- (NSInputStream *)inputStream { + if (!_inputStream) { + if ([self.body isKindOfClass:[NSData class]]) { + _inputStream = [NSInputStream inputStreamWithData:self.body]; + } else if ([self.body isKindOfClass:[NSURL class]]) { + _inputStream = [NSInputStream inputStreamWithURL:self.body]; + } else if ([self.body isKindOfClass:[NSInputStream class]]) { + _inputStream = self.body; + } else { + _inputStream = [NSInputStream inputStreamWithData:[NSData data]]; + } + } + + return _inputStream; +} + +- (NSString *)stringForHeaders { + NSMutableString *headerString = [NSMutableString string]; + for (NSString *field in [self.headers allKeys]) { + [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]]; + } + [headerString appendString:kAFMultipartFormCRLF]; + + return [NSString stringWithString:headerString]; +} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + length += [encapsulationBoundaryData length]; + + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + length += [headersData length]; + + length += _bodyContentLength; + + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + length += [closingBoundaryData length]; + + return length; +} + +- (BOOL)hasBytesAvailable { + // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer + if (_phase == AFFinalBoundaryPhase) { + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (self.inputStream.streamStatus) { + case NSStreamStatusNotOpen: + case NSStreamStatusOpening: + case NSStreamStatusOpen: + case NSStreamStatusReading: + case NSStreamStatusWriting: + return YES; + case NSStreamStatusAtEnd: + case NSStreamStatusClosed: + case NSStreamStatusError: + default: + return NO; + } +#pragma clang diagnostic pop +} + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + NSInteger totalNumberOfBytesRead = 0; + + if (_phase == AFEncapsulationBoundaryPhase) { + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFHeaderPhase) { + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFBodyPhase) { + NSInteger numberOfBytesRead = 0; + + numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + if (numberOfBytesRead == -1) { + return -1; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) { + [self transitionToNextPhase]; + } + } + } + + if (_phase == AFFinalBoundaryPhase) { + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + return totalNumberOfBytesRead; +} + +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); + [data getBytes:buffer range:range]; +#pragma clang diagnostic pop + + _phaseReadOffset += range.length; + + if (((NSUInteger)_phaseReadOffset) >= [data length]) { + [self transitionToNextPhase]; + } + + return (NSInteger)range.length; +} + +- (BOOL)transitionToNextPhase { + if (![[NSThread currentThread] isMainThread]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self transitionToNextPhase]; + }); + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (_phase) { + case AFEncapsulationBoundaryPhase: + _phase = AFHeaderPhase; + break; + case AFHeaderPhase: + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; + [self.inputStream open]; + _phase = AFBodyPhase; + break; + case AFBodyPhase: + [self.inputStream close]; + _phase = AFFinalBoundaryPhase; + break; + case AFFinalBoundaryPhase: + default: + _phase = AFEncapsulationBoundaryPhase; + break; + } + _phaseReadOffset = 0; +#pragma clang diagnostic pop + + return YES; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; + + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = self.headers; + bodyPart.bodyContentLength = self.bodyContentLength; + bodyPart.body = self.body; + bodyPart.boundary = self.boundary; + + return bodyPart; +} + +@end + +#pragma mark - + +@implementation AFJSONRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithWritingOptions:(NSJSONWritingOptions)0]; +} + ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions +{ + AFJSONRequestSerializer *serializer = [[self alloc] init]; + serializer.writingOptions = writingOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFJSONRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.writingOptions = self.writingOptions; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFPropertyListRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions +{ + AFPropertyListRequestSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.writeOptions = writeOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerializer + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-plist" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.format = self.format; + serializer.writeOptions = self.writeOptions; + + return serializer; +} + +@end diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h new file mode 100644 index 0000000..f9e14c6 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1,311 @@ +// AFURLResponseSerialization.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. + + For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object. + */ +@protocol AFURLResponseSerialization + +/** + The response object decoded from the data associated with a specified response. + + @param response The response to be processed. + @param data The response data to be decoded. + @param error The error that occurred while attempting to decode the response data. + + @return The object decoded from the specified response data. + */ +- (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response + data:(nullable NSData *)data + error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW; + +@end + +#pragma mark - + +/** + `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPResponseSerializer : NSObject + +- (instancetype)init; + +/** + The string encoding used to serialize data received from the server, when no string encoding is specified by the response. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +///----------------------------------------- +/// @name Configuring Response Serialization +///----------------------------------------- + +/** + The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation. + + See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + */ +@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes; + +/** + The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation. + */ +@property (nonatomic, copy, nullable) NSSet *acceptableContentTypes; + +/** + Validates the specified response and data. + + In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. + + @param response The response to be validated. + @param data The data associated with the response. + @param error The error that occurred while attempting to validate the response. + + @return `YES` if the response is valid, otherwise `NO`. + */ +- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response + data:(nullable NSData *)data + error:(NSError * _Nullable __autoreleasing *)error; + +@end + +#pragma mark - + + +/** + `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. + + By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: + + - `application/json` + - `text/json` + - `text/javascript` + */ +@interface AFJSONResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONReadingOptions readingOptions; + +/** + Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL removesKeysWithNullValues; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param readingOptions The specified JSON reading options. + */ ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; + +@end + +#pragma mark - + +/** + `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. + + By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +/** + `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSUInteger options; + +/** + Creates and returns an XML document serializer with the specified options. + + @param mask The XML document options. + */ ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; + +@end + +#endif + +#pragma mark - + +/** + `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFPropertyListResponseSerializer` accepts the following MIME types: + + - `application/x-plist` + */ +@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." + */ +@property (nonatomic, assign) NSPropertyListReadOptions readOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param readOptions The property list reading options. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions; + +@end + +#pragma mark - + +/** + `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. + + By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: + + - `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` + */ +@interface AFImageResponseSerializer : AFHTTPResponseSerializer + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH +/** + The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. + */ +@property (nonatomic, assign) CGFloat imageScale; + +/** + Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. + */ +@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; +#endif + +@end + +#pragma mark - + +/** + `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer. + */ +@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer + +/** + The component response serializers. + */ +@property (readonly, nonatomic, copy) NSArray > *responseSerializers; + +/** + Creates and returns a compound serializer comprised of the specified response serializers. + + @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. + */ ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray > *)responseSerializers; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLResponseSerializationErrorDomain` + + ### Constants + + `AFURLResponseSerializationErrorDomain` + AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` + - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLResponseErrorKey` + The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + + `AFNetworkingOperationFailingURLResponseDataErrorKey` + The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey; + +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey; + +NS_ASSUME_NONNULL_END diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m new file mode 100755 index 0000000..ef5e334 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m @@ -0,0 +1,828 @@ +// AFURLResponseSerialization.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "AFURLResponseSerialization.h" + +#import + +#if TARGET_OS_IOS +#import +#elif TARGET_OS_WATCH +#import +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#import +#endif + +NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response"; +NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response"; +NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data"; + +static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) { + if (!error) { + return underlyingError; + } + + if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) { + return error; + } + + NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy]; + mutableUserInfo[NSUnderlyingErrorKey] = underlyingError; + + return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo]; +} + +static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) { + if ([error.domain isEqualToString:domain] && error.code == code) { + return YES; + } else if (error.userInfo[NSUnderlyingErrorKey]) { + return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain); + } + + return NO; +} + +static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { + if ([JSONObject isKindOfClass:[NSArray class]]) { + NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]]; + for (id value in (NSArray *)JSONObject) { + [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray]; + } else if ([JSONObject isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject]; + for (id key in [(NSDictionary *)JSONObject allKeys]) { + id value = (NSDictionary *)JSONObject[key]; + if (!value || [value isEqual:[NSNull null]]) { + [mutableDictionary removeObjectForKey:key]; + } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) { + mutableDictionary[key] = AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions); + } + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary]; + } + + return JSONObject; +} + +@implementation AFHTTPResponseSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; + self.acceptableContentTypes = nil; + + return self; +} + +#pragma mark - + +- (BOOL)validateResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError * __autoreleasing *)error +{ + BOOL responseIsValid = YES; + NSError *validationError = nil; + + if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) { + if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]]) { + if ([data length] > 0 && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError); + } + + responseIsValid = NO; + } + + if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError); + + responseIsValid = NO; + } + } + + if (error && !responseIsValid) { + *error = validationError; + } + + return responseIsValid; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + [self validateResponse:(NSHTTPURLResponse *)response data:data error:error]; + + return data; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone]; + serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone]; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFJSONResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithReadingOptions:(NSJSONReadingOptions)0]; +} + ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions { + AFJSONResponseSerializer *serializer = [[self alloc] init]; + serializer.readingOptions = readingOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. + // See https://github.com/rails/rails/issues/1742 + NSStringEncoding stringEncoding = self.stringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + id responseObject = nil; + NSError *serializationError = nil; + @autoreleasepool { + NSString *responseString = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (responseString && ![responseString isEqualToString:@" "]) { + // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character + // See http://stackoverflow.com/a/12843465/157142 + data = [responseString dataUsingEncoding:NSUTF8StringEncoding]; + + if (data) { + if ([data length] > 0) { + responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError]; + } else { + return nil; + } + } else { + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"Data failed decoding as a UTF-8 string", @"AFNetworking", nil), + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Could not decode string: %@", @"AFNetworking", nil), responseString] + }; + + serializationError = [NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; + } + } + } + + if (self.removesKeysWithNullValues && responseObject) { + responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions); + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue]; + self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))]; + [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.readingOptions = self.readingOptions; + serializer.removesKeysWithNullValues = self.removesKeysWithNullValues; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFXMLParserResponseSerializer + ++ (instancetype)serializer { + AFXMLParserResponseSerializer *serializer = [[self alloc] init]; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + return [[NSXMLParser alloc] initWithData:data]; +} + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +@implementation AFXMLDocumentResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithXMLDocumentOptions:0]; +} + ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask { + AFXMLDocumentResponseSerializer *serializer = [[self alloc] init]; + serializer.options = mask; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + NSError *serializationError = nil; + NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError]; + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return document; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.options = self.options; + + return serializer; +} + +@end + +#endif + +#pragma mark - + +@implementation AFPropertyListResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions +{ + AFPropertyListResponseSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.readOptions = readOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + id responseObject; + NSError *serializationError = nil; + + if (data) { + responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError]; + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.format = self.format; + serializer.readOptions = self.readOptions; + + return serializer; +} + +@end + +#pragma mark - + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH +#import +#import + +@interface UIImage (AFNetworkingSafeImageLoading) ++ (UIImage *)af_safeImageWithData:(NSData *)data; +@end + +static NSLock* imageLock = nil; + +@implementation UIImage (AFNetworkingSafeImageLoading) + ++ (UIImage *)af_safeImageWithData:(NSData *)data { + UIImage* image = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + imageLock = [[NSLock alloc] init]; + }); + + [imageLock lock]; + image = [UIImage imageWithData:data]; + [imageLock unlock]; + return image; +} + +@end + +static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) { + UIImage *image = [UIImage af_safeImageWithData:data]; + if (image.images) { + return image; + } + + return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation]; +} + +static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) { + if (!data || [data length] == 0) { + return nil; + } + + CGImageRef imageRef = NULL; + CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data); + + if ([response.MIMEType isEqualToString:@"image/png"]) { + imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) { + imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + + if (imageRef) { + CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef); + CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace); + + // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale + if (imageColorSpaceModel == kCGColorSpaceModelCMYK) { + CGImageRelease(imageRef); + imageRef = NULL; + } + } + } + + CGDataProviderRelease(dataProvider); + + UIImage *image = AFImageWithDataAtScale(data, scale); + if (!imageRef) { + if (image.images || !image) { + return image; + } + + imageRef = CGImageCreateCopy([image CGImage]); + if (!imageRef) { + return nil; + } + } + + size_t width = CGImageGetWidth(imageRef); + size_t height = CGImageGetHeight(imageRef); + size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef); + + if (width * height > 1024 * 1024 || bitsPerComponent > 8) { + CGImageRelease(imageRef); + + return image; + } + + // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate + size_t bytesPerRow = 0; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace); + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + + if (colorSpaceModel == kCGColorSpaceModelRGB) { + uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wassign-enum" + if (alpha == kCGImageAlphaNone) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaNoneSkipFirst; + } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaPremultipliedFirst; + } +#pragma clang diagnostic pop + } + + CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo); + + CGColorSpaceRelease(colorSpace); + + if (!context) { + CGImageRelease(imageRef); + + return image; + } + + CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef); + CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context); + + CGContextRelease(context); + + UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation]; + + CGImageRelease(inflatedImageRef); + CGImageRelease(imageRef); + + return inflatedImage; +} +#endif + + +@implementation AFImageResponseSerializer + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"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", nil]; + +#if TARGET_OS_IOS || TARGET_OS_TV + self.imageScale = [[UIScreen mainScreen] scale]; + self.automaticallyInflatesResponseImage = YES; +#elif TARGET_OS_WATCH + self.imageScale = [[WKInterfaceDevice currentDevice] screenScale]; + self.automaticallyInflatesResponseImage = YES; +#endif + + return self; +} + +#pragma mark - AFURLResponseSerializer + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + if (self.automaticallyInflatesResponseImage) { + return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale); + } else { + return AFImageWithDataAtScale(data, self.imageScale); + } +#else + // Ensure that the image is set to it's correct pixel width and height + NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data]; + NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; + [image addRepresentation:bitimage]; + + return image; +#endif + + return nil; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))]; +#if CGFLOAT_IS_DOUBLE + self.imageScale = [imageScale doubleValue]; +#else + self.imageScale = [imageScale floatValue]; +#endif + + self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))]; + [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + serializer.imageScale = self.imageScale; + serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage; +#endif + + return serializer; +} + +@end + +#pragma mark - + +@interface AFCompoundResponseSerializer () +@property (readwrite, nonatomic, copy) NSArray *responseSerializers; +@end + +@implementation AFCompoundResponseSerializer + ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers { + AFCompoundResponseSerializer *serializer = [[self alloc] init]; + serializer.responseSerializers = responseSerializers; + + return serializer; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + for (id serializer in self.responseSerializers) { + if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) { + continue; + } + + NSError *serializerError = nil; + id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError]; + if (responseObject) { + if (error) { + *error = AFErrorWithUnderlyingError(serializerError, *error); + } + + return responseObject; + } + } + + return [super responseObjectForResponse:response data:data error:error]; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.responseSerializers = self.responseSerializers; + + return serializer; +} + +@end diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h new file mode 100644 index 0000000..be91828 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h @@ -0,0 +1,499 @@ +// AFURLSessionManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + + +#import + +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#if !TARGET_OS_WATCH +#import "AFNetworkReachabilityManager.h" +#endif + +/** + `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + + ## Subclassing Notes + + This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead. + + ## NSURLSession & NSURLSessionTask Delegate Methods + + `AFURLSessionManager` implements the following delegate methods: + + ### `NSURLSessionDelegate` + + - `URLSession:didBecomeInvalidWithError:` + - `URLSession:didReceiveChallenge:completionHandler:` + - `URLSessionDidFinishEventsForBackgroundURLSession:` + + ### `NSURLSessionTaskDelegate` + + - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:` + - `URLSession:task:didReceiveChallenge:completionHandler:` + - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` + - `URLSession:task:didCompleteWithError:` + + ### `NSURLSessionDataDelegate` + + - `URLSession:dataTask:didReceiveResponse:completionHandler:` + - `URLSession:dataTask:didBecomeDownloadTask:` + - `URLSession:dataTask:didReceiveData:` + - `URLSession:dataTask:willCacheResponse:completionHandler:` + + ### `NSURLSessionDownloadDelegate` + + - `URLSession:downloadTask:didFinishDownloadingToURL:` + - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:` + - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Network Reachability Monitoring + + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. + + ## NSCoding Caveats + + - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`. + + ## NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original. + - Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFURLSessionManager : NSObject + +/** + The managed session. + */ +@property (readonly, nonatomic, strong) NSURLSession *session; + +/** + The operation queue on which delegate callbacks are run. + */ +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) id responseSerializer; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +#if !TARGET_OS_WATCH +///-------------------------------------- +/// @name Monitoring Network Reachability +///-------------------------------------- + +/** + The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; +#endif + +///---------------------------- +/// @name Getting Session Tasks +///---------------------------- + +/** + The data, upload, and download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *tasks; + +/** + The data tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *dataTasks; + +/** + The upload tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *uploadTasks; + +/** + The download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *downloadTasks; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue; + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup; + +///--------------------------------- +/// @name Working Around System Bugs +///--------------------------------- + +/** + Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default. + + @bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again. + + @see https://github.com/AFNetworking/AFNetworking/issues/1675 + */ +@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a manager for a session created with the specified configuration. This is the designated initializer. + + @param configuration The configuration used to create the managed session. + + @return A manager for a newly-created session. + */ +- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +/** + Invalidates the managed session, optionally canceling pending tasks. + + @param cancelPendingTasks Whether or not to cancel pending tasks. + */ +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks; + +///------------------------- +/// @name Running Data Tasks +///------------------------- + +/** + Creates an `NSURLSessionDataTask` with the specified request. + + @param request The HTTP request for the request. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionDataTask` with the specified request. + + @param request The HTTP request for the request. + @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +///--------------------------- +/// @name Running Upload Tasks +///--------------------------- + +/** + Creates an `NSURLSessionUploadTask` with the specified request for a local file. + + @param request The HTTP request for the request. + @param fileURL A URL to the local file to be uploaded. + @param progress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + + @see `attemptsToRecreateUploadTasksForBackgroundSessions` + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body. + + @param request The HTTP request for the request. + @param bodyData A data object containing the HTTP body to be uploaded. + @param progress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(nullable NSData *)bodyData + progress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified streaming request. + + @param request The HTTP request for the request. + @param progress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +///----------------------------- +/// @name Running Download Tasks +///----------------------------- + +/** + Creates an `NSURLSessionDownloadTask` with the specified request. + + @param request The HTTP request for the request. + @param progress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + + @warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionDownloadTask` with the specified resume data. + + @param resumeData The data used to resume downloading. + @param progress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler; + +///--------------------------------- +/// @name Getting Progress for Tasks +///--------------------------------- + +/** + Returns the upload progress of the specified task. + + @param task The session task. Must not be `nil`. + + @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task; + +/** + Returns the download progress of the specified task. + + @param task The session task. Must not be `nil`. + + @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task; + +///----------------------------------------- +/// @name Setting Session Delegate Callbacks +///----------------------------------------- + +/** + Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`. + + @param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation. + */ +- (void)setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block; + +/** + Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block; + +///-------------------------------------- +/// @name Setting Task Delegate Callbacks +///-------------------------------------- + +/** + Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`. + + @param block A block object to be executed when a task requires a new request body stream. + */ +- (void)setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block; + +/** + Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`. + + @param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response. + */ +- (void)setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block; + +/** + Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a session task has received a request specific authentication challenge. The block returns the disposition of the authentication challenge, and takes four arguments: the session, the task, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block; + +/** + Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`. + + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block; + +/** + Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`. + + @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task. + */ +- (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * _Nullable error))block; + +///------------------------------------------- +/// @name Setting Data Task Delegate Callbacks +///------------------------------------------- + +/** + Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`. + + @param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response. + */ +- (void)setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block; + +/** + Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`. + + @param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become. + */ +- (void)setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block; + +/** + Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block; + +/** + Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`. + + @param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response. + */ +- (void)setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block; + +/** + Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`. + + @param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session. + */ +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block; + +///----------------------------------------------- +/// @name Setting Download Task Delegate Callbacks +///----------------------------------------------- + +/** + Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`. + + @param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error. + */ +- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block; + +/** + Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block; + +/** + Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`. + + @param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded. + */ +- (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block; + +@end + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when a task resumes. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification; + +/** + Posted when a task suspends its execution. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification; + +/** + Posted when a session is invalidated. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification; + +/** + Posted when a session download task encountered an error when moving the temporary download file to a specified destination. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if response data exists for the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the response was serialized. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the task has an associated response serializer. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an the response data has been stored directly to disk. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an error exists. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey; + +NS_ASSUME_NONNULL_END diff --git a/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m new file mode 100644 index 0000000..de447ae --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m @@ -0,0 +1,1244 @@ +// AFURLSessionManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "AFURLSessionManager.h" +#import + +#ifndef NSFoundationVersionNumber_iOS_8_0 +#define NSFoundationVersionNumber_With_Fixed_5871104061079552_bug 1140.11 +#else +#define NSFoundationVersionNumber_With_Fixed_5871104061079552_bug NSFoundationVersionNumber_iOS_8_0 +#endif + +static dispatch_queue_t url_session_manager_creation_queue() { + static dispatch_queue_t af_url_session_manager_creation_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_creation_queue = dispatch_queue_create("com.alamofire.networking.session.manager.creation", DISPATCH_QUEUE_SERIAL); + }); + + return af_url_session_manager_creation_queue; +} + +static void url_session_manager_create_task_safely(dispatch_block_t block) { + if (NSFoundationVersionNumber < NSFoundationVersionNumber_With_Fixed_5871104061079552_bug) { + // Fix of bug + // Open Radar:http://openradar.appspot.com/radar?id=5871104061079552 (status: Fixed in iOS8) + // Issue about:https://github.com/AFNetworking/AFNetworking/issues/2093 + dispatch_sync(url_session_manager_creation_queue(), block); + } else { + block(); + } +} + +static dispatch_queue_t url_session_manager_processing_queue() { + static dispatch_queue_t af_url_session_manager_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_url_session_manager_processing_queue; +} + +static dispatch_group_t url_session_manager_completion_group() { + static dispatch_group_t af_url_session_manager_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_completion_group = dispatch_group_create(); + }); + + return af_url_session_manager_completion_group; +} + +NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume"; +NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete"; +NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend"; +NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate"; +NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error"; + +NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; +NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; +NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; +NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error"; +NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; + +static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock"; + +static NSUInteger const AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask = 3; + +static void * AFTaskStateChangedContext = &AFTaskStateChangedContext; + +typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); + +typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); +typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session); + +typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task); +typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend); +typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error); + +typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response); +typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask); +typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data); +typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse); + +typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location); +typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite); +typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes); +typedef void (^AFURLSessionTaskProgressBlock)(NSProgress *); + +typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error); + + +#pragma mark - + +@interface AFURLSessionManagerTaskDelegate : NSObject +@property (nonatomic, weak) AFURLSessionManager *manager; +@property (nonatomic, strong) NSMutableData *mutableData; +@property (nonatomic, strong) NSProgress *uploadProgress; +@property (nonatomic, strong) NSProgress *downloadProgress; +@property (nonatomic, copy) NSURL *downloadFileURL; +@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (nonatomic, copy) AFURLSessionTaskProgressBlock uploadProgressBlock; +@property (nonatomic, copy) AFURLSessionTaskProgressBlock downloadProgressBlock; +@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler; +@end + +@implementation AFURLSessionManagerTaskDelegate + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.mutableData = [NSMutableData data]; + self.uploadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil]; + self.uploadProgress.totalUnitCount = NSURLSessionTransferSizeUnknown; + + self.downloadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil]; + self.downloadProgress.totalUnitCount = NSURLSessionTransferSizeUnknown; + return self; +} + +#pragma mark - NSProgress Tracking + +- (void)setupProgressForTask:(NSURLSessionTask *)task { + __weak __typeof__(task) weakTask = task; + + self.uploadProgress.totalUnitCount = task.countOfBytesExpectedToSend; + self.downloadProgress.totalUnitCount = task.countOfBytesExpectedToReceive; + [self.uploadProgress setCancellable:YES]; + [self.uploadProgress setCancellationHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask cancel]; + }]; + [self.uploadProgress setPausable:YES]; + [self.uploadProgress setPausingHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask suspend]; + }]; + if ([self.uploadProgress respondsToSelector:@selector(setResumingHandler:)]) { + [self.uploadProgress setResumingHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask resume]; + }]; + } + + [self.downloadProgress setCancellable:YES]; + [self.downloadProgress setCancellationHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask cancel]; + }]; + [self.downloadProgress setPausable:YES]; + [self.downloadProgress setPausingHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask suspend]; + }]; + + if ([self.downloadProgress respondsToSelector:@selector(setResumingHandler:)]) { + [self.downloadProgress setResumingHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask resume]; + }]; + } + + [task addObserver:self + forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived)) + options:NSKeyValueObservingOptionNew + context:NULL]; + [task addObserver:self + forKeyPath:NSStringFromSelector(@selector(countOfBytesExpectedToReceive)) + options:NSKeyValueObservingOptionNew + context:NULL]; + + [task addObserver:self + forKeyPath:NSStringFromSelector(@selector(countOfBytesSent)) + options:NSKeyValueObservingOptionNew + context:NULL]; + [task addObserver:self + forKeyPath:NSStringFromSelector(@selector(countOfBytesExpectedToSend)) + options:NSKeyValueObservingOptionNew + context:NULL]; + + [self.downloadProgress addObserver:self + forKeyPath:NSStringFromSelector(@selector(fractionCompleted)) + options:NSKeyValueObservingOptionNew + context:NULL]; + [self.uploadProgress addObserver:self + forKeyPath:NSStringFromSelector(@selector(fractionCompleted)) + options:NSKeyValueObservingOptionNew + context:NULL]; +} + +- (void)cleanUpProgressForTask:(NSURLSessionTask *)task { + [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; + [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesExpectedToReceive))]; + [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; + [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesExpectedToSend))]; + [self.downloadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))]; + [self.uploadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + if ([object isKindOfClass:[NSURLSessionTask class]]) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { + self.downloadProgress.completedUnitCount = [change[@"new"] longLongValue]; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesExpectedToReceive))]) { + self.downloadProgress.totalUnitCount = [change[@"new"] longLongValue]; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { + self.uploadProgress.completedUnitCount = [change[@"new"] longLongValue]; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesExpectedToSend))]) { + self.uploadProgress.totalUnitCount = [change[@"new"] longLongValue]; + } + } + else if ([object isEqual:self.downloadProgress]) { + if (self.downloadProgressBlock) { + self.downloadProgressBlock(object); + } + } + else if ([object isEqual:self.uploadProgress]) { + if (self.uploadProgressBlock) { + self.uploadProgressBlock(object); + } + } +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + __strong AFURLSessionManager *manager = self.manager; + + __block id responseObject = nil; + + __block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer; + + //Performance Improvement from #2672 + NSData *data = nil; + if (self.mutableData) { + data = [self.mutableData copy]; + //We no longer need the reference, so nil it out to gain back some memory. + self.mutableData = nil; + } + + if (self.downloadFileURL) { + userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL; + } else if (data) { + userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = data; + } + + if (error) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = error; + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, error); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + } else { + dispatch_async(url_session_manager_processing_queue(), ^{ + NSError *serializationError = nil; + responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:data error:&serializationError]; + + if (self.downloadFileURL) { + responseObject = self.downloadFileURL; + } + + if (responseObject) { + userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject; + } + + if (serializationError) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError; + } + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, serializationError); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + }); + } +#pragma clang diagnostic pop +} + +#pragma mark - NSURLSessionDataTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + dataTask:(__unused NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + [self.mutableData appendData:data]; +} + +#pragma mark - NSURLSessionDownloadTaskDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + NSError *fileManagerError = nil; + self.downloadFileURL = nil; + + if (self.downloadTaskDidFinishDownloading) { + self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (self.downloadFileURL) { + [[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]; + + if (fileManagerError) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo]; + } + } + } +} + +@end + +#pragma mark - + +/** + * A workaround for issues related to key-value observing the `state` of an `NSURLSessionTask`. + * + * See: + * - https://github.com/AFNetworking/AFNetworking/issues/1477 + * - https://github.com/AFNetworking/AFNetworking/issues/2638 + * - https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + +static inline void af_swizzleSelector(Class theClass, SEL originalSelector, SEL swizzledSelector) { + Method originalMethod = class_getInstanceMethod(theClass, originalSelector); + Method swizzledMethod = class_getInstanceMethod(theClass, swizzledSelector); + method_exchangeImplementations(originalMethod, swizzledMethod); +} + +static inline BOOL af_addMethod(Class theClass, SEL selector, Method method) { + return class_addMethod(theClass, selector, method_getImplementation(method), method_getTypeEncoding(method)); +} + +static NSString * const AFNSURLSessionTaskDidResumeNotification = @"com.alamofire.networking.nsurlsessiontask.resume"; +static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofire.networking.nsurlsessiontask.suspend"; + +@interface _AFURLSessionTaskSwizzling : NSObject + +@end + +@implementation _AFURLSessionTaskSwizzling + ++ (void)load { + /** + WARNING: Trouble Ahead + https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + + if (NSClassFromString(@"NSURLSessionTask")) { + /** + iOS 7 and iOS 8 differ in NSURLSessionTask implementation, which makes the next bit of code a bit tricky. + Many Unit Tests have been built to validate as much of this behavior has possible. + Here is what we know: + - NSURLSessionTasks are implemented with class clusters, meaning the class you request from the API isn't actually the type of class you will get back. + - Simply referencing `[NSURLSessionTask class]` will not work. You need to ask an `NSURLSession` to actually create an object, and grab the class from there. + - On iOS 7, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `__NSCFURLSessionTask`. + - On iOS 8, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `NSURLSessionTask`. + - On iOS 7, `__NSCFLocalSessionTask` and `__NSCFURLSessionTask` are the only two classes that have their own implementations of `resume` and `suspend`, and `__NSCFLocalSessionTask` DOES NOT CALL SUPER. This means both classes need to be swizzled. + - On iOS 8, `NSURLSessionTask` is the only class that implements `resume` and `suspend`. This means this is the only class that needs to be swizzled. + - Because `NSURLSessionTask` is not involved in the class hierarchy for every version of iOS, its easier to add the swizzled methods to a dummy class and manage them there. + + Some Assumptions: + - No implementations of `resume` or `suspend` call super. If this were to change in a future version of iOS, we'd need to handle it. + - No background task classes override `resume` or `suspend` + + The current solution: + 1) Grab an instance of `__NSCFLocalDataTask` by asking an instance of `NSURLSession` for a data task. + 2) Grab a pointer to the original implementation of `af_resume` + 3) Check to see if the current class has an implementation of resume. If so, continue to step 4. + 4) Grab the super class of the current class. + 5) Grab a pointer for the current class to the current implementation of `resume`. + 6) Grab a pointer for the super class to the current implementation of `resume`. + 7) If the current class implementation of `resume` is not equal to the super class implementation of `resume` AND the current implementation of `resume` is not equal to the original implementation of `af_resume`, THEN swizzle the methods + 8) Set the current class to the super class, and repeat steps 3-8 + */ + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration]; + NSURLSession * session = [NSURLSession sessionWithConfiguration:configuration]; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnonnull" + NSURLSessionDataTask *localDataTask = [session dataTaskWithURL:nil]; +#pragma clang diagnostic pop + IMP originalAFResumeIMP = method_getImplementation(class_getInstanceMethod([self class], @selector(af_resume))); + Class currentClass = [localDataTask class]; + + while (class_getInstanceMethod(currentClass, @selector(resume))) { + Class superClass = [currentClass superclass]; + IMP classResumeIMP = method_getImplementation(class_getInstanceMethod(currentClass, @selector(resume))); + IMP superclassResumeIMP = method_getImplementation(class_getInstanceMethod(superClass, @selector(resume))); + if (classResumeIMP != superclassResumeIMP && + originalAFResumeIMP != classResumeIMP) { + [self swizzleResumeAndSuspendMethodForClass:currentClass]; + } + currentClass = [currentClass superclass]; + } + + [localDataTask cancel]; + [session finishTasksAndInvalidate]; + } +} + ++ (void)swizzleResumeAndSuspendMethodForClass:(Class)theClass { + Method afResumeMethod = class_getInstanceMethod(self, @selector(af_resume)); + Method afSuspendMethod = class_getInstanceMethod(self, @selector(af_suspend)); + + if (af_addMethod(theClass, @selector(af_resume), afResumeMethod)) { + af_swizzleSelector(theClass, @selector(resume), @selector(af_resume)); + } + + if (af_addMethod(theClass, @selector(af_suspend), afSuspendMethod)) { + af_swizzleSelector(theClass, @selector(suspend), @selector(af_suspend)); + } +} + +- (NSURLSessionTaskState)state { + NSAssert(NO, @"State method should never be called in the actual dummy class"); + return NSURLSessionTaskStateCanceling; +} + +- (void)af_resume { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_resume]; + + if (state != NSURLSessionTaskStateRunning) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidResumeNotification object:self]; + } +} + +- (void)af_suspend { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_suspend]; + + if (state != NSURLSessionTaskStateSuspended) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidSuspendNotification object:self]; + } +} +@end + +#pragma mark - + +@interface AFURLSessionManager () +@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration; +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; +@property (readwrite, nonatomic, strong) NSURLSession *session; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier; +@property (readonly, nonatomic, copy) NSString *taskDescriptionForSessionTasks; +@property (readwrite, nonatomic, strong) NSLock *lock; +@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid; +@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession; +@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidReceiveAuthenticationChallengeBlock taskDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume; +@end + +@implementation AFURLSessionManager + +- (instancetype)init { + return [self initWithSessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + self = [super init]; + if (!self) { + return nil; + } + + if (!configuration) { + configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + } + + self.sessionConfiguration = configuration; + + self.operationQueue = [[NSOperationQueue alloc] init]; + self.operationQueue.maxConcurrentOperationCount = 1; + + self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue]; + + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + +#if !TARGET_OS_WATCH + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; +#endif + + self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init]; + + self.lock = [[NSLock alloc] init]; + self.lock.name = AFURLSessionManagerLockName; + + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + for (NSURLSessionDataTask *task in dataTasks) { + [self addDelegateForDataTask:task uploadProgress:nil downloadProgress:nil completionHandler:nil]; + } + + for (NSURLSessionUploadTask *uploadTask in uploadTasks) { + [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil]; + } + + for (NSURLSessionDownloadTask *downloadTask in downloadTasks) { + [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil]; + } + }]; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +#pragma mark - + +- (NSString *)taskDescriptionForSessionTasks { + return [NSString stringWithFormat:@"%p", self]; +} + +- (void)taskDidResume:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task]; + }); + } + } +} + +- (void)taskDidSuspend:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task]; + }); + } + } +} + +#pragma mark - + +- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + AFURLSessionManagerTaskDelegate *delegate = nil; + [self.lock lock]; + delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)]; + [self.lock unlock]; + + return delegate; +} + +- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate + forTask:(NSURLSessionTask *)task +{ + NSParameterAssert(task); + NSParameterAssert(delegate); + + [self.lock lock]; + self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate; + [delegate setupProgressForTask:task]; + [self addNotificationObserverForTask:task]; + [self.lock unlock]; +} + +- (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + dataTask.taskDescription = self.taskDescriptionForSessionTasks; + [self setDelegate:delegate forTask:dataTask]; + + delegate.uploadProgressBlock = uploadProgressBlock; + delegate.downloadProgressBlock = downloadProgressBlock; +} + +- (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + uploadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:uploadTask]; + + delegate.uploadProgressBlock = uploadProgressBlock; +} + +- (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + if (destination) { + delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) { + return destination(location, task.response); + }; + } + + downloadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:downloadTask]; + + delegate.downloadProgressBlock = downloadProgressBlock; +} + +- (void)removeDelegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + [self.lock lock]; + [delegate cleanUpProgressForTask:task]; + [self removeNotificationObserverForTask:task]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)]; + [self.lock unlock]; +} + +#pragma mark - + +- (NSArray *)tasksForKeyPath:(NSString *)keyPath { + __block NSArray *tasks = nil; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) { + tasks = dataTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) { + tasks = uploadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) { + tasks = downloadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) { + tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"]; + } + + dispatch_semaphore_signal(semaphore); + }]; + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + + return tasks; +} + +- (NSArray *)tasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)dataTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)uploadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)downloadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +#pragma mark - + +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks { + dispatch_async(dispatch_get_main_queue(), ^{ + if (cancelPendingTasks) { + [self.session invalidateAndCancel]; + } else { + [self.session finishTasksAndInvalidate]; + } + }); +} + +#pragma mark - + +- (void)setResponseSerializer:(id )responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - +- (void)addNotificationObserverForTask:(NSURLSessionTask *)task { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidResume:) name:AFNSURLSessionTaskDidResumeNotification object:task]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidSuspend:) name:AFNSURLSessionTaskDidSuspendNotification object:task]; +} + +- (void)removeNotificationObserverForTask:(NSURLSessionTask *)task { + [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidSuspendNotification object:task]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidResumeNotification object:task]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + return [self dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:completionHandler]; +} + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler { + + __block NSURLSessionDataTask *dataTask = nil; + url_session_manager_create_task_safely(^{ + dataTask = [self.session dataTaskWithRequest:request]; + }); + + [self addDelegateForDataTask:dataTask uploadProgress:uploadProgressBlock downloadProgress:downloadProgressBlock completionHandler:completionHandler]; + + return dataTask; +} + +#pragma mark - + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + url_session_manager_create_task_safely(^{ + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + }); + + if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) { + for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) { + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + } + } + + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(NSData *)bodyData + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + url_session_manager_create_task_safely(^{ + uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData]; + }); + + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + url_session_manager_create_task_safely(^{ + uploadTask = [self.session uploadTaskWithStreamedRequest:request]; + }); + + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler]; + + return uploadTask; +} + +#pragma mark - + +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + url_session_manager_create_task_safely(^{ + downloadTask = [self.session downloadTaskWithRequest:request]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + url_session_manager_create_task_safely(^{ + downloadTask = [self.session downloadTaskWithResumeData:resumeData]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +#pragma mark - +- (NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task { + return [[self delegateForTask:task] uploadProgress]; +} + +- (NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task { + return [[self delegateForTask:task] downloadProgress]; +} + +#pragma mark - + +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block { + self.sessionDidBecomeInvalid = block; +} + +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.sessionDidReceiveAuthenticationChallenge = block; +} + +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block { + self.didFinishEventsForBackgroundURLSession = block; +} + +#pragma mark - + +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block { + self.taskNeedNewBodyStream = block; +} + +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block { + self.taskWillPerformHTTPRedirection = block; +} + +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.taskDidReceiveAuthenticationChallenge = block; +} + +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block { + self.taskDidSendBodyData = block; +} + +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block { + self.taskDidComplete = block; +} + +#pragma mark - + +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block { + self.dataTaskDidReceiveResponse = block; +} + +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block { + self.dataTaskDidBecomeDownloadTask = block; +} + +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block { + self.dataTaskDidReceiveData = block; +} + +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block { + self.dataTaskWillCacheResponse = block; +} + +#pragma mark - + +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block { + self.downloadTaskDidFinishDownloading = block; +} + +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block { + self.downloadTaskDidWriteData = block; +} + +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block { + self.downloadTaskDidResume = block; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue]; +} + +- (BOOL)respondsToSelector:(SEL)selector { + if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) { + return self.taskWillPerformHTTPRedirection != nil; + } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) { + return self.dataTaskDidReceiveResponse != nil; + } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) { + return self.dataTaskWillCacheResponse != nil; + } else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) { + return self.didFinishEventsForBackgroundURLSession != nil; + } + + return [[self class] instancesRespondToSelector:selector]; +} + +#pragma mark - NSURLSessionDelegate + +- (void)URLSession:(NSURLSession *)session +didBecomeInvalidWithError:(NSError *)error +{ + if (self.sessionDidBecomeInvalid) { + self.sessionDidBecomeInvalid(session, error); + } + + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session]; +} + +- (void)URLSession:(NSURLSession *)session +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.sessionDidReceiveAuthenticationChallenge) { + disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + if (credential) { + disposition = NSURLSessionAuthChallengeUseCredential; + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } else { + disposition = NSURLSessionAuthChallengeRejectProtectionSpace; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +willPerformHTTPRedirection:(NSHTTPURLResponse *)response + newRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLRequest *))completionHandler +{ + NSURLRequest *redirectRequest = request; + + if (self.taskWillPerformHTTPRedirection) { + redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request); + } + + if (completionHandler) { + completionHandler(redirectRequest); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.taskDidReceiveAuthenticationChallenge) { + disposition = self.taskDidReceiveAuthenticationChallenge(session, task, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + disposition = NSURLSessionAuthChallengeUseCredential; + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + } else { + disposition = NSURLSessionAuthChallengeRejectProtectionSpace; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler +{ + NSInputStream *inputStream = nil; + + if (self.taskNeedNewBodyStream) { + inputStream = self.taskNeedNewBodyStream(session, task); + } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + inputStream = [task.originalRequest.HTTPBodyStream copy]; + } + + if (completionHandler) { + completionHandler(inputStream); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + didSendBodyData:(int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + + int64_t totalUnitCount = totalBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t) [contentLength longLongValue]; + } + } + + if (self.taskDidSendBodyData) { + self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + + // delegate may be nil when completing a task in the background + if (delegate) { + [delegate URLSession:session task:task didCompleteWithError:error]; + + [self removeDelegateForTask:task]; + } + + if (self.taskDidComplete) { + self.taskDidComplete(session, task, error); + } +} + +#pragma mark - NSURLSessionDataDelegate + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didReceiveResponse:(NSURLResponse *)response + completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler +{ + NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow; + + if (self.dataTaskDidReceiveResponse) { + disposition = self.dataTaskDidReceiveResponse(session, dataTask, response); + } + + if (completionHandler) { + completionHandler(disposition); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + if (delegate) { + [self removeDelegateForTask:dataTask]; + [self setDelegate:delegate forTask:downloadTask]; + } + + if (self.dataTaskDidBecomeDownloadTask) { + self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + [delegate URLSession:session dataTask:dataTask didReceiveData:data]; + + if (self.dataTaskDidReceiveData) { + self.dataTaskDidReceiveData(session, dataTask, data); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + willCacheResponse:(NSCachedURLResponse *)proposedResponse + completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler +{ + NSCachedURLResponse *cachedResponse = proposedResponse; + + if (self.dataTaskWillCacheResponse) { + cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse); + } + + if (completionHandler) { + completionHandler(cachedResponse); + } +} + +- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session { + if (self.didFinishEventsForBackgroundURLSession) { + dispatch_async(dispatch_get_main_queue(), ^{ + self.didFinishEventsForBackgroundURLSession(session); + }); + } +} + +#pragma mark - NSURLSessionDownloadDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + if (self.downloadTaskDidFinishDownloading) { + NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (fileURL) { + delegate.downloadFileURL = fileURL; + NSError *error = nil; + [[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]; + if (error) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo]; + } + + return; + } + } + + if (delegate) { + [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location]; + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didWriteData:(int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + if (self.downloadTaskDidWriteData) { + self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes +{ + if (self.downloadTaskDidResume) { + self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes); + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + + self = [self initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration]; +} + +@end diff --git a/HeadsUpper/Pods/AFNetworking/LICENSE b/HeadsUpper/Pods/AFNetworking/LICENSE new file mode 100644 index 0000000..91f125b --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) + +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/HeadsUpper/Pods/AFNetworking/README.md b/HeadsUpper/Pods/AFNetworking/README.md new file mode 100644 index 0000000..f784681 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/README.md @@ -0,0 +1,320 @@ +

+ AFNetworking +

+ +[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.svg)](https://travis-ci.org/AFNetworking/AFNetworking) +[![codecov.io](https://codecov.io/github/AFNetworking/AFNetworking/coverage.svg?branch=master)](https://codecov.io/github/AFNetworking/AFNetworking?branch=master) +[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/AFNetworking.svg)](https://img.shields.io/cocoapods/v/AFNetworking.svg) +[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) +[![Platform](https://img.shields.io/cocoapods/p/AFNetworking.svg?style=flat)](http://cocoadocs.org/docsets/AFNetworking) +[![Twitter](https://img.shields.io/badge/twitter-@AFNetworking-blue.svg?style=flat)](http://twitter.com/AFNetworking) + +AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of the [Foundation URL Loading System](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. + +Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. + +Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did! + +## How To Get Started + +- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps +- Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki) +- Check out the [documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at all of the APIs available in AFNetworking +- Read the [AFNetworking 3.0 Migration Guide](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-3.0-Migration-Guide) for an overview of the architectural changes from 2.0. + +## Communication + +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking') +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). +- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + +## Installation +AFNetworking supports multiple methods for installing the library in a project. + +## Installation with CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects. See the ["Getting Started" guide for more information](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking). You can install it with the following command: + +```bash +$ gem install cocoapods +``` + +> CocoaPods 0.39.0+ is required to build AFNetworking 3.0.0+. + +#### Podfile + +To integrate AFNetworking into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' + +pod 'AFNetworking', '~> 3.0' +``` + +Then, run the following command: + +```bash +$ pod install +``` + +### Installation with Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. + +You can install Carthage with [Homebrew](http://brew.sh/) using the following command: + +```bash +$ brew update +$ brew install carthage +``` + +To integrate AFNetworking into your Xcode project using Carthage, specify it in your `Cartfile`: + +```ogdl +github "AFNetworking/AFNetworking" ~> 3.0 +``` + +Run `carthage` to build the framework and drag the built `AFNetworking.framework` into your Xcode project. + +## Requirements + +| AFNetworking Version | Minimum iOS Target | Minimum OS X Target | Minimum watchOS Target | Minimum tvOS Target | Notes | +|:--------------------:|:---------------------------:|:----------------------------:|:----------------------------:|:----------------------------:|:-------------------------------------------------------------------------:| +| 3.x | iOS 7 | OS X 10.9 | watchOS 2.0 | tvOS 9.0 | Xcode 7+ is required. `NSURLConnectionOperation` support has been removed. | +| 2.6 -> 2.6.3 | iOS 7 | OS X 10.9 | watchOS 2.0 | n/a | Xcode 7+ is required. | +| 2.0 -> 2.5.4 | iOS 6 | OS X 10.8 | n/a | n/a | Xcode 5+ is required. `NSURLSession` subspec requires iOS 7 or OS X 10.9. | +| 1.x | iOS 5 | Mac OS X 10.7 | n/a | n/a | +| 0.10.x | iOS 4 | Mac OS X 10.6 | n/a | n/a | + +(OS X projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)). + +> Programming in Swift? Try [Alamofire](https://github.com/Alamofire/Alamofire) for a more conventional set of APIs. + +## Architecture + +### NSURLSession + +- `AFURLSessionManager` +- `AFHTTPSessionManager` + +### Serialization + +* `` + - `AFHTTPRequestSerializer` + - `AFJSONRequestSerializer` + - `AFPropertyListRequestSerializer` +* `` + - `AFHTTPResponseSerializer` + - `AFJSONResponseSerializer` + - `AFXMLParserResponseSerializer` + - `AFXMLDocumentResponseSerializer` _(Mac OS X)_ + - `AFPropertyListResponseSerializer` + - `AFImageResponseSerializer` + - `AFCompoundResponseSerializer` + +### Additional Functionality + +- `AFSecurityPolicy` +- `AFNetworkReachabilityManager` + +## Usage + +### AFURLSessionManager + +`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + +#### Creating a Download Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { + NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; + return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; +} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) { + NSLog(@"File downloaded to: %@", filePath); +}]; +[downloadTask resume]; +``` + +#### Creating an Upload Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"Success: %@ %@", response, responseObject); + } +}]; +[uploadTask resume]; +``` + +#### Creating an Upload Task for a Multi-Part Request, with Progress + +```objective-c +NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil]; + } error:nil]; + +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; + +NSURLSessionUploadTask *uploadTask; +uploadTask = [manager + uploadTaskWithStreamedRequest:request + progress:^(NSProgress * _Nonnull uploadProgress) { + // This is not called back on the main queue. + // You are responsible for dispatching to the main queue for UI updates + dispatch_async(dispatch_get_main_queue(), ^{ + //Update the progress view + [progressView setProgress:uploadProgress.fractionCompleted]; + }); + } + completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } + }]; + +[uploadTask resume]; +``` + +#### Creating a Data Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } +}]; +[dataTask resume]; +``` + +--- + +### Request Serialization + +Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body. + +```objective-c +NSString *URLString = @"http://example.com"; +NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]}; +``` + +#### Query String Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil]; +``` + + GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### URL Form Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters]; +``` + + POST http://example.com/ + Content-Type: application/x-www-form-urlencoded + + foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### JSON Parameter Encoding + +```objective-c +[[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters]; +``` + + POST http://example.com/ + Content-Type: application/json + + {"foo": "bar", "baz": [1,2,3]} + +--- + +### Network Reachability Manager + +`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + +* Do not use Reachability to determine if the original request should be sent. + * You should try to send it. +* You can use Reachability to determine when a request should be automatically retried. + * Although it may still fail, a Reachability notification that the connectivity is available is a good time to retry something. +* Network reachability is a useful tool for determining why a request might have failed. + * After a network request has failed, telling the user they're offline is better than giving them a more technical but accurate error, such as "request timed out." + +See also [WWDC 2012 session 706, "Networking Best Practices."](https://developer.apple.com/videos/play/wwdc2012-706/). + +#### Shared Network Reachability + +```objective-c +[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status)); +}]; + +[[AFNetworkReachabilityManager sharedManager] startMonitoring]; +``` + +--- + +### Security Policy + +`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + +Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + +#### Allowing Invalid SSL Certificates + +```objective-c +AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; +manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production +``` + +--- + +## Unit Tests + +AFNetworking includes a suite of unit tests within the Tests subdirectory. These tests can be run simply be executed the test action on the platform framework you would like to test. + +## Credits + +AFNetworking is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org). + +AFNetworking was originally created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla). + +AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/). + +And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors). + +### Security Disclosure + +If you believe you have identified a security vulnerability with AFNetworking, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker. + +## License + +AFNetworking is released under the MIT license. See LICENSE for details. diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h new file mode 100644 index 0000000..e89b951 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h @@ -0,0 +1,149 @@ +// AFAutoPurgingImageCache.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import +#import + +#if TARGET_OS_IOS || TARGET_OS_TV +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously. + */ +@protocol AFImageCache + +/** + Adds the image to the cache with the given identifier. + + @param image The image to cache. + @param identifier The unique identifier for the image in the cache. + */ +- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier; + +/** + Removes the image from the cache matching the given identifier. + + @param identifier The unique identifier for the image in the cache. + + @return A BOOL indicating whether or not the image was removed from the cache. + */ +- (BOOL)removeImageWithIdentifier:(NSString *)identifier; + +/** + Removes all images from the cache. + + @return A BOOL indicating whether or not all images were removed from the cache. + */ +- (BOOL)removeAllImages; + +/** + Returns the image in the cache associated with the given identifier. + + @param identifier The unique identifier for the image in the cache. + + @return An image for the matching identifier, or nil. + */ +- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier; +@end + + +/** + The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier. + */ +@protocol AFImageRequestCache + +/** + Adds the image to the cache using an identifier created from the request and additional identifier. + + @param image The image to cache. + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + */ +- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +/** + Removes the image from the cache using an identifier created from the request and additional identifier. + + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + + @return A BOOL indicating whether or not all images were removed from the cache. + */ +- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +/** + Returns the image from the cache associated with an identifier created from the request and additional identifier. + + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + + @return An image for the matching request and identifier, or nil. + */ +- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +@end + +/** + The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated. + */ +@interface AFAutoPurgingImageCache : NSObject + +/** + The total memory capacity of the cache in bytes. + */ +@property (nonatomic, assign) UInt64 memoryCapacity; + +/** + The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit. + */ +@property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge; + +/** + The current total memory usage in bytes of all images stored within the cache. + */ +@property (nonatomic, assign, readonly) UInt64 memoryUsage; + +/** + Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`. + + @return The new `AutoPurgingImageCache` instance. + */ +- (instancetype)init; + +/** + Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage + after purge limit. + + @param memoryCapacity The total memory capacity of the cache in bytes. + @param preferredMemoryUsageAfterPurge The preferred memory usage after purge in bytes. + + @return The new `AutoPurgingImageCache` instance. + */ +- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity; + +@end + +NS_ASSUME_NONNULL_END + +#endif + diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m new file mode 100644 index 0000000..326fe4f --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m @@ -0,0 +1,201 @@ +// AFAutoPurgingImageCache.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFAutoPurgingImageCache.h" + +@interface AFCachedImage : NSObject + +@property (nonatomic, strong) UIImage *image; +@property (nonatomic, strong) NSString *identifier; +@property (nonatomic, assign) UInt64 totalBytes; +@property (nonatomic, strong) NSDate *lastAccessDate; +@property (nonatomic, assign) UInt64 currentMemoryUsage; + +@end + +@implementation AFCachedImage + +-(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier { + if (self = [self init]) { + self.image = image; + self.identifier = identifier; + + CGSize imageSize = CGSizeMake(image.size.width * image.scale, image.size.height * image.scale); + CGFloat bytesPerPixel = 4.0; + CGFloat bytesPerRow = imageSize.width * bytesPerPixel; + self.totalBytes = (UInt64)bytesPerPixel * (UInt64)bytesPerRow; + self.lastAccessDate = [NSDate date]; + } + return self; +} + +- (UIImage*)accessImage { + self.lastAccessDate = [NSDate date]; + return self.image; +} + +- (NSString *)description { + NSString *descriptionString = [NSString stringWithFormat:@"Idenfitier: %@ lastAccessDate: %@ ", self.identifier, self.lastAccessDate]; + return descriptionString; + +} + +@end + +@interface AFAutoPurgingImageCache () +@property (nonatomic, strong) NSMutableDictionary *cachedImages; +@property (nonatomic, assign) UInt64 currentMemoryUsage; +@property (nonatomic, strong) dispatch_queue_t synchronizationQueue; +@end + +@implementation AFAutoPurgingImageCache + +- (instancetype)init { + return [self initWithMemoryCapacity:100 * 1024 * 1024 preferredMemoryCapacity:60 * 1024 * 1024]; +} + +- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity { + if (self = [super init]) { + self.memoryCapacity = memoryCapacity; + self.preferredMemoryUsageAfterPurge = preferredMemoryCapacity; + self.cachedImages = [[NSMutableDictionary alloc] init]; + + NSString *queueName = [NSString stringWithFormat:@"com.alamofire.autopurgingimagecache-%@", [[NSUUID UUID] UUIDString]]; + self.synchronizationQueue = dispatch_queue_create([queueName cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT); + + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(removeAllImages) + name:UIApplicationDidReceiveMemoryWarningNotification + object:nil]; + + } + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (UInt64)memoryUsage { + __block UInt64 result = 0; + dispatch_sync(self.synchronizationQueue, ^{ + result = self.currentMemoryUsage; + }); + return result; +} + +- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier { + dispatch_barrier_async(self.synchronizationQueue, ^{ + AFCachedImage *cacheImage = [[AFCachedImage alloc] initWithImage:image identifier:identifier]; + + AFCachedImage *previousCachedImage = self.cachedImages[identifier]; + if (previousCachedImage != nil) { + self.currentMemoryUsage -= previousCachedImage.totalBytes; + } + + self.cachedImages[identifier] = cacheImage; + self.currentMemoryUsage += cacheImage.totalBytes; + }); + + dispatch_barrier_async(self.synchronizationQueue, ^{ + if (self.currentMemoryUsage > self.memoryCapacity) { + UInt64 bytesToPurge = self.currentMemoryUsage - self.preferredMemoryUsageAfterPurge; + NSMutableArray *sortedImages = [NSMutableArray arrayWithArray:self.cachedImages.allValues]; + NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastAccessDate" + ascending:YES]; + [sortedImages sortUsingDescriptors:@[sortDescriptor]]; + + UInt64 bytesPurged = 0; + + for (AFCachedImage *cachedImage in sortedImages) { + [self.cachedImages removeObjectForKey:cachedImage.identifier]; + bytesPurged += cachedImage.totalBytes; + if (bytesPurged >= bytesToPurge) { + break ; + } + } + self.currentMemoryUsage -= bytesPurged; + } + }); +} + +- (BOOL)removeImageWithIdentifier:(NSString *)identifier { + __block BOOL removed = NO; + dispatch_barrier_sync(self.synchronizationQueue, ^{ + AFCachedImage *cachedImage = self.cachedImages[identifier]; + if (cachedImage != nil) { + [self.cachedImages removeObjectForKey:identifier]; + self.currentMemoryUsage -= cachedImage.totalBytes; + removed = YES; + } + }); + return removed; +} + +- (BOOL)removeAllImages { + __block BOOL removed = NO; + dispatch_barrier_sync(self.synchronizationQueue, ^{ + if (self.cachedImages.count > 0) { + [self.cachedImages removeAllObjects]; + self.currentMemoryUsage = 0; + removed = YES; + } + }); + return removed; +} + +- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier { + __block UIImage *image = nil; + dispatch_sync(self.synchronizationQueue, ^{ + AFCachedImage *cachedImage = self.cachedImages[identifier]; + image = [cachedImage accessImage]; + }); + return image; +} + +- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { + [self addImage:image withIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; +} + +- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { + return [self removeImageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; +} + +- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { + return [self imageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; +} + +- (NSString *)imageCacheKeyFromURLRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)additionalIdentifier { + NSString *key = request.URL.absoluteString; + if (additionalIdentifier != nil) { + key = [key stringByAppendingString:additionalIdentifier]; + } + return key; +} + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h new file mode 100644 index 0000000..b35e185 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h @@ -0,0 +1,157 @@ +// AFImageDownloader.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import +#import "AFAutoPurgingImageCache.h" +#import "AFHTTPSessionManager.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) { + AFImageDownloadPrioritizationFIFO, + AFImageDownloadPrioritizationLIFO +}; + +/** + The `AFImageDownloadReceipt` is an object vended by the `AFImageDownloader` when starting a data task. It can be used to cancel active tasks running on the `AFImageDownloader` session. As a general rule, image data tasks should be cancelled using the `AFImageDownloadReceipt` instead of calling `cancel` directly on the `task` itself. The `AFImageDownloader` is optimized to handle duplicate task scenarios as well as pending versus active downloads. + */ +@interface AFImageDownloadReceipt : NSObject + +/** + The data task created by the `AFImageDownloader`. +*/ +@property (nonatomic, strong) NSURLSessionDataTask *task; + +/** + The unique identifier for the success and failure blocks when duplicate requests are made. + */ +@property (nonatomic, strong) NSUUID *receiptID; +@end + +/** The `AFImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying `NSURLCache` as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation. + */ +@interface AFImageDownloader : NSObject + +/** + The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default. + */ +@property (nonatomic, strong, nullable) id imageCache; + +/** + The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads. + */ +@property (nonatomic, strong) AFHTTPSessionManager *sessionManager; + +/** + Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default. + */ +@property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton; + +/** + The shared default instance of `AFImageDownloader` initialized with default values. + */ ++ (instancetype)defaultInstance; + +/** + Creates a default `NSURLCache` with common usage parameter values. + + @returns The default `NSURLCache` instance. + */ ++ (NSURLCache *)defaultURLCache; + +/** + Default initializer + + @return An instance of `AFImageDownloader` initialized with default values. + */ +- (instancetype)init; + +/** + Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache. + + @param sessionManager The session manager to use to download images. + @param downloadPrioritization The download prioritization of the download queue. + @param maximumActiveDownloads The maximum number of active downloads allowed at any given time. Recommend `4`. + @param imageCache The image cache used to store all downloaded images in. + + @return The new `AFImageDownloader` instance. + */ +- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager + downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization + maximumActiveDownloads:(NSInteger)maximumActiveDownloads + imageCache:(nullable id )imageCache; + +/** + Creates a data task using the `sessionManager` instance for the specified URL request. + + If the same data task is already in the queue or currently being downloaded, the success and failure blocks are + appended to the already existing task. Once the task completes, all success or failure blocks attached to the + task are executed in the order they were added. + + @param request The URL request. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + + @return The image download receipt for the data task if available. `nil` if the image is stored in the cache. + cache and the URL request cache policy allows the cache to be used. + */ +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + +/** + Creates a data task using the `sessionManager` instance for the specified URL request. + + If the same data task is already in the queue or currently being downloaded, the success and failure blocks are + appended to the already existing task. Once the task completes, all success or failure blocks attached to the + task are executed in the order they were added. + + @param request The URL request. + @param request The identifier to use for the download receipt that will be created for this request. This must be a unique identifier that does not represent any other request. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + + @return The image download receipt for the data task if available. `nil` if the image is stored in the cache. + cache and the URL request cache policy allows the cache to be used. + */ +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + withReceiptID:(NSUUID *)receiptID + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + +/** + Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary. + + If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes. + + @param imageDownloadReceipt The image download receipt to cancel. + */ +- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt; + +@end + +#endif + +NS_ASSUME_NONNULL_END diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m new file mode 100644 index 0000000..e87082a --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m @@ -0,0 +1,369 @@ +// AFImageDownloader.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFImageDownloader.h" +#import "AFHTTPSessionManager.h" + +@interface AFImageDownloaderResponseHandler : NSObject +@property (nonatomic, strong) NSUUID *uuid; +@property (nonatomic, copy) void (^successBlock)(NSURLRequest*, NSHTTPURLResponse*, UIImage*); +@property (nonatomic, copy) void (^failureBlock)(NSURLRequest*, NSHTTPURLResponse*, NSError*); +@end + +@implementation AFImageDownloaderResponseHandler + +- (instancetype)initWithUUID:(NSUUID *)uuid + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure { + if (self = [self init]) { + self.uuid = uuid; + self.successBlock = success; + self.failureBlock = failure; + } + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat: @"UUID: %@", [self.uuid UUIDString]]; +} + +@end + +@interface AFImageDownloaderMergedTask : NSObject +@property (nonatomic, strong) NSString *identifier; +@property (nonatomic, strong) NSURLSessionDataTask *task; +@property (nonatomic, strong) NSMutableArray *responseHandlers; + +@end + +@implementation AFImageDownloaderMergedTask + +- (instancetype)initWithIdentifier:(NSString *)identifier task:(NSURLSessionDataTask *)task { + if (self = [self init]) { + self.identifier = identifier; + self.task = task; + self.responseHandlers = [[NSMutableArray alloc] init]; + } + return self; +} + +- (void)addResponseHandler:(AFImageDownloaderResponseHandler*)handler { + [self.responseHandlers addObject:handler]; +} + +- (void)removeResponseHandler:(AFImageDownloaderResponseHandler*)handler { + [self.responseHandlers removeObject:handler]; +} + +@end + +@implementation AFImageDownloadReceipt + +- (instancetype)initWithReceiptID:(NSUUID *)receiptID task:(NSURLSessionDataTask *)task { + if (self = [self init]) { + self.receiptID = receiptID; + self.task = task; + } + return self; +} + +@end + +@interface AFImageDownloader () + +@property (nonatomic, strong) dispatch_queue_t synchronizationQueue; +@property (nonatomic, strong) dispatch_queue_t responseQueue; + +@property (nonatomic, assign) NSInteger maximumActiveDownloads; +@property (nonatomic, assign) NSInteger activeRequestCount; + +@property (nonatomic, strong) NSMutableArray *queuedMergedTasks; +@property (nonatomic, strong) NSMutableDictionary *mergedTasks; + +@end + + +@implementation AFImageDownloader + ++ (NSURLCache *)defaultURLCache { + return [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 + diskCapacity:150 * 1024 * 1024 + diskPath:@"com.alamofire.imagedownloader"]; +} + ++ (NSURLSessionConfiguration *)defaultURLSessionConfiguration { + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + + //TODO set the default HTTP headers + + configuration.HTTPShouldSetCookies = YES; + configuration.HTTPShouldUsePipelining = NO; + + configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy; + configuration.allowsCellularAccess = YES; + configuration.timeoutIntervalForRequest = 60.0; + configuration.URLCache = [AFImageDownloader defaultURLCache]; + + return configuration; +} + +- (instancetype)init { + NSURLSessionConfiguration *defaultConfiguration = [self.class defaultURLSessionConfiguration]; + AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:defaultConfiguration]; + sessionManager.responseSerializer = [AFImageResponseSerializer serializer]; + + return [self initWithSessionManager:sessionManager + downloadPrioritization:AFImageDownloadPrioritizationFIFO + maximumActiveDownloads:4 + imageCache:[[AFAutoPurgingImageCache alloc] init]]; +} + +- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager + downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization + maximumActiveDownloads:(NSInteger)maximumActiveDownloads + imageCache:(id )imageCache { + if (self = [super init]) { + self.sessionManager = sessionManager; + + self.downloadPrioritizaton = downloadPrioritization; + self.maximumActiveDownloads = maximumActiveDownloads; + self.imageCache = imageCache; + + self.queuedMergedTasks = [[NSMutableArray alloc] init]; + self.mergedTasks = [[NSMutableDictionary alloc] init]; + self.activeRequestCount = 0; + + NSString *name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.synchronizationqueue-%@", [[NSUUID UUID] UUIDString]]; + self.synchronizationQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_SERIAL); + + name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.responsequeue-%@", [[NSUUID UUID] UUIDString]]; + self.responseQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT); + } + + return self; +} + ++ (instancetype)defaultInstance { + static AFImageDownloader *sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [[self alloc] init]; + }); + return sharedInstance; +} + +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + success:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, UIImage * _Nonnull))success + failure:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, NSError * _Nonnull))failure { + return [self downloadImageForURLRequest:request withReceiptID:[NSUUID UUID] success:success failure:failure]; +} + +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + withReceiptID:(nonnull NSUUID *)receiptID + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure { + __block NSURLSessionDataTask *task = nil; + dispatch_sync(self.synchronizationQueue, ^{ + NSString *identifier = request.URL.absoluteString; + + // 1) Append the success and failure blocks to a pre-existing request if it already exists + AFImageDownloaderMergedTask *existingMergedTask = self.mergedTasks[identifier]; + if (existingMergedTask != nil) { + AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID success:success failure:failure]; + [existingMergedTask addResponseHandler:handler]; + task = existingMergedTask.task; + return; + } + + // 2) Attempt to load the image from the image cache if the cache policy allows it + switch (request.cachePolicy) { + case NSURLRequestUseProtocolCachePolicy: + case NSURLRequestReturnCacheDataElseLoad: + case NSURLRequestReturnCacheDataDontLoad: { + UIImage *cachedImage = [self.imageCache imageforRequest:request withAdditionalIdentifier:nil]; + if (cachedImage != nil) { + if (success) { + dispatch_async(dispatch_get_main_queue(), ^{ + success(request, nil, cachedImage); + }); + } + return; + } + break; + } + default: + break; + } + + // 3) Create the request and set up authentication, validation and response serialization + NSURLSessionDataTask *createdTask; + __weak __typeof__(self) weakSelf = self; + + createdTask = [self.sessionManager + dataTaskWithRequest:request + completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { + dispatch_async(self.responseQueue, ^{ + __strong __typeof__(weakSelf) strongSelf = weakSelf; + AFImageDownloaderMergedTask *mergedTask = [strongSelf safelyRemoveMergedTaskWithIdentifier:identifier]; + if (error) { + for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) { + if (handler.failureBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler.failureBlock(request, (NSHTTPURLResponse*)response, error); + }); + } + } + } else { + [strongSelf.imageCache addImage:responseObject forRequest:request withAdditionalIdentifier:nil]; + + for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) { + if (handler.successBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler.successBlock(request, (NSHTTPURLResponse*)response, responseObject); + }); + } + } + + } + [strongSelf safelyDecrementActiveTaskCount]; + [strongSelf safelyStartNextTaskIfNecessary]; + }); + }]; + + // 4) Store the response handler for use when the request completes + AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID + success:success + failure:failure]; + AFImageDownloaderMergedTask *mergedTask = [[AFImageDownloaderMergedTask alloc] + initWithIdentifier:identifier + task:createdTask]; + [mergedTask addResponseHandler:handler]; + self.mergedTasks[identifier] = mergedTask; + + // 5) Either start the request or enqueue it depending on the current active request count + if ([self isActiveRequestCountBelowMaximumLimit]) { + [self startMergedTask:mergedTask]; + } else { + [self enqueueMergedTask:mergedTask]; + } + + task = mergedTask.task; + }); + if (task) { + return [[AFImageDownloadReceipt alloc] initWithReceiptID:receiptID task:task]; + } else { + return nil; + } +} + +- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt { + dispatch_sync(self.synchronizationQueue, ^{ + NSString *identifier = imageDownloadReceipt.task.originalRequest.URL.absoluteString; + AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[identifier]; + NSUInteger index = [mergedTask.responseHandlers indexOfObjectPassingTest:^BOOL(AFImageDownloaderResponseHandler * _Nonnull handler, __unused NSUInteger idx, __unused BOOL * _Nonnull stop) { + return handler.uuid == imageDownloadReceipt.receiptID; + }]; + + if (index != NSNotFound) { + AFImageDownloaderResponseHandler *handler = mergedTask.responseHandlers[index]; + [mergedTask removeResponseHandler:handler]; + NSString *failureReason = [NSString stringWithFormat:@"ImageDownloader cancelled URL request: %@",imageDownloadReceipt.task.originalRequest.URL.absoluteString]; + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey:failureReason}; + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; + if (handler.failureBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler.failureBlock(imageDownloadReceipt.task.originalRequest, nil, error); + }); + } + } + + if (mergedTask.responseHandlers.count == 0 && mergedTask.task.state == NSURLSessionTaskStateSuspended) { + [mergedTask.task cancel]; + } + }); +} + +- (AFImageDownloaderMergedTask*)safelyRemoveMergedTaskWithIdentifier:(NSString *)identifier { + __block AFImageDownloaderMergedTask *mergedTask = nil; + dispatch_sync(self.synchronizationQueue, ^{ + mergedTask = self.mergedTasks[identifier]; + [self.mergedTasks removeObjectForKey:identifier]; + + }); + return mergedTask; +} + +- (void)safelyDecrementActiveTaskCount { + dispatch_sync(self.synchronizationQueue, ^{ + if (self.activeRequestCount > 0) { + self.activeRequestCount -= 1; + } + }); +} + +- (void)safelyStartNextTaskIfNecessary { + dispatch_sync(self.synchronizationQueue, ^{ + if ([self isActiveRequestCountBelowMaximumLimit]) { + while (self.queuedMergedTasks.count > 0) { + AFImageDownloaderMergedTask *mergedTask = [self dequeueMergedTask]; + if (mergedTask.task.state == NSURLSessionTaskStateSuspended) { + [self startMergedTask:mergedTask]; + break; + } + } + } + }); +} + +- (void)startMergedTask:(AFImageDownloaderMergedTask *)mergedTask { + [mergedTask.task resume]; + ++self.activeRequestCount; +} + +- (void)enqueueMergedTask:(AFImageDownloaderMergedTask *)mergedTask { + switch (self.downloadPrioritizaton) { + case AFImageDownloadPrioritizationFIFO: + [self.queuedMergedTasks addObject:mergedTask]; + break; + case AFImageDownloadPrioritizationLIFO: + [self.queuedMergedTasks insertObject:mergedTask atIndex:0]; + break; + } +} + +- (AFImageDownloaderMergedTask *)dequeueMergedTask { + AFImageDownloaderMergedTask *mergedTask = nil; + mergedTask = [self.queuedMergedTasks firstObject]; + [self.queuedMergedTasks removeObject:mergedTask]; + return mergedTask; +} + +- (BOOL)isActiveRequestCountBelowMaximumLimit { + return self.activeRequestCount < self.maximumActiveDownloads; +} + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 100644 index 0000000..a627a6d --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1,103 @@ +// AFNetworkActivityIndicatorManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#import + +#if TARGET_OS_IOS + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. + + You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: + + [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; + + By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. + + See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: + http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 + */ +NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") +@interface AFNetworkActivityIndicatorManager : NSObject + +/** + A Boolean value indicating whether the manager is enabled. + + If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. + */ +@property (nonatomic, assign, getter = isEnabled) BOOL enabled; + +/** + A Boolean value indicating whether the network activity indicator manager is currently active. +*/ +@property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; + +/** + A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds. + + Apple's HIG describes the following: + + > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence. + + */ +@property (nonatomic, assign) NSTimeInterval activationDelay; + +/** + A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds. + */ + +@property (nonatomic, assign) NSTimeInterval completionDelay; + +/** + Returns the shared network activity indicator manager object for the system. + + @return The systemwide network activity indicator manager. + */ ++ (instancetype)sharedManager; + +/** + Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. + */ +- (void)incrementActivityCount; + +/** + Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. + */ +- (void)decrementActivityCount; + +/** + Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward. + + @param block A block to be executed when the network activity indicator status changes. + */ +- (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m new file mode 100644 index 0000000..0615fa9 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m @@ -0,0 +1,261 @@ +// AFNetworkActivityIndicatorManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "AFNetworkActivityIndicatorManager.h" + +#if TARGET_OS_IOS +#import "AFURLSessionManager.h" + +typedef NS_ENUM(NSInteger, AFNetworkActivityManagerState) { + AFNetworkActivityManagerStateNotActive, + AFNetworkActivityManagerStateDelayingStart, + AFNetworkActivityManagerStateActive, + AFNetworkActivityManagerStateDelayingEnd +}; + +static NSTimeInterval const kDefaultAFNetworkActivityManagerActivationDelay = 1.0; +static NSTimeInterval const kDefaultAFNetworkActivityManagerCompletionDelay = 0.17; + +static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { + if ([[notification object] respondsToSelector:@selector(originalRequest)]) { + return [(NSURLSessionTask *)[notification object] originalRequest]; + } else { + return nil; + } +} + +typedef void (^AFNetworkActivityActionBlock)(BOOL networkActivityIndicatorVisible); + +@interface AFNetworkActivityIndicatorManager () +@property (readwrite, nonatomic, assign) NSInteger activityCount; +@property (readwrite, nonatomic, strong) NSTimer *activationDelayTimer; +@property (readwrite, nonatomic, strong) NSTimer *completionDelayTimer; +@property (readonly, nonatomic, getter = isNetworkActivityOccurring) BOOL networkActivityOccurring; +@property (nonatomic, copy) AFNetworkActivityActionBlock networkActivityActionBlock; +@property (nonatomic, assign) AFNetworkActivityManagerState currentState; +@property (nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; + +- (void)updateCurrentStateForNetworkActivityChange; +@end + +@implementation AFNetworkActivityIndicatorManager + ++ (instancetype)sharedManager { + static AFNetworkActivityIndicatorManager *_sharedManager = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _sharedManager = [[self alloc] init]; + }); + + return _sharedManager; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + self.currentState = AFNetworkActivityManagerStateNotActive; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; + self.activationDelay = kDefaultAFNetworkActivityManagerActivationDelay; + self.completionDelay = kDefaultAFNetworkActivityManagerCompletionDelay; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [_activationDelayTimer invalidate]; + [_completionDelayTimer invalidate]; +} + +- (void)setEnabled:(BOOL)enabled { + _enabled = enabled; + if (enabled == NO) { + [self setCurrentState:AFNetworkActivityManagerStateNotActive]; + } +} + +- (void)setNetworkingActivityActionWithBlock:(void (^)(BOOL networkActivityIndicatorVisible))block { + self.networkActivityActionBlock = block; +} + +- (BOOL)isNetworkActivityOccurring { + @synchronized(self) { + return self.activityCount > 0; + } +} + +- (void)setNetworkActivityIndicatorVisible:(BOOL)networkActivityIndicatorVisible { + if (_networkActivityIndicatorVisible != networkActivityIndicatorVisible) { + [self willChangeValueForKey:@"networkActivityIndicatorVisible"]; + @synchronized(self) { + _networkActivityIndicatorVisible = networkActivityIndicatorVisible; + } + [self didChangeValueForKey:@"networkActivityIndicatorVisible"]; + if (self.networkActivityActionBlock) { + self.networkActivityActionBlock(networkActivityIndicatorVisible); + } else { + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:networkActivityIndicatorVisible]; + } + } +} + +- (void)setActivityCount:(NSInteger)activityCount { + @synchronized(self) { + _activityCount = activityCount; + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateCurrentStateForNetworkActivityChange]; + }); +} + +- (void)incrementActivityCount { + [self willChangeValueForKey:@"activityCount"]; + @synchronized(self) { + _activityCount++; + } + [self didChangeValueForKey:@"activityCount"]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateCurrentStateForNetworkActivityChange]; + }); +} + +- (void)decrementActivityCount { + [self willChangeValueForKey:@"activityCount"]; + @synchronized(self) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + _activityCount = MAX(_activityCount - 1, 0); +#pragma clang diagnostic pop + } + [self didChangeValueForKey:@"activityCount"]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateCurrentStateForNetworkActivityChange]; + }); +} + +- (void)networkRequestDidStart:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self incrementActivityCount]; + } +} + +- (void)networkRequestDidFinish:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self decrementActivityCount]; + } +} + +#pragma mark - Internal State Management +- (void)setCurrentState:(AFNetworkActivityManagerState)currentState { + @synchronized(self) { + if (_currentState != currentState) { + [self willChangeValueForKey:@"currentState"]; + _currentState = currentState; + switch (currentState) { + case AFNetworkActivityManagerStateNotActive: + [self cancelActivationDelayTimer]; + [self cancelCompletionDelayTimer]; + [self setNetworkActivityIndicatorVisible:NO]; + break; + case AFNetworkActivityManagerStateDelayingStart: + [self startActivationDelayTimer]; + break; + case AFNetworkActivityManagerStateActive: + [self cancelCompletionDelayTimer]; + [self setNetworkActivityIndicatorVisible:YES]; + break; + case AFNetworkActivityManagerStateDelayingEnd: + [self startCompletionDelayTimer]; + break; + } + } + [self didChangeValueForKey:@"currentState"]; + } +} + +- (void)updateCurrentStateForNetworkActivityChange { + if (self.enabled) { + switch (self.currentState) { + case AFNetworkActivityManagerStateNotActive: + if (self.isNetworkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateDelayingStart]; + } + break; + case AFNetworkActivityManagerStateDelayingStart: + //No op. Let the delay timer finish out. + break; + case AFNetworkActivityManagerStateActive: + if (!self.isNetworkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateDelayingEnd]; + } + break; + case AFNetworkActivityManagerStateDelayingEnd: + if (self.isNetworkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateActive]; + } + break; + } + } +} + +- (void)startActivationDelayTimer { + self.activationDelayTimer = [NSTimer + timerWithTimeInterval:self.activationDelay target:self selector:@selector(activationDelayTimerFired) userInfo:nil repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:self.activationDelayTimer forMode:NSRunLoopCommonModes]; +} + +- (void)activationDelayTimerFired { + if (self.networkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateActive]; + } else { + [self setCurrentState:AFNetworkActivityManagerStateNotActive]; + } +} + +- (void)startCompletionDelayTimer { + [self.completionDelayTimer invalidate]; + self.completionDelayTimer = [NSTimer timerWithTimeInterval:self.completionDelay target:self selector:@selector(completionDelayTimerFired) userInfo:nil repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:self.completionDelayTimer forMode:NSRunLoopCommonModes]; +} + +- (void)completionDelayTimerFired { + [self setCurrentState:AFNetworkActivityManagerStateNotActive]; +} + +- (void)cancelActivationDelayTimer { + [self.activationDelayTimer invalidate]; +} + +- (void)cancelCompletionDelayTimer { + [self.completionDelayTimer invalidate]; +} + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 100644 index 0000000..b6ef044 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1,48 @@ +// UIActivityIndicatorView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +/** + This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task. + */ +@interface UIActivityIndicatorView (AFNetworking) + +///---------------------------------- +/// @name Animating for Session Tasks +///---------------------------------- + +/** + Binds the animating state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m new file mode 100644 index 0000000..fcf1c0c --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m @@ -0,0 +1,124 @@ +// UIActivityIndicatorView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "UIActivityIndicatorView+AFNetworking.h" +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFURLSessionManager.h" + +@interface AFActivityIndicatorViewNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; + +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; + +@end + +@implementation UIActivityIndicatorView (AFNetworking) + +- (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { + AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; +} + +@end + +@implementation AFActivityIndicatorViewNotificationObserver + +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView +{ + self = [super init]; + if (self) { + _activityIndicatorView = activityIndicatorView; + } + return self; +} + +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { + if (task.state != NSURLSessionTaskStateCompleted) { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (task.state == NSURLSessionTaskStateRunning) { + [self.activityIndicatorView startAnimating]; + } else { + [self.activityIndicatorView stopAnimating]; + } +#pragma clang diagnostic pop + + [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; + } + } +} + +#pragma mark - + +- (void)af_startAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.activityIndicatorView startAnimating]; +#pragma clang diagnostic pop + }); +} + +- (void)af_stopAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.activityIndicatorView stopAnimating]; +#pragma clang diagnostic pop + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +} + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h new file mode 100644 index 0000000..98b911e --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1,175 @@ +// UIButton+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFImageDownloader; + +/** + This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL. + + @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported. + */ +@interface UIButton (AFNetworking) + +///------------------------------------ +/// @name Accessing the Image Downloader +///------------------------------------ + +/** + Set the shared image downloader used to download images. + + @param imageDownloader The shared image downloader used to download images. +*/ ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; + +/** + The shared image downloader used to download images. + */ ++ (AFImageDownloader *)sharedImageDownloader; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the image request. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + + +///------------------------------- +/// @name Setting Background Image +///------------------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled. + + If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the background image request. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the background image request. + @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + + +///------------------------------ +/// @name Canceling Image Loading +///------------------------------ + +/** + Cancels any executing image task for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelImageDownloadTaskForState:(UIControlState)state; + +/** + Cancels any executing background image task for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m new file mode 100644 index 0000000..ceb6ebc --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m @@ -0,0 +1,305 @@ +// UIButton+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "UIButton+AFNetworking.h" + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "UIImageView+AFNetworking.h" +#import "AFImageDownloader.h" + +@interface UIButton (_AFNetworking) +@end + +@implementation UIButton (_AFNetworking) + +#pragma mark - + +static char AFImageDownloadReceiptNormal; +static char AFImageDownloadReceiptHighlighted; +static char AFImageDownloadReceiptSelected; +static char AFImageDownloadReceiptDisabled; + +static const char * af_imageDownloadReceiptKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFImageDownloadReceiptHighlighted; + case UIControlStateSelected: + return &AFImageDownloadReceiptSelected; + case UIControlStateDisabled: + return &AFImageDownloadReceiptDisabled; + case UIControlStateNormal: + default: + return &AFImageDownloadReceiptNormal; + } +} + +- (AFImageDownloadReceipt *)af_imageDownloadReceiptForState:(UIControlState)state { + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_imageDownloadReceiptKeyForState(state)); +} + +- (void)af_setImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_imageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +static char AFBackgroundImageDownloadReceiptNormal; +static char AFBackgroundImageDownloadReceiptHighlighted; +static char AFBackgroundImageDownloadReceiptSelected; +static char AFBackgroundImageDownloadReceiptDisabled; + +static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFBackgroundImageDownloadReceiptHighlighted; + case UIControlStateSelected: + return &AFBackgroundImageDownloadReceiptSelected; + case UIControlStateDisabled: + return &AFBackgroundImageDownloadReceiptDisabled; + case UIControlStateNormal: + default: + return &AFBackgroundImageDownloadReceiptNormal; + } +} + +- (AFImageDownloadReceipt *)af_backgroundImageDownloadReceiptForState:(UIControlState)state { + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state)); +} + +- (void)af_setBackgroundImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIButton (AFNetworking) + ++ (AFImageDownloader *)sharedImageDownloader { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; +#pragma clang diagnostic pop +} + ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { + objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure +{ + if ([self isActiveTaskURLEqualToURLRequest:urlRequest forState:state]) { + return; + } + + [self cancelImageDownloadTaskForState:state]; + + AFImageDownloader *downloader = [[self class] sharedImageDownloader]; + id imageCache = downloader.imageCache; + + //Use the image from the image cache if it exists + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setImage:cachedImage forState:state]; + } + [self af_setImageDownloadReceipt:nil forState:state]; + } else { + if (placeholderImage) { + [self setImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + NSUUID *downloadID = [NSUUID UUID]; + AFImageDownloadReceipt *receipt; + receipt = [downloader + downloadImageForURLRequest:urlRequest + withReceiptID:downloadID + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (success) { + success(request, response, responseObject); + } else if(responseObject) { + [strongSelf setImage:responseObject forState:state]; + } + [strongSelf af_setImageDownloadReceipt:nil forState:state]; + } + + } + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (failure) { + failure(request, response, error); + } + [strongSelf af_setImageDownloadReceipt:nil forState:state]; + } + }]; + + [self af_setImageDownloadReceipt:receipt forState:state]; + } +} + +#pragma mark - + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setBackgroundImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure +{ + if ([self isActiveBackgroundTaskURLEqualToURLRequest:urlRequest forState:state]) { + return; + } + + [self cancelImageDownloadTaskForState:state]; + + AFImageDownloader *downloader = [[self class] sharedImageDownloader]; + id imageCache = downloader.imageCache; + + //Use the image from the image cache if it exists + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setBackgroundImage:cachedImage forState:state]; + } + [self af_setBackgroundImageDownloadReceipt:nil forState:state]; + } else { + if (placeholderImage) { + [self setBackgroundImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + NSUUID *downloadID = [NSUUID UUID]; + AFImageDownloadReceipt *receipt; + receipt = [downloader + downloadImageForURLRequest:urlRequest + withReceiptID:downloadID + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (success) { + success(request, response, responseObject); + } else if(responseObject) { + [strongSelf setBackgroundImage:responseObject forState:state]; + } + [strongSelf af_setImageDownloadReceipt:nil forState:state]; + } + + } + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (failure) { + failure(request, response, error); + } + [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state]; + } + }]; + + [self af_setBackgroundImageDownloadReceipt:receipt forState:state]; + } +} + +#pragma mark - + +- (void)cancelImageDownloadTaskForState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state]; + if (receipt != nil) { + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt]; + [self af_setImageDownloadReceipt:nil forState:state]; + } +} + +- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state]; + if (receipt != nil) { + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt]; + [self af_setBackgroundImageDownloadReceipt:nil forState:state]; + } +} + +- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state]; + return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; +} + +- (BOOL)isActiveBackgroundTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state]; + return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; +} + + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h new file mode 100644 index 0000000..14744cd --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1,35 @@ +// +// UIImage+AFNetworking.h +// +// +// Created by Paulo Ferreira on 08/07/15. +// +// 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. + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +@interface UIImage (AFNetworking) + ++ (UIImage*) safeImageWithData:(NSData*)data; + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h new file mode 100644 index 0000000..ce9ae2e --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1,109 @@ +// UIImageView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFImageDownloader; + +/** + This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. + */ +@interface UIImageView (AFNetworking) + +///------------------------------------ +/// @name Accessing the Image Downloader +///------------------------------------ + +/** + Set the shared image downloader used to download images. + + @param imageDownloader The shared image downloader used to download images. + */ ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; + +/** + The shared image downloader used to download images. + */ ++ (AFImageDownloader *)sharedImageDownloader; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + + @param url The URL used for the image request. + */ +- (void)setImageWithURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + + @param url The URL used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. + */ +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. + + @param urlRequest The URL request used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + +/** + Cancels any executing image operation for the receiver, if one exists. + */ +- (void)cancelImageDownloadTask; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m new file mode 100644 index 0000000..a97d5cc --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m @@ -0,0 +1,161 @@ +// UIImageView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "UIImageView+AFNetworking.h" + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFImageDownloader.h" + +@interface UIImageView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setActiveImageDownloadReceipt:) AFImageDownloadReceipt *af_activeImageDownloadReceipt; +@end + +@implementation UIImageView (_AFNetworking) + +- (AFImageDownloadReceipt *)af_activeImageDownloadReceipt { + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, @selector(af_activeImageDownloadReceipt)); +} + +- (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt { + objc_setAssociatedObject(self, @selector(af_activeImageDownloadReceipt), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIImageView (AFNetworking) + ++ (AFImageDownloader *)sharedImageDownloader { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; +#pragma clang diagnostic pop +} + ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { + objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageWithURL:(NSURL *)url { + [self setImageWithURL:url placeholderImage:nil]; +} + +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure +{ + + if ([urlRequest URL] == nil) { + [self cancelImageDownloadTask]; + self.image = placeholderImage; + return; + } + + if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){ + return; + } + + [self cancelImageDownloadTask]; + + AFImageDownloader *downloader = [[self class] sharedImageDownloader]; + id imageCache = downloader.imageCache; + + //Use the image from the image cache if it exists + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + self.image = cachedImage; + } + [self clearActiveDownloadInformation]; + } else { + if (placeholderImage) { + self.image = placeholderImage; + } + + __weak __typeof(self)weakSelf = self; + NSUUID *downloadID = [NSUUID UUID]; + AFImageDownloadReceipt *receipt; + receipt = [downloader + downloadImageForURLRequest:urlRequest + withReceiptID:downloadID + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) { + if (success) { + success(request, response, responseObject); + } else if(responseObject) { + strongSelf.image = responseObject; + } + [strongSelf clearActiveDownloadInformation]; + } + + } + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) { + if (failure) { + failure(request, response, error); + } + [strongSelf clearActiveDownloadInformation]; + } + }]; + + self.af_activeImageDownloadReceipt = receipt; + } +} + +- (void)cancelImageDownloadTask { + if (self.af_activeImageDownloadReceipt != nil) { + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:self.af_activeImageDownloadReceipt]; + [self clearActiveDownloadInformation]; + } +} + +- (void)clearActiveDownloadInformation { + self.af_activeImageDownloadReceipt = nil; +} + +- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest { + return [self.af_activeImageDownloadReceipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; +} + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h new file mode 100644 index 0000000..b36ee0c --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1,42 @@ +// UIKit+AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// 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. + +#if TARGET_OS_IOS || TARGET_OS_TV +#import + +#ifndef _UIKIT_AFNETWORKING_ + #define _UIKIT_AFNETWORKING_ + +#if TARGET_OS_IOS + #import "AFAutoPurgingImageCache.h" + #import "AFImageDownloader.h" + #import "AFNetworkActivityIndicatorManager.h" + #import "UIRefreshControl+AFNetworking.h" + #import "UIWebView+AFNetworking.h" +#endif + + #import "UIActivityIndicatorView+AFNetworking.h" + #import "UIButton+AFNetworking.h" + #import "UIImageView+AFNetworking.h" + #import "UIProgressView+AFNetworking.h" +#endif /* _UIKIT_AFNETWORKING_ */ +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h new file mode 100644 index 0000000..a0c463b --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1,64 @@ +// UIProgressView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +NS_ASSUME_NONNULL_BEGIN + + +/** + This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task. + */ +@interface UIProgressView (AFNetworking) + +///------------------------------------ +/// @name Setting Session Task Progress +///------------------------------------ + +/** + Binds the progress to the upload progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated; + +/** + Binds the progress to the download progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m new file mode 100644 index 0000000..6680bac --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m @@ -0,0 +1,118 @@ +// UIProgressView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "UIProgressView+AFNetworking.h" + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFURLSessionManager.h" + +static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; +static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; + +#pragma mark - + +@implementation UIProgressView (AFNetworking) + +- (BOOL)af_uploadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; +} + +- (void)af_setUploadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (BOOL)af_downloadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; +} + +- (void)af_setDownloadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated +{ + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + + [self af_setUploadProgressAnimated:animated]; +} + +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated +{ + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + + [self af_setDownloadProgressAnimated:animated]; +} + +#pragma mark - NSKeyValueObserving + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(__unused NSDictionary *)change + context:(void *)context +{ + if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { + if ([object countOfBytesExpectedToSend] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { + if ([object countOfBytesExpectedToReceive] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { + if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { + @try { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; + + if (context == AFTaskCountOfBytesSentContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; + } + + if (context == AFTaskCountOfBytesReceivedContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; + } + } + @catch (NSException * __unused exception) {} + } + } + } +} + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h new file mode 100644 index 0000000..f6930a9 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1,53 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2014 AFNetworking (http://afnetworking.com) +// +// 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. + +#import + +#import + +#if TARGET_OS_IOS + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task. + */ +@interface UIRefreshControl (AFNetworking) + +///----------------------------------- +/// @name Refreshing for Session Tasks +///----------------------------------- + +/** + Binds the refreshing state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m new file mode 100644 index 0000000..ddc033b --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m @@ -0,0 +1,122 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2014 AFNetworking (http://afnetworking.com) +// +// 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. + +#import "UIRefreshControl+AFNetworking.h" +#import + +#if TARGET_OS_IOS + +#import "AFURLSessionManager.h" + +@interface AFRefreshControlNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; + +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; + +@end + +@implementation UIRefreshControl (AFNetworking) + +- (AFRefreshControlNotificationObserver *)af_notificationObserver { + AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; +} + +@end + +@implementation AFRefreshControlNotificationObserver + +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl +{ + self = [super init]; + if (self) { + _refreshControl = refreshControl; + } + return self; +} + +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (task.state == NSURLSessionTaskStateRunning) { + [self.refreshControl beginRefreshing]; + + [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; + } else { + [self.refreshControl endRefreshing]; + } +#pragma clang diagnostic pop + } +} + +#pragma mark - + +- (void)af_beginRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.refreshControl beginRefreshing]; +#pragma clang diagnostic pop + }); +} + +- (void)af_endRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.refreshControl endRefreshing]; +#pragma clang diagnostic pop + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +} + +@end + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h new file mode 100644 index 0000000..777dce2 --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1,80 @@ +// UIWebView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import + +#import + +#if TARGET_OS_IOS + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFHTTPSessionManager; + +/** + This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. + + @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. + */ +@interface UIWebView (AFNetworking) + +/** + The session manager used to download all requests. + */ +@property (nonatomic, strong) AFHTTPSessionManager *sessionManager; + +/** + Asynchronously loads the specified request. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param progress A progress object monitoring the current download progress. + @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. + @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)loadRequest:(NSURLRequest *)request + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(nullable void (^)(NSError *error))failure; + +/** + Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. + @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. +@param progress A progress object monitoring the current download progress. + @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. + @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)loadRequest:(NSURLRequest *)request + MIMEType:(nullable NSString *)MIMEType + textEncodingName:(nullable NSString *)textEncodingName + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(nullable void (^)(NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m new file mode 100644 index 0000000..ac089da --- /dev/null +++ b/HeadsUpper/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m @@ -0,0 +1,160 @@ +// UIWebView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// 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. + +#import "UIWebView+AFNetworking.h" + +#import + +#if TARGET_OS_IOS + +#import "AFHTTPSessionManager.h" +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" + +@interface UIWebView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setURLSessionTask:) NSURLSessionDataTask *af_URLSessionTask; +@end + +@implementation UIWebView (_AFNetworking) + +- (NSURLSessionDataTask *)af_URLSessionTask { + return (NSURLSessionDataTask *)objc_getAssociatedObject(self, @selector(af_URLSessionTask)); +} + +- (void)af_setURLSessionTask:(NSURLSessionDataTask *)af_URLSessionTask { + objc_setAssociatedObject(self, @selector(af_URLSessionTask), af_URLSessionTask, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIWebView (AFNetworking) + +- (AFHTTPSessionManager *)sessionManager { + static AFHTTPSessionManager *_af_defaultHTTPSessionManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultHTTPSessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; + _af_defaultHTTPSessionManager.requestSerializer = [AFHTTPRequestSerializer serializer]; + _af_defaultHTTPSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sessionManager)) ?: _af_defaultHTTPSessionManager; +#pragma clang diagnostic pop +} + +- (void)setSessionManager:(AFHTTPSessionManager *)sessionManager { + objc_setAssociatedObject(self, @selector(sessionManager), sessionManager, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (AFHTTPResponseSerializer *)responseSerializer { + static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; +#pragma clang diagnostic pop +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)loadRequest:(NSURLRequest *)request + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(void (^)(NSError *error))failure +{ + [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { + NSStringEncoding stringEncoding = NSUTF8StringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (success) { + string = success(response, string); + } + + return [string dataUsingEncoding:stringEncoding]; + } failure:failure]; +} + +- (void)loadRequest:(NSURLRequest *)request + MIMEType:(NSString *)MIMEType + textEncodingName:(NSString *)textEncodingName + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(void (^)(NSError *error))failure +{ + NSParameterAssert(request); + + if (self.af_URLSessionTask.state == NSURLSessionTaskStateRunning || self.af_URLSessionTask.state == NSURLSessionTaskStateSuspended) { + [self.af_URLSessionTask cancel]; + } + self.af_URLSessionTask = nil; + + __weak __typeof(self)weakSelf = self; + NSURLSessionDataTask *dataTask; + dataTask = [self.sessionManager + GET:request.URL.absoluteString + parameters:nil + progress:nil + success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { + __strong __typeof(weakSelf) strongSelf = weakSelf; + if (success) { + success((NSHTTPURLResponse *)task.response, responseObject); + } + [strongSelf loadData:responseObject MIMEType:MIMEType textEncodingName:textEncodingName baseURL:[task.currentRequest URL]]; + + if ([strongSelf.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { + [strongSelf.delegate webViewDidFinishLoad:strongSelf]; + } + } + failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) { + if (failure) { + failure(error); + } + }]; + self.af_URLSessionTask = dataTask; + *progress = [self.sessionManager downloadProgressForTask:dataTask]; + [self.af_URLSessionTask resume]; + + if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { + [self.delegate webViewDidStartLoad:self]; + } +} + +@end + +#endif \ No newline at end of file diff --git a/HeadsUpper/Pods/ChameleonFramework/LICENSE.md b/HeadsUpper/Pods/ChameleonFramework/LICENSE.md new file mode 100755 index 0000000..7fd117d --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/LICENSE.md @@ -0,0 +1,21 @@ +##The MIT License (MIT) + +> Copyright (c) 2014-2015 Vicc Alexander + +> 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/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/Chameleon.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/Chameleon.h new file mode 100755 index 0000000..9573d11 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/Chameleon.h @@ -0,0 +1,31 @@ +// +// Chameleon.h +// Chameleon +// +// Created by Vicc Alexander on 9/24/15. +// Copyright © 2015 Vicc Alexander. All rights reserved. +// + +#import + +//! Project version number for Chameleon. +FOUNDATION_EXPORT double ChameleonVersionNumber; + +//! Project version string for Chameleon. +FOUNDATION_EXPORT const unsigned char ChameleonVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + +#import "Chameleon_.h" + +#import "UIButton+Chameleon.h" +#import "UILabel+Chameleon.h" +#import "UIColor+ChameleonPrivate.h" +#import "UIImage+ChameleonPrivate.h" +#import "UIView+ChameleonPrivate.h" +#import "UIAppearance+Swift.h" + +#import "NSArray+Chameleon.h" +#import "UIColor+Chameleon.h" +#import "UINavigationController+Chameleon.h" +#import "UIViewController+Chameleon.h" diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonConstants.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonConstants.h new file mode 100755 index 0000000..9c9c345 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonConstants.h @@ -0,0 +1,21 @@ +// +// Constants.h +// Chameleon +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import +#import + +/** + * A contrasting status bar, intended for use on any backgrounds. + * + * @since 2.0 + */ +extern const UIStatusBarStyle UIStatusBarStyleContrast; + +@interface ChameleonConstants : NSObject + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonConstants.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonConstants.m new file mode 100755 index 0000000..02cdc7f --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonConstants.m @@ -0,0 +1,15 @@ +// +// Constants.m +// Chameleon +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import "ChameleonConstants.h" + +const UIStatusBarStyle UIStatusBarStyleContrast = 100; + +@implementation ChameleonConstants + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonEnums.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonEnums.h new file mode 100755 index 0000000..0a9fed3 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonEnums.h @@ -0,0 +1,39 @@ +// +// ChameleonEnums.h +// Chameleon +// +// Created by Vicc Alexander on 6/8/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#ifndef Chameleon_ChameleonEnums_h +#define Chameleon_ChameleonEnums_h + +/** + * Specifies how text-based UI elements and other content such as switch knobs, should be colored. + * + * @since 2.0 + */ + +typedef NS_ENUM(NSUInteger, UIContentStyle) { + /** + * Automatically chooses and colors text-based elements with the shade that best contrasts its @c backgroundColor. + * + * @since 2.0 + */ + UIContentStyleContrast, + /** + * Colors text-based elements using a light shade. + * + * @since 2.0 + */ + UIContentStyleLight, + /** + * Colors text-based elements using a light shade. + * + * @since 2.0 + */ + UIContentStyleDark +}; + +#endif diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonMacros.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonMacros.h new file mode 100755 index 0000000..237c579 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/ChameleonMacros.h @@ -0,0 +1,125 @@ + +// ChameleonMacros.h + +/* + + The MIT License (MIT) + + Copyright (c) 2014-2015 Vicc Alexander. + + 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. + + */ + +#import "UIColor+Chameleon.h" + +#pragma mark - Light Shades Shorthand + +#define FlatBlack [UIColor flatBlackColor] +#define FlatBlue [UIColor flatBlueColor] +#define FlatBrown [UIColor flatBrownColor] +#define FlatCoffee [UIColor flatCoffeeColor] +#define FlatForestGreen [UIColor flatForestGreenColor] +#define FlatGray [UIColor flatGrayColor] +#define FlatGreen [UIColor flatGreenColor] +#define FlatLime [UIColor flatLimeColor] +#define FlatMagenta [UIColor flatMagentaColor] +#define FlatMaroon [UIColor flatMaroonColor] +#define FlatMint [UIColor flatMintColor] +#define FlatNavyBlue [UIColor flatNavyBlueColor] +#define FlatOrange [UIColor flatOrangeColor] +#define FlatPink [UIColor flatPinkColor] +#define FlatPlum [UIColor flatPlumColor] +#define FlatPowderBlue [UIColor flatPowderBlueColor] +#define FlatPurple [UIColor flatPurpleColor] +#define FlatRed [UIColor flatRedColor] +#define FlatSand [UIColor flatSandColor] +#define FlatSkyBlue [UIColor flatSkyBlueColor] +#define FlatTeal [UIColor flatTealColor] +#define FlatWatermelon [UIColor flatWatermelonColor] +#define FlatWhite [UIColor flatWhiteColor] +#define FlatYellow [UIColor flatYellowColor] + +// --------------------------------------------------- + +#pragma mark - Dark Shades Shorthand + +#define FlatBlackDark [UIColor flatBlackColorDark] +#define FlatBlueDark [UIColor flatBlueColorDark] +#define FlatBrownDark [UIColor flatBrownColorDark] +#define FlatCoffeeDark [UIColor flatCoffeeColorDark] +#define FlatForestGreenDark [UIColor flatForestGreenColorDark] +#define FlatGrayDark [UIColor flatGrayColorDark] +#define FlatGreenDark [UIColor flatGreenColorDark] +#define FlatLimeDark [UIColor flatLimeColorDark] +#define FlatMagentaDark [UIColor flatMagentaColorDark] +#define FlatMaroonDark [UIColor flatMaroonColorDark] +#define FlatMintDark [UIColor flatMintColorDark] +#define FlatNavyBlueDark [UIColor flatNavyBlueColorDark] +#define FlatOrangeDark [UIColor flatOrangeColorDark] +#define FlatPinkDark [UIColor flatPinkColorDark] +#define FlatPlumDark [UIColor flatPlumColorDark] +#define FlatPowderBlueDark [UIColor flatPowderBlueColorDark] +#define FlatPurpleDark [UIColor flatPurpleColorDark] +#define FlatRedDark [UIColor flatRedColorDark] +#define FlatSandDark [UIColor flatSandColorDark] +#define FlatSkyBlueDark [UIColor flatSkyBlueColorDark] +#define FlatTealDark [UIColor flatTealColorDark] +#define FlatWatermelonDark [UIColor flatWatermelonColorDark] +#define FlatWhiteDark [UIColor flatWhiteColorDark] +#define FlatYellowDark [UIColor flatYellowColorDark] + +// --------------------------------------------------- + +#pragma mark - Special Colors Shorthand + +#define RandomFlatColor [UIColor randomFlatColor] +#define ClearColor [UIColor clearColor] + +// --------------------------------------------------- + +#pragma mark - UIColor Methods Shorthand + +#define AverageColorFromImage(image) [UIColor colorWithAverageColorFromImage:image] +#define AverageColorFromImageWithAlpha(image, alpha) [UIColor colorWithAverageColorFromImage:image withAlpha:alpha] + +#define ComplementaryFlatColor(color) [UIColor colorWithComplementaryFlatColorOf:color] +#define ComplementaryFlatColorWithAlpha(color, alpha) [UIColor colorWithComplementaryFlatColorOf:color withAlpha:alpha] + +#define ContrastColor(backgroundColor, returnFlat) [UIColor colorWithContrastingBlackOrWhiteColorOn:backgroundColor isFlat:returnFlat] +#define ContrastColorWithAlpha(backgroundColor, returnFlat, alpha) [UIColor colorWithContrastingBlackOrWhiteColorOn:backgroundColor isFlat:returnFlat alpha:alpha] + +#define GradientColor(gradientStyle, frame, colors) [UIColor colorWithGradientStyle:gradientStyle withFrame:frame andColors:colors] + +#define HexColor(hexString) [UIColor colorWithHexString:hexString] +#define HexColorWithAlpha(hexString, alpha) [UIColor colorWithHexString:hexString withAlpha:alpha] + +#define RandomFlatColorInArray(colors) [UIColor colorWithRandomColorInArray:colors] +#define RandomFlatColorExcluding(colors) [UIColor colorWithRandomFlatColorExcludingColorsInArray:colors]; +#define RandomFlatColorWithShade(shade) [UIColor colorWithRandomFlatColorOfShadeStyle:shade] +#define RandomFlatColorWithShadeAndAlpha(shade, alpha) [UIColor colorWithRandomFlatColorOfShadeStyle:shade withAlpha:alpha] + +// --------------------------------------------------- + +#pragma mark - NSArray Shorthand + +#define ColorsWithScheme(colorSchemeType, color, isFlatScheme) [NSArray arrayOfColorsWithColorScheme:colorSchemeType usingColor:color withFlatScheme:isFlatScheme] +#define ColorsFromImage(image, isFlatScheme) [NSArray arrayOfColorsFromImage:image withFlatScheme:isFlatScheme] + + diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/Chameleon_.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/Chameleon_.h new file mode 100755 index 0000000..d492a47 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/Chameleon_.h @@ -0,0 +1,66 @@ +// +// ChameleonInternal.h +// Chameleon +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import +#import + +#import "ChameleonConstants.h" +#import "ChameleonEnums.h" +#import "ChameleonMacros.h" + +#import "NSArray+Chameleon.h" +#import "UIColor+Chameleon.h" +#import "UINavigationController+Chameleon.h" +#import "UIViewController+Chameleon.h" + +@interface Chameleon : NSObject + +#pragma mark - Global Theming + +/** + * Set a global theme using a primary color and the specified content style. + * + * @param primaryColor The primary color to theme all controllers with. + * @param contentStyle The contentStyle. + * + * @note By default the secondary color will be a darker shade of the specified primary color. + * + * @since 2.0 + */ ++ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle; + +/** + * Set a global theme using a primary color, secondary color, and the specified content style. + * + * @param primaryColor The primary color to theme all controllers with. + * @param secondaryColor The secondary color to theme all controllers with. + * @param contentStyle The contentStyle. + * + * @since 2.0 + */ ++ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor + withSecondaryColor:(UIColor *)secondaryColor + andContentStyle:(UIContentStyle)contentStyle; + +/** + * Set a global theme using a primary color, secondary color, font name, and the specified content style. + * + * @param primaryColor The primary color to theme all controllers with. + * @param secondaryColor The secondary color to theme all controllers with. + * @param fontName The default font for all text-based UI elements. + * @param contentStyle The contentStyle. + * + * @since 2.0 + */ ++ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor + withSecondaryColor:(UIColor *)secondaryColor + usingFontName:(NSString *)fontName + andContentStyle:(UIContentStyle)contentStyle; + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/Chameleon_.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/Chameleon_.m new file mode 100755 index 0000000..4aab5a2 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/Chameleon_.m @@ -0,0 +1,793 @@ +// +// ChameleonInternal.m +// Chameleon +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import "Chameleon_.h" +#import "UILabel+Chameleon.h" +#import "UIButton+Chameleon.h" +#import "UIAppearance+Swift.h" + +@implementation Chameleon + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + ++ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + if (contentStyle == UIContentStyleContrast) { + + if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + } else { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + } else if (contentStyle == UIContentStyleLight) { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + + } else { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor contentStyle:contentStyle]; + [[self class] customizeButtonWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeNavigationBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeProgressViewWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSliderWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSwitchWithPrimaryColor:primaryColor]; + [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; + [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; +} + + ++ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor + withSecondaryColor:(UIColor *)secondaryColor + andContentStyle:(UIContentStyle)contentStyle { + + if (contentStyle == UIContentStyleContrast) { + + if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + } else { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + } else if (contentStyle == UIContentStyleLight) { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + + } else { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor contentStyle:contentStyle]; + [[self class] customizeButtonWithPrimaryColor:primaryColor secondaryColor:secondaryColor withContentStyle:contentStyle]; + [[self class] customizeNavigationBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; + [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; +} + ++ (void)setGlobalThemeUsingPrimaryColor:(UIColor *)primaryColor + withSecondaryColor:(UIColor *)secondaryColor + usingFontName:(NSString *)fontName + andContentStyle:(UIContentStyle)contentStyle { + + if (contentStyle == UIContentStyleContrast) { + + if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + } else { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + } else if (contentStyle == UIContentStyleLight) { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + + } else { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + [[UILabel appearance] setSubstituteFontName:fontName]; + [[UIButton appearance] setSubstituteFontName:fontName]; + + [[self class] customizeNavigationBarWithBarColor:primaryColor textColor:ContrastColor(primaryColor, YES) fontName:fontName fontSize:20 buttonColor:ContrastColor(primaryColor, YES)]; + [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor fontName:fontName fontSize:18 contentStyle:contentStyle]; + [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withFontName:fontName withFontSize:14 withContentStyle:contentStyle]; + [[self class] customizeButtonWithPrimaryColor:primaryColor secondaryColor:secondaryColor withContentStyle:contentStyle]; + [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; + [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + + /* + + if (contentStyle == UIContentStyleContrast) { + + if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + } else { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + } else if (contentStyle == UIContentStyleLight) { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + + } else { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor fontName:fontName fontSize:18 contentStyle:contentStyle]; + [[self class] customizeButtonWithPrimaryColor:primaryColor fontName:fontName fontSize:17 contentStyle:contentStyle]; + [[self class] customizeLabelWithPrimaryColor:primaryColor fontName:fontName fontSize:18 withContentStyle:contentStyle]; + [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeTabBarWithBarTintColor:FlatWhite tintColor:primaryColor fontName:fontName fontSize:11]; + [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + + */ +} + +#pragma mark - UIBarButtonItem + ++ (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor + contentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIBarButtonItem appearance] setTintColor:primaryColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; + + +} + ++ (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor + fontName:(NSString *)fontName + fontSize:(float)fontSize + contentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIBarButtonItem appearance] setTintColor:primaryColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; + + + if ([UIFont fontWithName:fontName size:fontSize]) { + [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{ NSForegroundColorAttributeName:contentColor, + NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize]} forState:UIControlStateNormal]; + } +} + +#pragma mark - UIButton + ++ (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIButton appearance] setTintColor:contentColor]; + [[UIButton appearance] setBackgroundColor:primaryColor]; + + [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setTintColor:primaryColor]; + [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; +} + ++ (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor + secondaryColor:(UIColor *)secondaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + UIColor *secondaryContentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + secondaryContentColor = ContrastColor(secondaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + secondaryContentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + secondaryContentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + secondaryContentColor = ContrastColor(secondaryColor, NO); + break; + } + } + + [[UIButton appearance] setTintColor:secondaryContentColor]; + [[UIButton appearance] setBackgroundColor:secondaryColor]; + + [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setTintColor:primaryColor]; + [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; +} + +#pragma mark - UIImagePickerController + ++ (void)customizeImagePickerControllerWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + //Workaround for Swift http://stackoverflow.com/a/28765193 + [[UIButton appearanceWhenContainedWithin:@[[UIView class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + [[UIButton appearanceWhenContainedWithin:@[[UIView class],[UIImagePickerController class]]] setTintColor:ClearColor]; + [[UIButton appearanceWhenContainedWithin:@[[UINavigationBar class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + [[UIButton appearanceWhenContainedWithin:@[[UINavigationBar class],[UIImagePickerController class]]] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedWithin:@[[UITableViewCell class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setTintColor:contentColor]; + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setTintColor:contentColor]; + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UITableViewCell class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; +} + + +#pragma mark - UILabel + ++ (void)customizeLabelWithPrimaryColor:(UIColor *)primaryColor + fontName:(NSString *)fontName + fontSize:(CGFloat)fontSize + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UILabel appearanceWhenContainedIn:[UINavigationBar class], nil] setTextColor:contentColor]; + [[UILabel appearanceWhenContainedIn:[UIToolbar class], nil] setTextColor:contentColor]; + + UIFont *font = [UIFont fontWithName:fontName size:fontSize]; + + if (font) { + [[UILabel appearance] setFont:[UIFont fontWithName:fontName size:fontSize]]; + [[UILabel appearanceWhenContainedIn:[UITextField class], nil] setFont:[UIFont fontWithName:fontName size:14]]; + [[UILabel appearanceWhenContainedIn:[UIButton class], nil] setFont:[UIFont fontWithName:fontName size:18]]; + } +} + +#pragma mark - UINavigationBar + ++ (void)customizeNavigationBarWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UINavigationBar appearance] setBarTintColor:primaryColor]; + [[UINavigationBar appearance] setTintColor:contentColor]; + [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:contentColor}]; + [[UINavigationBar appearance] setShadowImage:[UIImage new]]; + // [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; +} + ++ (void)customizeNavigationBarWithBarColor:(UIColor *)barColor + textColor:(UIColor *)textColor + buttonColor:(UIColor *)buttonColor { + + [[UINavigationBar appearance] setBarTintColor:barColor]; + [[UINavigationBar appearance] setTintColor:buttonColor]; + [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:textColor}]; + [[UINavigationBar appearance] setShadowImage:[UIImage new]]; + // [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; +} + ++ (void)customizeNavigationBarWithBarColor:(UIColor *)barColor + textColor:(UIColor *)textColor + fontName:(NSString *)fontName + fontSize:(CGFloat)fontSize + buttonColor:(UIColor *)buttonColor { + + [[UINavigationBar appearance] setBarTintColor:barColor]; + [[UINavigationBar appearance] setTintColor:buttonColor]; + [[UINavigationBar appearance] setShadowImage:[UIImage new]]; + // [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; + + if ([UIFont fontWithName:fontName size:fontSize]) { + [[UINavigationBar appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:textColor, NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize] }]; + } +} + +#pragma mark - UIPageControl + ++ (void)customizePageControlWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIPageControl appearance] setCurrentPageIndicatorTintColor:primaryColor]; + [[UIPageControl appearance] setPageIndicatorTintColor:[primaryColor colorWithAlphaComponent:0.4]]; + [[UIPageControl appearanceWhenContainedIn:[UINavigationBar class], nil] setCurrentPageIndicatorTintColor:contentColor]; + [[UIPageControl appearanceWhenContainedIn:[UINavigationBar class], nil] setPageIndicatorTintColor:[contentColor colorWithAlphaComponent:0.4]]; + [[UIPageControl appearanceWhenContainedIn:[UIToolbar class], nil] setCurrentPageIndicatorTintColor:contentColor]; + [[UIPageControl appearanceWhenContainedIn:[UIToolbar class], nil] setPageIndicatorTintColor:[contentColor colorWithAlphaComponent:0.4]]; +} + +#pragma mark - UIProgressView + ++ (void)customizeProgressViewWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIProgressView appearance] setProgressTintColor:primaryColor]; + [[UIProgressView appearanceWhenContainedIn:[UINavigationBar class], nil] setProgressTintColor:contentColor]; + [[UIProgressView appearanceWhenContainedIn:[UIToolbar class], nil] setProgressTintColor:contentColor]; + [[UIProgressView appearance] setTrackTintColor:[UIColor lightGrayColor]]; + [[UIProgressView appearanceWhenContainedIn:[UINavigationBar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UIProgressView appearanceWhenContainedIn:[UIToolbar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; +} + ++ (void)customizeProgressViewWithPrimaryColor:(UIColor *)primaryColor + andSecondaryColor:(UIColor *)secondaryColor { + + [[UIProgressView appearance] setProgressTintColor:secondaryColor]; + [[UIProgressView appearanceWhenContainedIn:[UINavigationBar class], nil] setProgressTintColor:secondaryColor]; + [[UIProgressView appearanceWhenContainedIn:[UIToolbar class], nil] setProgressTintColor:secondaryColor]; + [[UIProgressView appearance] setTrackTintColor:[UIColor lightGrayColor]]; + [[UIProgressView appearanceWhenContainedIn:[UINavigationBar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UIProgressView appearanceWhenContainedIn:[UIToolbar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; +} + +#pragma mark - UISearchBar + ++ (void)customizeSearchBarWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UISearchBar appearance] setBarTintColor:primaryColor]; + [[UISearchBar appearance] setBackgroundColor:primaryColor]; + [[UISearchBar appearance] setTintColor:contentColor]; + [[UISearchBar appearance] setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; +} + +#pragma mark - UISegmentedControl + ++ (void)customizeSegmentedControlWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UISegmentedControl appearance] setTintColor:primaryColor]; + [[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil] + setTintColor:contentColor]; + [[UISegmentedControl appearanceWhenContainedIn:[UIToolbar class], nil] + setTintColor:contentColor]; +} + ++ (void)customizeSegmentedControlWithPrimaryColor:(UIColor *)primaryColor + withFontName:(NSString *)fontName + withFontSize:(CGFloat)fontSize + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UISegmentedControl appearance] setTintColor:primaryColor]; + [[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil] + setTintColor:contentColor]; + [[UISegmentedControl appearanceWhenContainedIn:[UIToolbar class], nil] + setTintColor:contentColor]; + + UIFont *font = [UIFont fontWithName:fontName size:fontSize]; + if (font) { + [[UISegmentedControl appearance] setTitleTextAttributes:@{NSFontAttributeName:font} + forState:UIControlStateNormal]; + } +} + +#pragma mark - UISlider + ++ (void)customizeSliderWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UISlider appearance] setMinimumTrackTintColor:primaryColor]; + [[UISlider appearanceWhenContainedIn:[UINavigationBar class], nil] setMinimumTrackTintColor:contentColor]; + [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setMinimumTrackTintColor:contentColor]; + [[UISlider appearance] setMaximumTrackTintColor:[UIColor lightGrayColor]]; + [[UISlider appearanceWhenContainedIn:[UINavigationBar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + + [[UISlider appearance] setThumbTintColor:primaryColor]; + [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setThumbTintColor:contentColor]; +} + ++ (void)customizeSliderWithPrimaryColor:(UIColor *)primaryColor + andSecondaryColor:(UIColor *)secondaryColor { + + [[UISlider appearance] setMinimumTrackTintColor:secondaryColor]; + [[UISlider appearanceWhenContainedIn:[UINavigationBar class], nil] setMinimumTrackTintColor:secondaryColor]; + [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setMinimumTrackTintColor:secondaryColor]; + [[UISlider appearance] setMaximumTrackTintColor:[UIColor lightGrayColor]]; + [[UISlider appearanceWhenContainedIn:[UINavigationBar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + + [[UISlider appearance] setThumbTintColor:secondaryColor]; + [[UISlider appearanceWhenContainedIn:[UIToolbar class], nil] setThumbTintColor:ContrastColor(primaryColor, NO)]; +} + +#pragma mark - UIStepper + ++ (void)customizeStepperWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIStepper appearance] setTintColor:primaryColor]; + [[UIStepper appearanceWhenContainedIn:[UINavigationBar class], nil] + setTintColor:contentColor]; + [[UIStepper appearanceWhenContainedIn:[UIToolbar class], nil] + setTintColor:contentColor]; +} + +#pragma mark - UISwitch + ++ (void)customizeSwitchWithPrimaryColor:(UIColor *)primaryColor { + + [[UISwitch appearance] setOnTintColor:primaryColor]; + [[UISwitch appearanceWhenContainedIn:[UINavigationBar class], nil] setOnTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UISwitch appearanceWhenContainedIn:[UIToolbar class], nil] setOnTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; +} + ++ (void)customizeSwitchWithPrimaryColor:(UIColor *)primaryColor + andSecondaryColor:(UIColor *)secondaryColor { + + [[UISwitch appearance] setOnTintColor:secondaryColor]; + [[UISwitch appearanceWhenContainedIn:[UINavigationBar class], nil] setOnTintColor:secondaryColor]; + [[UISwitch appearanceWhenContainedIn:[UIToolbar class], nil] setOnTintColor:secondaryColor]; +} + +#pragma mark - UITabBar + ++ (void)customizeTabBarWithBarTintColor:(UIColor *)barTintColor + andTintColor:(UIColor *)tintColor { + + [[UITabBar appearance] setBarTintColor:barTintColor]; + [[UITabBar appearance] setTintColor:tintColor]; +} + ++ (void)customizeTabBarWithBarTintColor:(UIColor *)barTintColor + tintColor:(UIColor *)tintColor + fontName:(NSString *)fontName + fontSize:(CGFloat)fontSize { + + [[UITabBar appearance] setBarTintColor:barTintColor]; + [[UITabBar appearance] setTintColor:tintColor]; + + UIFont *font = [UIFont fontWithName:fontName size:fontSize]; + if (font) { + [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:font} + forState:UIControlStateNormal]; + } +} + +#pragma mark - UIToolbar + ++ (void)customizeToolbarWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIToolbar appearance] setTintColor:contentColor]; + [[UIToolbar appearance] setBarTintColor:primaryColor]; + [[UIToolbar appearance] setClipsToBounds:YES]; +} + +#pragma GCC diagnostic pop + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/NSArray+Chameleon.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/NSArray+Chameleon.h new file mode 100755 index 0000000..b74c664 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/NSArray+Chameleon.h @@ -0,0 +1,112 @@ + +// NSArray+Chameleon.h + +/* + + The MIT License (MIT) + + Copyright (c) 2014-2015 Vicc Alexander. + + 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. + + */ + +#import +#import + +#pragma mark - Enums + +/** + * Color schemes with which to select colors using a specified color. + * + * @since 1.0 + */ +typedef NS_ENUM(NSInteger, ColorScheme){ + /** + * Analogous color schemes use colors that are next to each other on the color wheel. They usually match well and create serene and comfortable designs. Analogous color schemes are often found in nature and are harmonious and pleasing to the eye. Make sure you have enough contrast when choosing an analogous color scheme. Choose one color to dominate, a second to support. The third color is used (along with black, white or gray) as an accent. + * + * @since 1.0 + */ + ColorSchemeAnalogous, + /** + * Colors that are opposite each other on the color wheel are considered to be complementary colors (example: red and green). The high contrast of complementary colors creates a vibrant look especially when used at full saturation. This color scheme must be managed well so it is not jarring. Complementary colors are tricky to use in large doses, but work well when you want something to stand out. Complementary colors are really bad for text. + * + * @since 1.0 + */ + ColorSchemeTriadic, + /** + * A triadic color scheme uses colors that are evenly spaced around the color wheel. Triadic color harmonies tend to be quite vibrant, even if you use pale or unsaturated versions of your hues. To use a triadic harmony successfully, the colors should be carefully balanced - let one color dominate and use the two others for accent. + * + * @since 1.0 + */ + ColorSchemeComplementary +}; + +@interface NSArray (Chameleon) + +#pragma mark - Generating Color Schemes + +/** + * Generates and creates an array of 5 color objects in the HSB colorspace from the specified color. + * + * @param colorScheme The color scheme with which to select colors using a specified color. + * @param color The specified color which the color scheme is built around. + * @param isFlatScheme Pass YES to return flat color objects. + * + * @return An array of 5 color objects in the HSB colorspace. + * + * @since 2.0 + */ ++ (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme + usingColor:(UIColor *)color + withFlatScheme:(BOOL)isFlatScheme; + +/** + * Generates and creates an array of 5 color objects in the HSB colorspace that appear most often in a specified image. + * + * @param image The specified image which the color scheme is built around. + * @param isFlatScheme Pass YES to return flat color objects. + * + * @return An array of 5 color objects in the HSB colorspace. + * + * @since 2.0 + */ ++ (NSArray *)arrayOfColorsFromImage:(UIImage *)image + withFlatScheme:(BOOL)isFlatScheme; + +#pragma mark - Deprecated Methods + +/** + * Generates and creates an array of 5 color objects in the HSB colorspace from the specified color. + * + * @param colorScheme The color scheme with which to select colors using a specified color. + * + * @param color The specified color which the color scheme is built around. + * + * @param isFlatScheme Pass YES to return flat color objects. + * + * @return An array of 5 color objects in the HSB colorspace. + * + * @since 1.1.2 + */ ++ (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme + with:(UIColor *)color + flatScheme:(BOOL)isFlatScheme __attribute((deprecated(" Use -arrayOfColorsWithColorScheme:usingColor:withFlatScheme: instead (First deprecated in Chameleon 2.0)."))); + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/NSArray+Chameleon.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/NSArray+Chameleon.m new file mode 100755 index 0000000..1e1dbe0 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/NSArray+Chameleon.m @@ -0,0 +1,736 @@ + +// NSArray+Chameleon.m + +/* + + The MIT License (MIT) + + Copyright (c) 2014-2015 Vicc Alexander. + + 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. + + */ + +#import "NSArray+Chameleon.h" +#import "ChameleonMacros.h" +#import "UIColor+ChameleonPrivate.h" +#import "UIImage+ChameleonPrivate.h" + +@interface ChameleonCountedColor : NSObject + +@property (assign) NSUInteger count; +@property (strong) UIColor *color; + +- (id)initWithColor:(UIColor *)color count:(NSUInteger)count; + +@end + +@implementation NSArray (Chameleon) + +#pragma mark - Deprecated 2.0 + ++ (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme with:(UIColor *)color flatScheme:(BOOL)isFlatScheme { + + //Extract HSB values from input color + CGFloat h, s, b, a; + [color getHue:&h saturation:&s brightness:&b alpha:&a]; + + //Multiply our values by the max value to convert + h *= 360; + s *= 100; + b *= 100; + + //Choose Between Schemes + switch (colorScheme) { + case ColorSchemeAnalogous: + return [self analogousColorSchemeFromHue:h Saturation:s Brightness:b flat:isFlatScheme]; + case ColorSchemeComplementary: + return [self complementaryColorSchemeFromHue:h Saturation:s Brightness:b flat:isFlatScheme]; + case ColorSchemeTriadic: + return [self triadicColorSchemeFromHue:h Saturation:s Brightness:b flat:isFlatScheme]; + default: + NSAssert(0, @"Oops! Unrecognized color scheme provided as random color."); + } +} + +#pragma mark - Chameleon - Public Color Scheme Methods + ++ (NSArray *)arrayOfColorsWithColorScheme:(ColorScheme)colorScheme usingColor:(UIColor *)color withFlatScheme:(BOOL)isFlatScheme { + + //Extract HSB values from input color + CGFloat h, s, b, a; + [color getHue:&h saturation:&s brightness:&b alpha:&a]; + + //Multiply our values by the max value to convert + h *= 360; + s *= 100; + b *= 100; + + //Choose Between Schemes + switch (colorScheme) { + case ColorSchemeAnalogous: + if (isFlatScheme) return [self analogousColorSchemeFromHue:h Saturation:s Brightness:b flat:YES]; + else return [self analogousColorSchemeFromHue:h Saturation:s Brightness:b flat:NO]; + case ColorSchemeComplementary: + if (isFlatScheme) return [self complementaryColorSchemeFromHue:h Saturation:s Brightness:b flat:YES]; + else return [self complementaryColorSchemeFromHue:h Saturation:s Brightness:b flat:NO]; + case ColorSchemeTriadic: + if (isFlatScheme) return [self triadicColorSchemeFromHue:h Saturation:s Brightness:b flat:YES]; + else return [self triadicColorSchemeFromHue:h Saturation:s Brightness:b flat:NO]; + default: + NSAssert(0, @"Oops! Unrecognized color scheme provided as random color."); + } +} + ++ (NSArray *)arrayOfColorsFromImage:(UIImage *)image withFlatScheme:(BOOL)isFlatScheme { + + //Quick return in case we don't have an image + if (!image) { + + //Make sure we return some colors to prevent exception + NSMutableArray *emptyColors = [NSMutableArray array]; + while (emptyColors.count < 5) { + [emptyColors addObject:[UIColor whiteColor]]; + } + + return emptyColors; + } + + //Scale image + UIImage *scaledImage = [UIImage imageWithImage:image scaledToSize:CGSizeMake(image.size.width/8, image.size.height/8)]; + NSMutableArray *finalColors = [NSMutableArray array]; + + //Find colors in image ********************************* + + //Get dimensions of image in pixels + size_t width = CGImageGetWidth(scaledImage.CGImage); + size_t height = CGImageGetHeight(scaledImage.CGImage); + + //Initialize a counted set with the correct capacity + NSCountedSet *imageColors = [[NSCountedSet alloc] initWithCapacity:(width * height)]; + + //Loop through each column + for (NSUInteger x = 0; x < width; x++) { + + //Loop through each row + for (NSUInteger y = 0; y < height; y++) { + + //Get color at a specific point + UIColor *color = [UIColor colorFromImage:scaledImage atPoint:CGPointMake(x, y)]; + + //Add color to our list of all pixel colors + [imageColors addObject:color]; + } + } + + //Setup up an enumerator object + NSEnumerator *enumerator = [imageColors objectEnumerator]; + UIColor *currentColor; + NSMutableArray *sortedColors = [NSMutableArray arrayWithCapacity:imageColors.count]; + NSMutableArray *resultColors = [NSMutableArray array]; + + //Enumerate through each object once + while ((currentColor = [enumerator nextObject]) != nil) { + + //Set a minimum allowed saturation + currentColor = [currentColor colorWithMinimumSaturation:0.15f]; + + //Get color count + NSUInteger colorCount = [imageColors countForObject:currentColor]; + + //Add them to our sortedColors array + [sortedColors addObject:[[ChameleonCountedColor alloc] initWithColor:currentColor count:colorCount]]; + } + + //Sort Colors + [sortedColors sortUsingSelector:@selector(compare:)]; + + //Loop through our sorted colors + for (ChameleonCountedColor *countedColor in sortedColors) { + + //Define our current color + currentColor = countedColor.color; + + //Setup a flag to see if we should continue counting + BOOL continueFlag = NO; + + //Loop through our colors + for (UIColor *otherColor in resultColors) { + + //If our current color differs from our last, break the loop + if (![currentColor isDistinct:otherColor]) { + continueFlag = YES; + break; + } + } + + //Continue + if (continueFlag) { + continue; + } + + //If we can still add more colors, do so + if (resultColors.count < 5) { + + //Check if we should flatten our color + if (isFlatScheme) { + [resultColors addObject:[currentColor flatten]]; + } else { + [resultColors addObject:currentColor]; + } + + } else { + break; + } + + } + + //Get colors from image + [finalColors addObjectsFromArray:[NSArray arrayWithArray:resultColors]]; + + // ***************************************************** + + //Make sure we add white colors in case we're missing colors + while (finalColors.count < 5) { + [finalColors addObject:[UIColor whiteColor]]; + } + + //Return array of colors + return [NSArray arrayWithArray:finalColors]; +} + +- (NSArray *)findColorsOfImage:(UIImage *)image imageColors:(NSCountedSet * __autoreleasing *)colors { + + //Get dimensions of image in pixels + size_t width = CGImageGetWidth(image.CGImage); + size_t height = CGImageGetHeight(image.CGImage); + + //Initialize a counted set with the correct capacity + NSCountedSet *imageColors = [[NSCountedSet alloc] initWithCapacity:(width * height)]; + + //Loop through each column + for (NSUInteger x = 0; x < width; x++) { + + //Loop through each row + for (NSUInteger y = 0; y < height; y++) { + + //Get color at a specific point + UIColor *color = [UIColor colorFromImage:image atPoint:CGPointMake(x, y)]; + + //Add color to our list of all pixel colors + [imageColors addObject:color]; + } + } + + //Assign imageColors to colors + *colors = imageColors; + + //Setup up an enumerator object + NSEnumerator *enumerator = [imageColors objectEnumerator]; + UIColor *currentColor; + NSMutableArray *sortedColors = [NSMutableArray arrayWithCapacity:imageColors.count]; + NSMutableArray *resultColors = [NSMutableArray array]; + + //Enumerate through each object once + while ((currentColor = [enumerator nextObject]) != nil) { + + //Set a minimum allowed saturation + currentColor = [currentColor colorWithMinimumSaturation:0.15f]; + + //Get color count + NSUInteger colorCount = [imageColors countForObject:currentColor]; + + //Add them to our sortedColors array + [sortedColors addObject:[[ChameleonCountedColor alloc] initWithColor:currentColor count:colorCount]]; + } + + //Sort Colors + [sortedColors sortUsingSelector:@selector(compare:)]; + + //Loop through our sorted colors + for (ChameleonCountedColor *countedColor in sortedColors) { + + //Define our current color + currentColor = countedColor.color; + + //Setup a flag to see if we should continue counting + BOOL continueFlag = NO; + + //Loop through our colors + for (UIColor *c in resultColors) { + + //If our current color differs from our last, break the loop + if (![currentColor isDistinct:c]) { + continueFlag = YES; + break; + } + } + + //Continue + if (continueFlag) { + continue; + } + + //If we can still add more colors, do so + if (resultColors.count < self.count) { + + [resultColors addObject:currentColor]; + + } else { + break; + } + + } + + //Return our colors + return [NSArray arrayWithArray:resultColors]; +} + + +#pragma mark - Chameleon - Internal Color Scheme Methods + +//Creates an array with 2 analagous colors on each side of the predefined color ++ (NSArray *)analogousColorSchemeFromHue:(CGFloat)h Saturation:(CGFloat)s Brightness:(CGFloat)b flat:(BOOL)isFlat { + + UIColor *firstColor = [UIColor colorWithHue:([[self class] add:-32 to:h])/360 + saturation:(s+5)/100 + brightness:(b+5)/100 + alpha:1.0]; + + UIColor *secondColor = [UIColor colorWithHue:[[self class] add:-16 to:h]/360 + saturation:(s+5)/100 + brightness:(b+9)/100 + alpha:1.0]; + + UIColor *thirdColor = [UIColor colorWithHue:h/360 + saturation:s/100 + brightness:b/100 + alpha:1.0]; + + UIColor *fourthColor = [UIColor colorWithHue:[[self class] add:16 to:h]/360 + saturation:(s+5)/100 + brightness:(b+9)/100 + alpha:1.0]; + + UIColor *fifthColor = [UIColor colorWithHue:[[self class] add:32 to:h]/360 + saturation:(s+5)/100 + brightness:(b+5)/100 + alpha:1.0]; + + if (isFlat) { + + //Flatten colors + firstColor = [firstColor flatten]; + secondColor = [secondColor flatten]; + thirdColor = [thirdColor flatten]; + fourthColor = [fourthColor flatten]; + fifthColor = [fifthColor flatten]; + + //Make sure returned colors are unique + + //Inner Colors + if ([secondColor isEqual:thirdColor]) { + + secondColor = [[UIColor colorWithHue:[[self class] add:-48 to:h]/360 + saturation:(s+5)/100 + brightness:(b+9)/100 + alpha:1.0] flatten]; + } + + if ([thirdColor isEqual:fourthColor]) { + + fourthColor = [[UIColor colorWithHue:[[self class] add:32 to:h]/360 + saturation:(s+5)/100 + brightness:(b+9)/100 + alpha:1.0] flatten]; + } + + //Outer Colors + + if ([firstColor isEqual:secondColor]) { + + firstColor = [[UIColor colorWithHue:[[self class] add:-64 to:h]/360 + saturation:(s+5)/100 + brightness:(b+9)/100 + alpha:1.0] flatten]; + } + + if ([firstColor isEqual:thirdColor]) { + + firstColor = [[UIColor colorWithHue:[[self class] add:-96 to:h]/360 + saturation:(s+5)/100 + brightness:(b+9)/100 + alpha:1.0] darkenByPercentage:0.25]; + } + + if ([fourthColor isEqual:fifthColor]) { + fifthColor = [[UIColor colorWithHue:[[self class] add:64 to:h]/360 + saturation:(s+5)/100 + brightness:(b+9)/100 + alpha:1.0] flatten]; + } + + if ([thirdColor isEqual:fifthColor]) { + fifthColor = [[UIColor colorWithHue:[[self class] add:96 to:h]/360 + saturation:(s+5)/100 + brightness:(b+9)/100 + alpha:1.0] flatten]; + } + + } + + return @[firstColor, secondColor, thirdColor, fourthColor, fifthColor]; +} + +// Creates an array of 5 colors, both 90 degrees and 180 degrees away from the predefined colors on both sides ++ (NSArray *)complementaryColorSchemeFromHue:(CGFloat)h Saturation:(CGFloat)s Brightness:(CGFloat)b flat:(BOOL)isFlat { + + UIColor *firstColor = [UIColor colorWithHue:h/360 + saturation:(s+5)/100 + brightness:(b-30)/100 + alpha:1.0]; + + UIColor *secondColor = [UIColor colorWithHue:h/360 + saturation:(s-10)/100 + brightness:(b+9)/100 + alpha:1.0]; + + UIColor *thirdColor = [UIColor colorWithHue:h/360 + saturation:s/100 + brightness:b/100 + alpha:1.0]; + + UIColor *fourthColor = [UIColor colorWithHue:[[self class] add:180 to:h]/360 + saturation:s/100 + brightness:b/100 + alpha:1.0]; + + UIColor *fifthColor = [UIColor colorWithHue:[[self class] add:180 to:h]/360 + saturation:(s+20)/100 + brightness:(b-30)/100 + alpha:1.0]; + + + if (isFlat) { + + //Flatten colors + firstColor = [firstColor flatten]; + secondColor = [secondColor flatten]; + thirdColor = [thirdColor flatten]; + fourthColor = [fourthColor flatten]; + fifthColor = [fifthColor flatten]; + + //Make sure returned colors are unique + + //Inner Colors + if ([secondColor isEqual:thirdColor]) { + secondColor = [[secondColor darkenByPercentage:0.25] flatten]; + } + + if ([thirdColor isEqual:fourthColor]) { + fourthColor = [[fourthColor darkenByPercentage:0.25] flatten]; + } + + if ([firstColor isEqual:thirdColor]) { + firstColor = [[firstColor darkenByPercentage:0.25] flatten]; + } + + if ([fifthColor isEqual:thirdColor]) { + fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; + } + + //Outer Colors + + if ([firstColor isEqual:secondColor]) { + firstColor = [[firstColor darkenByPercentage:0.25] flatten]; + } + + + if ([fourthColor isEqual:fifthColor]) { + fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; + } + + } + + return @[firstColor, secondColor, thirdColor, fourthColor, fifthColor]; + +} + +// Creates an array of 5 colors, both 120 degrees and 240 degrees away from the predefined colors on both sides ++ (NSArray *)triadicColorSchemeFromHue:(CGFloat)h Saturation:(CGFloat)s Brightness:(CGFloat)b flat:(BOOL)isFlat { + + UIColor *firstColor = [UIColor colorWithHue:[[self class] add:120 to:h]/360 + saturation:(7*s/6)/100 + brightness:(b-5)/100 + alpha:1.0]; + + UIColor *secondColor = [UIColor colorWithHue:[[self class] add:120 to:h]/360 + saturation:s/100 + brightness:(b+9)/100 + alpha:1.0]; + + UIColor *thirdColor = [UIColor colorWithHue:h/360 + saturation:s/100 + brightness:b/100 + alpha:1.0]; + + UIColor *fourthColor = [UIColor colorWithHue:[[self class] add:240 to:h]/360 + saturation:(7*s/6)/100 + brightness:(b-5)/100 + alpha:1.0]; + + UIColor *fifthColor = [UIColor colorWithHue:[[self class] add:240 to:h]/360 + saturation:s/100 + brightness:(b-30)/100 + alpha:1.0]; + + if (isFlat) { + + //Flatten colors + firstColor = [firstColor flatten]; + secondColor = [secondColor flatten]; + thirdColor = [thirdColor flatten]; + fourthColor = [fourthColor flatten]; + fifthColor = [fifthColor flatten]; + + //Make sure returned colors are unique + + //Inner Colors + if ([secondColor isEqual:thirdColor]) { + secondColor = [[secondColor darkenByPercentage:0.25] flatten]; + } + + if ([thirdColor isEqual:fourthColor]) { + fourthColor = [[fourthColor darkenByPercentage:0.25] flatten]; + } + + if ([firstColor isEqual:thirdColor]) { + firstColor = [[firstColor darkenByPercentage:0.25] flatten]; + } + + if ([fifthColor isEqual:thirdColor]) { + fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; + } + + //Outer Colors + + if ([firstColor isEqual:secondColor]) { + firstColor = [[firstColor darkenByPercentage:0.25] flatten]; + } + + + if ([fourthColor isEqual:fifthColor]) { + fifthColor = [[fifthColor darkenByPercentage:0.25] flatten]; + } + + } + + return @[firstColor, secondColor, thirdColor, fourthColor, fifthColor]; +} + +#pragma mark - Helper Methods for Color Schemes + ++ (float)add:(float)newValue to:(float)currentValue { + + currentValue += newValue; + + //Check if currentValue exceeds 360 degrees + if (currentValue > 360) { + float offset = currentValue - 360; + return offset; + } + + else if (currentValue < 0) { + return -1 * currentValue; + } + + else { + return currentValue; + } +} + ++ (UIColor *)colorWithFlatVersionOf:(UIColor *)color { + + //Create CGFloats to hold our color values + CGFloat L, A, B, alpha; + + //Get LAB values for our color + [color getLightness:&L valueForA:&A valueForB:&B alpha:&alpha]; + + //Find the nearest flat color + return [self nearestFlatColorForL:L A:A B:B alpha:1.0]; +} + +//Array of all our colors ++ (NSArray *)flatColors { + + return @[FlatBlack, FlatBlackDark, FlatBlue, FlatBlueDark, FlatBrown, FlatBrownDark, FlatCoffee, FlatCoffeeDark, FlatForestGreen, FlatForestGreenDark, FlatGray, FlatGrayDark, FlatGreen, FlatGreenDark, FlatLime, FlatLimeDark, FlatMagenta, FlatMagentaDark, FlatMaroon, FlatMaroonDark, FlatMint, FlatMintDark, FlatNavyBlue, FlatNavyBlueDark, FlatOrange, FlatOrangeDark, FlatPink, FlatPinkDark, FlatPlum, FlatPlumDark, FlatPowderBlue, FlatPowderBlueDark, FlatPurple, FlatPurpleDark, FlatRed, FlatRedDark, FlatSand, FlatSandDark, FlatSkyBlue, FlatSkyBlueDark, FlatTeal, FlatTealDark, FlatWatermelon, FlatWatermelonDark, FlatWhite, FlatWhiteDark, FlatYellow, FlatYellowDark]; +} + +//Calculate the total sum of differences - Euclidian distance +//Chameleon is now using the CIEDE2000 formula to calculate distances between 2 colors. +//More info: http://en.wikipedia.org/wiki/Color_difference ++ (float)totalSumOfDifferencesFroml1:(CGFloat)L1 l2:(CGFloat)L2 a1:(CGFloat)A1 + a2:(CGFloat)A2 b1:(CGFloat)B1 b2:(CGFloat)B2 { + + //Get C Values in LCH from LAB Values + CGFloat C1 = sqrt(pow(A1, 2) + pow(B1, 2)); + CGFloat C2 = sqrt(pow(A2, 2) + pow(B2, 2)); + + //CIE Weights + CGFloat KL = 1; + CGFloat KC = 1; + CGFloat KH = 1; + + //Variables specifically set for CIE:2000 + CGFloat DeltaPrimeL = L2 - L1; + CGFloat MeanL = ((L1 + L2) / 2); + CGFloat MeanC = ((C1 + C2) / 2); + CGFloat A1Prime = A1 + A1 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); + CGFloat A2Prime = A2 + A2 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); + CGFloat C1Prime = sqrt(pow(A1Prime, 2) + pow(B1, 2)); + CGFloat C2Prime = sqrt(pow(A2Prime, 2) + pow(B2, 2)); + CGFloat DeltaPrimeC = C1Prime - C2Prime; + CGFloat DeltaC = C1 - C2; + CGFloat MeanCPrime = (C1Prime + C2Prime) / 2; + CGFloat H1Prime = fmodf(atan2(B1, A1Prime), (360.0 * M_PI/180)); + CGFloat H2Prime = fmodf(atan2(B2, A2Prime), (360.0 * M_PI/180)); + + //Run everything through our △H' Function + CGFloat hDeltaPrime = 0; + if (fabs(H1Prime - H2Prime) <= (180.0 * M_PI/180)) { + + hDeltaPrime = H2Prime - H1Prime; + + } else if (H2Prime <= H1Prime) { + + hDeltaPrime = (H2Prime - H1Prime) + ((360.0 * M_PI/180)); + + } else { + + hDeltaPrime = (H2Prime - H1Prime) - ((360.0 * M_PI/180)); + } + + CGFloat deltaHPrime = 2 * (sqrt(C1Prime*C2Prime)) * sin(hDeltaPrime/2); + + //Get Mean H' Value + CGFloat MeanHPrime = 0; + if (fabs(H1Prime-H2Prime) > (180.0 * M_PI/180)) { + + MeanHPrime = (H1Prime + H2Prime + (360.0 * M_PI/180)) / 2; + + } else { + + MeanHPrime = (H1Prime + H2Prime) / 2; + } + + CGFloat T = 1 - 0.17 * cos(MeanHPrime - (30.0 * M_PI/180)) + 0.24 * cos(2 * MeanHPrime)+0.32 * cos(3 * MeanHPrime + (6.0 * M_PI/180)) - 0.20 * cos(4 * MeanHPrime - (63.0 * M_PI/180)); + + CGFloat SL = 1 + (0.015 * pow((MeanL - 50), 2))/sqrt(20 + pow((MeanL - 50), 2)); + CGFloat SC = 1 + 0.045 * MeanCPrime; + CGFloat SH = 1 + 0.015 * MeanCPrime * T; + + CGFloat RT = -2 * sqrt(pow(MeanCPrime, 7) / (pow(MeanCPrime, 7) + pow(25.0, 7))) * sin((60.0 * M_PI/180)* exp(-1 * pow((MeanCPrime - (275.0 * M_PI/180)) / (25.0 * M_PI/180), 2))); + + + //Get total difference + CGFloat TotalDifference = sqrt(pow((DeltaPrimeL / (KL * SL)), 2) + pow((DeltaPrimeC / (KC * SC)), 2) + pow((deltaHPrime / (KH * SH)), 2) + RT * (DeltaC / (KC * SC)) * (deltaHPrime / (KH * SH))); + + return TotalDifference; +} + ++ (UIColor *)nearestFlatColorForL:(CGFloat)l1 A:(CGFloat)a1 B:(CGFloat)b1 alpha:(CGFloat)alpha{ + + //Keep track of our index + int index = 0; + + //Start with a random big number to make sure the first comparison gets saved. + float smallestDistance = 1000000; + float previousDistance = 1000000; + float currentDistance; + + //Our values + CGFloat l2, a2, b2; + + //We're interested in the color with values returning the smallest sum of total differences so we need to cross reference our input color's values with every flat color's values + for (int i=0; i<[[self flatColors] count]; i++ ) { + + //Check that index is not zero + if (i!=0 ) { + //Extract LAB values from colors in array and store it as the previous index + [[self flatColors][i - 1] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; + + previousDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 + a1:a1 a2:a2 + b1:b1 b2:b2]; + } + + //Extract LAB values from colors in array and store it as the current index + [[self flatColors][i] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; + + currentDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 + a1:a1 a2:a2 + b1:b1 b2:b2]; + + //We're only interested in the smallest difference + if (currentDistance < previousDistance) { + if (currentDistance < smallestDistance) { + smallestDistance = currentDistance; + index = i; + } + } + } + + + //Collect the RGB Values of the color where the smallest difference was found + CGFloat red, green, blue; + [[self flatColors][index] getRed:&red green:&green blue:&blue alpha:nil]; + + //Return the closest flat color + return rgba(red*255, green*255, blue*255, alpha); +} + +@end + +@implementation ChameleonCountedColor + +- (id)initWithColor:(UIColor *)color count:(NSUInteger)count { + + if ((self = [super init])) { + self.color = color; + self.count = count; + } + + return self; +} + +- (NSComparisonResult)compare:(ChameleonCountedColor *)object { + + if ([object isKindOfClass:[ChameleonCountedColor class]]) { + if (self.count < object.count) + return NSOrderedDescending; + else if (self.count == object.count) + return NSOrderedSame; + } + + return NSOrderedAscending; +} + + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIAppearance+Swift.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIAppearance+Swift.h new file mode 100755 index 0000000..2d43ceb --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIAppearance+Swift.h @@ -0,0 +1,17 @@ +// +// UIAppearance+Swift.h +// Chameleon +// +// Created by Vicc Alexander on 11/26/15. +// Copyright © 2015 Vicc Alexander. All rights reserved. +// + +#import + +@interface UIView (UIViewAppearance_Swift) + +// @param containers An array of Class < UIAppearanceContainer > +// http://stackoverflow.com/a/28765193 ++ (instancetype)appearanceWhenContainedWithin:(NSArray *)containers; + +@end \ No newline at end of file diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIAppearance+Swift.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIAppearance+Swift.m new file mode 100755 index 0000000..d0854a1 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIAppearance+Swift.m @@ -0,0 +1,32 @@ +// +// UIAppearance+Swift.m +// Chameleon +// +// Created by Vicc Alexander on 11/26/15. +// Copyright © 2015 Vicc Alexander. All rights reserved. +// + +#import "UIAppearance+Swift.h" + +@implementation UIView (UIViewAppearance_Swift) + ++ (instancetype)appearanceWhenContainedWithin: (NSArray *)containers { + + NSUInteger count = containers.count; + NSAssert(count <= 10, @"The count of containers greater than 10 is not supported."); + + return [self appearanceWhenContainedIn: + count > 0 ? containers[0] : nil, + count > 1 ? containers[1] : nil, + count > 2 ? containers[2] : nil, + count > 3 ? containers[3] : nil, + count > 4 ? containers[4] : nil, + count > 5 ? containers[5] : nil, + count > 6 ? containers[6] : nil, + count > 7 ? containers[7] : nil, + count > 8 ? containers[8] : nil, + count > 9 ? containers[9] : nil, + nil]; +} + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIButton+Chameleon.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIButton+Chameleon.h new file mode 100755 index 0000000..c0fecea --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIButton+Chameleon.h @@ -0,0 +1,15 @@ +// +// UIButton+Chameleon.h +// Chameleon +// +// Created by Vicc Alexander on 9/20/15. +// Copyright © 2015 Vicc Alexander. All rights reserved. +// + +#import + +@interface UIButton (Chameleon) + +- (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR; + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIButton+Chameleon.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIButton+Chameleon.m new file mode 100755 index 0000000..a1e896f --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIButton+Chameleon.m @@ -0,0 +1,23 @@ +// +// UIButton+Chameleon.m +// Chameleon +// +// Created by Vicc Alexander on 9/20/15. +// Copyright © 2015 Vicc Alexander. All rights reserved. +// + +#import "UIButton+Chameleon.h" + +@implementation UIButton (Chameleon) + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +- (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR { + + self.font = [UIFont fontWithName:name size:self.font.pointSize]; +} + +#pragma GCC diagnostic pop + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+Chameleon.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+Chameleon.h new file mode 100755 index 0000000..22d9b7c --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+Chameleon.h @@ -0,0 +1,685 @@ + +// UIColor+Chameleon.h + +/* + + The MIT License (MIT) + + Copyright (c) 2014-2015 Vicc Alexander. + + 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. + + */ + +#import +#import + +#pragma mark - Enums + +/** + * Defines the gradient style and direction of the gradient color. + * + * @since 1.0 + */ +typedef NS_ENUM (NSUInteger, UIGradientStyle) { + /** + * Returns a gradual blend between colors originating at the leftmost point of an object's frame, and ending at the rightmost point of the object's frame. + * + * @since 1.0 + */ + UIGradientStyleLeftToRight, + /** + * Returns a gradual blend between colors originating at the center of an object's frame, and ending at all edges of the object's frame. NOTE: Supports a Maximum of 2 Colors. + * + * @since 1.0 + */ + UIGradientStyleRadial, + /** + * Returns a gradual blend between colors originating at the topmost point of an object's frame, and ending at the bottommost point of the object's frame. + * + * @since 1.0 + */ + UIGradientStyleTopToBottom +}; + +/** + * Defines the shade of a any flat color. + * + * @since 1.0 + */ +typedef NS_ENUM (NSInteger, UIShadeStyle) { + /** + * Returns the light shade version of a flat color. + * + * @since 1.0 + */ + UIShadeStyleLight, + /** + * Returns the dark shade version of a flat color. + * + * @since 1.0 + */ + UIShadeStyleDark +}; + + +@interface UIColor (Chameleon) + +#pragma mark - Instance Variables + +/** + * Stores an object's UIColor image if the UIColor was created using colorWithPatternImage. + * + * @since 1.0 + */ + +@property (nonatomic, strong) UIImage *gradientImage; + +#pragma mark - Quick Shorthand Macros + +// Quick & Easy Shorthand for RGB x HSB Colors +// The reason we don't import our Macro file is to prevent naming conflicts. +#define rgba(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a] +#define rgb(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0] +#define hsba(h,s,b,a) [UIColor colorWithHue:h/360.0f saturation:s/100.0f brightness:b/100.0f alpha:a] +#define hsb(h,s,b) [UIColor colorWithHue:h/360.0f saturation:s/100.0f brightness:b/100.0f alpha:1.0] + +#pragma mark - Light Shades + +/** + * Returns a flat color object whose HSB values are 0.0, 0.0, 0.17 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatBlackColor; + +/** + * Returns a flat color object whose HSB values are 0.62, 0.50, 0.63 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatBlueColor; + +/** + * Returns a flat color object whose HSB values are 0.07, 0.45, 0.37 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatBrownColor; + +/** + * Returns a flat color object whose HSB values are 0.07, 0.31, 0.64 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatCoffeeColor; + +/** + * Returns a flat color object whose HSB values are 0.38, 0.45, 0.37 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatForestGreenColor; + +/** + * Returns a flat color object whose HSB values are 0.51, 0.10, 0.65 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatGrayColor; + +/** + * Returns a flat color object whose HSB values are 0.40, 0.77, 0.80 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatGreenColor; + +/** + * Returns a flat color object whose HSB values are 0.21, 0.70, 0.78 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatLimeColor; + +/** + * Returns a flat color object whose HSB values are 0.79, 0.51, 0.71 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatMagentaColor; + +/** + * Returns a flat color object whose HSB values are 0.01, 0.65, 0.47 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatMaroonColor; + +/** + * Returns a flat color object whose HSB values are 0.47, 0.86, 0.74 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatMintColor; + +/** + * Returns a flat color object whose HSB values are 0.58, 0.45, 0.37 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatNavyBlueColor; + +/** + * Returns a flat color object whose HSB values are 0.08, 0.85, 0.90 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatOrangeColor; + +/** + * Returns a flat color object whose HSB values are 0.90, 0.49, 0.96 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatPinkColor; + +/** + * Returns a flat color object whose HSB values are 0.83, 0.45, 0.37 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatPlumColor; + +/** + * Returns a flat color object whose HSB values are 0.62, 0.24, 0.95 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatPowderBlueColor; + +/** + * Returns a flat color object whose HSB values are 0.70, 0.52, 0.77 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatPurpleColor; + +/** + * Returns a flat color object whose HSB values are 0.02, 0.74, 0.91 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatRedColor; + +/** + * Returns a flat color object whose HSB values are 0.12, 0.25, 0.94 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatSandColor; + +/** + * Returns a flat color object whose HSB values are 0.57, 0.76, 0.86 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatSkyBlueColor; + +/** + * Returns a flat color object whose HSB values are 0.54, 0.55, 0.51 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatTealColor; + +/** + * Returns a flat color object whose HSB values are 0.99, 0.53, 0.94 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatWatermelonColor; + +/** + * Returns a flat color object whose HSB values are 0.53, 0.02, 0.95 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatWhiteColor; + +/** + * Returns a flat color object whose HSB values are 0.13, 0.99, 1.00 and whose alpha value is 1.0. + * + * @return A flat UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatYellowColor; + +#pragma mark - Dark Shades + +/** + * Returns a flat color object whose HSB values are 0.00, 0.00, 0.15 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatBlackColorDark; + +/** + * Returns a flat color object whose HSB values are 0.62, 0.56, 0.51 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatBlueColorDark; + +/** + * Returns a flat color object whose HSB values are 0.07, 0.45, 0.31 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatBrownColorDark; + +/** + * Returns a flat color object whose HSB values are 0.07, 0.34, 0.56 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatCoffeeColorDark; + +/** + * Returns a flat color object whose HSB values are 0.38, 0.44, 0.31 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatForestGreenColorDark; + +/** + * Returns a flat color object whose HSB values are 0.51, 0.10, 0.55 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatGrayColorDark; + +/** + * Returns a flat color object whose HSB values are 0.40, 0.78, 0.68 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatGreenColorDark; + +/** + * Returns a flat color object whose HSB values are 0.21, 0.81, 0.69 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatLimeColorDark; + +/** + * Returns a flat color object whose HSB values are 0.78, 0.61, 0.68 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatMagentaColorDark; + +/** + * Returns a flat color object whose HSB values are 0.01, 0.68, 0.40 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatMaroonColorDark; + +/** + * Returns a flat color object whose HSB values are 0.47, 0.86, 0.63 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatMintColorDark; + +/** + * Returns a flat color object whose HSB values are 0.58, 0.45, 0.31 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatNavyBlueColorDark; + +/** + * Returns a flat color object whose HSB values are 0.07, 1.00, 0.83 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatOrangeColorDark; + +/** + * Returns a flat color object whose HSB values are 0.91, 0.57, 0.83 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatPinkColorDark; + +/** + * Returns a flat color object whose HSB values are 0.83, 0.46, 0.31 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatPlumColorDark; + +/** + * Returns a flat color object whose HSB values are 0.62, 0.28, 0.84 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatPowderBlueColorDark; + +/** + * Returns a flat color object whose HSB values are 0.70, 0.56, 0.64 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatPurpleColorDark; + +/** + * Returns a flat color object whose HSB values are 0.02, 0.78, 0.75 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatRedColorDark; + +/** + * Returns a flat color object whose HSB values are 0.12, 0.30, 0.84 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatSandColorDark; + +/** + * Returns a flat color object whose HSB values are 0.57, 0.78, 0.73 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatSkyBlueColorDark; + +/** + * Returns a flat color object whose HSB values are 0.54, 0.54, 0.45 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatTealColorDark; + +/** + * Returns a flat color object whose HSB values are 0.99, 0.61, 0.85 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatWatermelonColorDark; + +/** + * Returns a flat color object whose HSB values are 0.57, 0.05, 0.78 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatWhiteColorDark; + +/** + * Returns a flat color object whose HSB values are 0.11, 1.00, 1.00 and whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + */ ++ (UIColor *)flatYellowColorDark; + +#pragma mark - Randomizing Colors + +/** + * Returns a randomly generated flat color object whose alpha value is 1.0. + * + * @return A flat @c UIColor object in the HSB colorspace. + * + * @since 1.0 + */ + ++ (UIColor *)randomFlatColor; + +/** + * @author Vicc Alexander + * + * Returns a randomly generated flat color object NOT found in the specified array. + * + * @param excludedColors An array specifying which colors NOT to return. + * + * @return A flat @c UIColor object in the HSB colorspace. + * + * @since 2.1.0 + */ ++ (UIColor *)colorWithRandomFlatColorExcludingColorsInArray:(NSArray *)colors; + +/** + * @author Vicc Alexander + * + * Returns a randomly generated color object found in the specified array. + * + * @param colors An array specifying which colors to return. + * + * @return A flat @c UIColor object in the HSB colorspace. + * + * @since 2.1.0 + */ ++ (UIColor *)colorWithRandomColorInArray:(NSArray *)colors; + +/** + * Returns a randomly generated flat color object with an alpha value of 1.0 in either a light or dark shade. + * + * @param shadeStyle Specifies whether the randomly generated flat color should be a light or dark shade. + * + * @return A flat @c UIColor object in the HSB colorspace. + * + * @since 1.0 + */ ++ (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle; + +/** + * Returns a randomly generated flat color object in either a light or dark shade. + * + * @param shadeStyle Specifies whether the randomly generated flat color should be a light or dark shade. + * @param alpha The opacity. + * + * @return A flat @c UIColor object in the HSB colorspace. + * + * @since 2.0 + */ ++ (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle withAlpha:(CGFloat)alpha; + +#pragma mark - Averaging a Color + +/** + * Returns the average color generated by averaging the colors of a specified image. + * + * @param image A specified @c UIImage. + * + * @return A flat @c UIColor object in the HSB colorspace. + * + * @since 2.0 + */ ++ (UIColor *)colorWithAverageColorFromImage:(UIImage *)image; + +/** + * Returns the average color generated by averaging the colors of a specified image. + * + * @param image A specified @c UIImage. + * @param alpha The opacity. + * + * @return A flat @c UIColor object in the HSB colorspace. + * + * @since 2.0 + */ ++ (UIColor *)colorWithAverageColorFromImage:(UIImage *)image withAlpha:(CGFloat)alpha; + +#pragma mark - Complementary Colors + +/** + * Creates and returns a complementary flat color object 180 degrees away in the HSB colorspace from the specified color. + * + * @param color The color whose complementary color is being requested. + * + * @return A flat UIColor object in the HSB colorspace. + * + * @since 1.0 + */ + ++ (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color; + +/** + * Creates and returns a complementary flat color object 180 degrees away in the HSB colorspace from the specified color. + * + * @param color The color whose complementary color is being requested. + * @param alpha The opacity. + * + * @return A flat UIColor object in the HSB colorspace. + * + * @since 2.0 + */ + ++ (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color withAlpha:(CGFloat)alpha; + +#pragma mark - Contrasting Colors + +/** + * Creates and returns either a black or white color object depending on which contrasts more with a specified color. + * + * @param color The specified color of the contrast color that is being requested. + * @param isFlat Pass YES to return flat color objects. + * + * @return A UIColor object in the HSB colorspace. + * + * @since 1.0 + */ + ++ (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat; + +/** + * Creates and returns either a black or white color object depending on which contrasts more with a specified color. + * + * @param color The specified color of the contrast color that is being requested. + * @param isFlat Pass YES to return flat color objects. + * @param alpha The opacity. + * + * @return A UIColor object in the HSB colorspace. + * + * @since 2.0 + */ ++ (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat alpha:(CGFloat)alpha; + +#pragma mark - Gradient Colors + +/** + * Creates and returns a gradient as a color object with an alpha value of 1.0 + * + * @param gradientStyle Specifies the style and direction of the gradual blend between colors. + * @param frame The frame rectangle, which describes the view’s location and size in its superview’s coordinate system. + * @param colors An array of color objects used to create a gradient. + * + * @return A @c UIColor object using colorWithPattern. + * + * @since 2.0 + */ ++ (UIColor *)colorWithGradientStyle:(UIGradientStyle)gradientStyle withFrame:(CGRect)frame andColors:(NSArray *)colors; + +#pragma mark - Colors from Hex Strings + +/** + * Creates and returns a @c UIColor object based on the specified hex string. + * + * @param string The hex string. + * + * @return A @c UIColor object in the RGB colorspace. + * + * + * @since 2.0 + */ ++ (UIColor *)colorWithHexString:(NSString *)string; + +/** + * Creates and returns a @c UIColor object based on the specified hex string. + * + * @param string The hex string. + * @param alpha The opacity. + * + * @return A @c UIColor object in the RGB colorspace. + * + * + * @since 2.0 + */ ++ (UIColor *)colorWithHexString:(NSString *)string withAlpha:(CGFloat)alpha; + +#pragma mark - Instance Methods + +/** + * Creates and returns a flat color object closest to the specified color in the LAB colorspace. + * + * @return A flat version of the specified @c UIColor. + * + * @since 2.0 + */ +- (UIColor *)flatten; + +/** + * Creates and returns a darker shade of a specified color in the HSB space. + * + * @param percentage The value with which to darken a specified color. + * + * @return A @c UIColor object in the HSB space. + * + * @since 2.0 + */ +- (UIColor *)darkenByPercentage:(CGFloat)percentage; + +/** + * @author Vicc Alexander + * + * Returns the hex string value for the specified color. + * + * @return An @NSString object. + * + * @since 2.1.0 + */ +- (NSString *)hexValue; + +/** + * Creates and returns a lighter shade of a specified color in the HSB space. + * + * @param percentage The value with which to lighten a specified color. + * + * @return A @c UIColor object in the HSB space. + * + * @since 2.0 + */ +- (UIColor *)lightenByPercentage:(CGFloat)percentage; + +#pragma mark - Deprecated Methods + +/** + * Creates and returns a flat color object closest to the specified color in the LAB colorspace. + * + * @param color The specified color of the flat color that is being requested. + * + * @return A flat UIColor object in the RGB colorspace. + * + * @since 1.0 + */ ++ (UIColor *)colorWithFlatVersionOf:(UIColor *)color __attribute((deprecated(" Use -flatten: instead (First deprecated in Chameleon 2.0)."))); + + +@end + diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+Chameleon.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+Chameleon.m new file mode 100755 index 0000000..934f760 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+Chameleon.m @@ -0,0 +1,1027 @@ + +// UIColor+Chameleon.m + +/* + + The MIT License (MIT) + + Copyright (c) 2014-2015 Vicc Alexander. + + 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. + + */ + +#import "UIColor+Chameleon.h" +#import "UIColor+ChameleonPrivate.h" +#import "ChameleonMacros.h" +#import + +@implementation UIColor (Chameleon) + +@dynamic gradientImage; + +#pragma mark - Chameleon - Getter & Setter Methods for Instance Variables + ++ (void)setGradientImage:(UIImage *)gradientImage { + + objc_setAssociatedObject(self, @selector(gradientImage), gradientImage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + ++ (UIImage *)gradientImage { + + return objc_getAssociatedObject(self, @selector(gradientImage)); +} + +#pragma mark - Chameleon - Light Shades + ++ (UIColor *)flatBlackColor { + return hsb(0, 0, 17); +} + ++ (UIColor *)flatBlueColor { + return hsb(224, 50, 63); +} + ++ (UIColor *)flatBrownColor { + return hsb(24, 45, 37); +} + ++ (UIColor *)flatCoffeeColor { + return hsb(25, 31, 64); +} + ++ (UIColor *)flatForestGreenColor { + return hsb(138, 45, 37); +} + ++ (UIColor *)flatGrayColor { + return hsb(184, 10, 65); +} + ++ (UIColor *)flatGreenColor { + return hsb(145, 77, 80); +} + ++ (UIColor *)flatLimeColor { + return hsb(74, 70, 78); +} + ++ (UIColor *)flatMagentaColor { + return hsb(283, 51, 71); +} + ++ (UIColor *)flatMaroonColor { + return hsb(5, 65, 47); +} + ++ (UIColor *)flatMintColor { + return hsb(168, 86, 74); +} + ++ (UIColor *)flatNavyBlueColor { + return hsb(210, 45, 37); +} + ++ (UIColor *)flatOrangeColor { + return hsb(28, 85, 90); +} + ++ (UIColor *)flatPinkColor { + return hsb(324, 49, 96); +} + ++ (UIColor *)flatPlumColor { + return hsb(300, 45, 37); +} + ++ (UIColor *)flatPowderBlueColor { + return hsb(222, 24, 95); +} + ++ (UIColor *)flatPurpleColor { + return hsb(253, 52, 77); +} + ++ (UIColor *)flatRedColor { + return hsb(6, 74, 91); +} + ++ (UIColor *)flatSandColor { + return hsb(42, 25, 94); +} + ++ (UIColor *)flatSkyBlueColor { + return hsb(204, 76, 86); +} + ++ (UIColor *)flatTealColor { + return hsb(195, 55, 51); +} + ++ (UIColor *)flatWatermelonColor { + return hsb(356, 53, 94); +} + ++ (UIColor *)flatWhiteColor { + return hsb(192, 2, 95); +} + ++ (UIColor *)flatYellowColor { + return hsb(48, 99, 100); +} + +#pragma mark - Chameleon - Dark Shades + ++ (UIColor *)flatBlackColorDark { + return hsb(0, 0, 15); +} + ++ (UIColor *)flatBlueColorDark { + return hsb(224, 56, 51); +} + ++ (UIColor *)flatBrownColorDark { + return hsb(25, 45, 31); +} + ++ (UIColor *)flatCoffeeColorDark { + return hsb(25, 34, 56); +} + ++ (UIColor *)flatForestGreenColorDark { + return hsb(135, 44, 31); +} + ++ (UIColor *)flatGrayColorDark { + return hsb(184, 10, 55); +} + ++ (UIColor *)flatGreenColorDark { + return hsb(145, 78, 68); +} + ++ (UIColor *)flatLimeColorDark { + return hsb(74, 81, 69); +} + ++ (UIColor *)flatMagentaColorDark { + return hsb(282, 61, 68); +} + ++ (UIColor *)flatMaroonColorDark { + return hsb(4, 68, 40); +} + ++ (UIColor *)flatMintColorDark { + return hsb(168, 86, 63); +} + ++ (UIColor *)flatNavyBlueColorDark { + return hsb(210, 45, 31); +} + ++ (UIColor *)flatOrangeColorDark { + return hsb(24, 100, 83); +} + ++ (UIColor *)flatPinkColorDark { + return hsb(327, 57, 83); +} + ++ (UIColor *)flatPlumColorDark { + return hsb(300, 46, 31); +} + ++ (UIColor *)flatPowderBlueColorDark { + return hsb(222, 28, 84); +} + ++ (UIColor *)flatPurpleColorDark { + return hsb(253, 56, 64); +} + ++ (UIColor *)flatRedColorDark { + return hsb(6, 78, 75); +} + ++ (UIColor *)flatSandColorDark { + return hsb(42, 30, 84); +} + ++ (UIColor *)flatSkyBlueColorDark { + return hsb(204, 78, 73); +} + ++ (UIColor *)flatTealColorDark { + return hsb(196, 54, 45); +} + ++ (UIColor *)flatWatermelonColorDark { + return hsb(358, 61, 85); +} + ++ (UIColor *)flatWhiteColorDark { + return hsb(204, 5, 78); +} + ++ (UIColor *)flatYellowColorDark { + return hsb(40, 100, 100); +} + +#pragma mark - Chameleon - "Color With" Methods + ++ (UIColor *)colorWithAverageColorFromImage:(UIImage *)image { + + return [self colorWithAverageColorFromImage:image withAlpha:1.0]; +} + ++ (UIColor *)colorWithAverageColorFromImage:(UIImage *)image withAlpha:(CGFloat)alpha { + + //Work within the RGB colorspoace + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + unsigned char rgba[4]; + CGContextRef context = CGBitmapContextCreate(rgba, 1, 1, 8, 4, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); + + //Draw our image down to 1x1 pixels + CGContextDrawImage(context, CGRectMake(0, 0, 1, 1), image.CGImage); + CGColorSpaceRelease(colorSpace); + CGContextRelease(context); + + //Check if image alpha is 0 + if (rgba[3] == 0) { + + CGFloat imageAlpha = ((CGFloat)rgba[3])/255.0; + CGFloat multiplier = imageAlpha/255.0; + + UIColor *averageColor = [UIColor colorWithRed:((CGFloat)rgba[0])*multiplier green:((CGFloat)rgba[1])*multiplier blue:((CGFloat)rgba[2])*multiplier alpha:imageAlpha]; + + //Improve color + averageColor = [averageColor colorWithMinimumSaturation:0.15]; + + //Return average color + return averageColor; + } + + else { + + //Get average + UIColor *averageColor = [UIColor colorWithRed:((CGFloat)rgba[0])/255.0 green:((CGFloat)rgba[1])/255.0 blue:((CGFloat)rgba[2])/255.0 alpha:alpha]; + + //Improve color + averageColor = [averageColor colorWithMinimumSaturation:0.15]; + + //Return average color + return averageColor; + } +} + ++ (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color { + + return [[self class] colorWithComplementaryFlatColorOf:color withAlpha:1.0]; +} + ++ (UIColor *)colorWithComplementaryFlatColorOf:(UIColor *)color withAlpha:(CGFloat)alpha { + + //Check if input UIColor is a gradient aka a pattern + if (CGColorGetPattern(color.CGColor)) { + + //Let's find the average color of the image and contrast against that. + CGSize size = {1, 1}; + + //Create a 1x1 bitmap context + UIGraphicsBeginImageContext(size); + CGContextRef ctx = UIGraphicsGetCurrentContext(); + + //Set the interpolation quality to medium + CGContextSetInterpolationQuality(ctx, kCGInterpolationMedium); + + //Draw image scaled down to this 1x1 pixel + [[self gradientImage] drawInRect:(CGRect){.size = size} blendMode:kCGBlendModeCopy alpha:1]; + + //Read the RGB values from the context's buffer + uint8_t *data = CGBitmapContextGetData(ctx); + color = [UIColor colorWithRed:data[2] / 255.0f + green:data[1] / 255.0f + blue:data[0] / 255.0f + alpha:1]; + UIGraphicsEndImageContext(); + } + + //Extract & Check to make sure we have an actual color to work with (Clear returns clear) + CGFloat hue, saturation, brightness, alpha1; + [color getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha1]; + + //Check if color is transparent + if (alpha1 == 0) { + return [UIColor clearColor]; + } + + //Multiply our value by their max values to convert + hue *= 360; + saturation *= 100; + brightness *= 100; + + //Select a color with a hue 180 degrees away on the colorwheel (i.e. for 50 it would be 230). + hue += 180.0f; + if (hue > 360.f) { + hue -= 360.0f; + } + + //Round to the nearest whole number after multiplying + hue = roundf(hue); + saturation = roundf(saturation); + brightness = roundf(brightness); + + //Store complimentary nonflat color + UIColor *complimentaryNonFlatColor = [UIColor colorWithHue:hue/360.0 + saturation:saturation/100.0 + brightness:brightness/100.0 + alpha:alpha]; + + //Retrieve LAB values from our complimentary nonflat color & return nearest flat color + return [self colorWithFlatVersionOf:complimentaryNonFlatColor withAlpha:alpha]; +} + + ++ (UIColor *)colorWithFlatVersionOf:(UIColor *)color { + + //Return flat version with default alpha of 1.0 + return [[self class] colorWithFlatVersionOf:color withAlpha:1.0]; +} + ++ (UIColor *)colorWithFlatVersionFrom:(UIColor *)color { + CGFloat colorAlpha = 0; + [color getLightness:nil valueForA:nil valueForB:nil alpha:&colorAlpha]; + colorAlpha = colorAlpha > 0.0 ? colorAlpha : 1.0; + //Return flat version with default alpha of 1.0 + return [[self class] colorWithFlatVersionOf:color withAlpha:colorAlpha]; +} + ++ (UIColor *)colorWithFlatVersionOf:(UIColor *)color withAlpha:(CGFloat)alpha { + + //Check if input UIColor is a gradient aka a pattern + if (CGColorGetPattern(color.CGColor)) { + + //Let's find the average color of the image and contrast against that. + CGSize size = {1, 1}; + + //Create a 1x1 bitmap context + UIGraphicsBeginImageContext(size); + CGContextRef ctx = UIGraphicsGetCurrentContext(); + + //Set the interpolation quality to medium + CGContextSetInterpolationQuality(ctx, kCGInterpolationMedium); + + //Draw image scaled down to this 1x1 pixel + [[self gradientImage] drawInRect:(CGRect){.size = size} blendMode:kCGBlendModeCopy alpha:1]; + + //Read the RGB values from the context's buffer + uint8_t *data = CGBitmapContextGetData(ctx); + color = [UIColor colorWithRed:data[2] / 255.0f + green:data[1] / 255.0f + blue:data[0] / 255.0f + alpha:1]; + UIGraphicsEndImageContext(); + } + + //Create CGFloats to hold our color values + CGFloat L, A, B, alpha1; + + //Get LAB values for our color + [color getLightness:&L valueForA:&A valueForB:&B alpha:&alpha1]; + + if (![color getLightness:&L valueForA:&A valueForB:&B alpha:&alpha1]) { + return nil; + } + + //Find the nearest flat color + return [self nearestFlatColorForL:L A:A B:B alpha:alpha]; +} + ++ (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat { + + //Return color with default alpha value of 1.0 + return [[self class] colorWithContrastingBlackOrWhiteColorOn:backgroundColor isFlat:flat alpha:1.0]; +} + ++ (UIColor *)colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor + isFlat:(BOOL)flat + alpha:(CGFloat)alpha { + + //Check if UIColor is a gradient aka a pattern + if (CGColorGetPattern(backgroundColor.CGColor)) { + + //Let's find the average color of the image and contrast against that. + CGSize size = {1, 1}; + + //Create a 1x1 bitmap context + UIGraphicsBeginImageContext(size); + CGContextRef ctx = UIGraphicsGetCurrentContext(); + + //Set the interpolation quality to medium + CGContextSetInterpolationQuality(ctx, kCGInterpolationMedium); + + //Draw image scaled down to this 1x1 pixel + [[self gradientImage] drawInRect:(CGRect){.size = size} blendMode:kCGBlendModeCopy alpha:1]; + + //Read the RGB values from the context's buffer + uint8_t *data = CGBitmapContextGetData(ctx); + backgroundColor = [UIColor colorWithRed:data[2] / 255.0f + green:data[1] / 255.0f + blue:data[0] / 255.0f + alpha:1]; + UIGraphicsEndImageContext(); + } + + //Calculate Luminance + CGFloat luminance; + CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha1 = 0.0; + [backgroundColor getRed:&red green:&green blue:&blue alpha:&alpha1]; + + //Check if color is transparent + if (alpha == 0) { + return [UIColor clearColor]; + } + + // Relative luminance in colorimetric spaces - http://en.wikipedia.org/wiki/Luminance_(relative) + red *= 0.2126f; green *= 0.7152f; blue *= 0.0722f; + luminance = red + green + blue; + + if (flat == NO) { + return (luminance > 0.6f) ? rgba(0, 0, 0, alpha) : rgba(255, 255, 255, alpha); + } else { + return (luminance > 0.6f) ? hsba(0, 0, 15, alpha) : hsba(192, 2, 95, alpha); + } +} + ++ (UIColor *)colorWithGradientStyle:(UIGradientStyle)gradientStyle withFrame:(CGRect)frame andColors:(NSArray *)colors; { + + //Create our background gradient layer + CAGradientLayer *backgroundGradientLayer = [CAGradientLayer layer]; + + //Set the frame to our object's bounds + backgroundGradientLayer.frame = frame; + + //To simplfy formatting, we'll iterate through our colors array and create a mutable array with their CG counterparts + NSMutableArray *cgColors = [[NSMutableArray alloc] init]; + for (UIColor *color in colors) { + [cgColors addObject:(id)[color CGColor]]; + } + + switch (gradientStyle) { + case UIGradientStyleLeftToRight: { + + //Set out gradient's colors + backgroundGradientLayer.colors = cgColors; + + //Specify the direction our gradient will take + [backgroundGradientLayer setStartPoint:CGPointMake(0.0, 0.5)]; + [backgroundGradientLayer setEndPoint:CGPointMake(1.0, 0.5)]; + + //Convert our CALayer to a UIImage object + UIGraphicsBeginImageContextWithOptions(backgroundGradientLayer.bounds.size,NO, [UIScreen mainScreen].scale); + [backgroundGradientLayer renderInContext:UIGraphicsGetCurrentContext()]; + UIImage *backgroundColorImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + [self setGradientImage:backgroundColorImage]; + return [UIColor colorWithPatternImage:backgroundColorImage]; + } + + case UIGradientStyleRadial: { + UIGraphicsBeginImageContextWithOptions(frame.size,NO, [UIScreen mainScreen].scale); + + //Specific the spread of the gradient (For now this gradient only takes 2 locations) + CGFloat locations[2] = {0.0, 1.0}; + + //Default to the RGB Colorspace + CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB(); + CFArrayRef arrayRef = (__bridge CFArrayRef)cgColors; + + //Create our Fradient + CGGradientRef myGradient = CGGradientCreateWithColors(myColorspace, arrayRef, locations); + + + // Normalise the 0-1 ranged inputs to the width of the image + CGPoint myCentrePoint = CGPointMake(0.5 * frame.size.width, 0.5 * frame.size.height); + float myRadius = MIN(frame.size.width, frame.size.height) * 1.0; + + // Draw our Gradient + CGContextDrawRadialGradient (UIGraphicsGetCurrentContext(), myGradient, myCentrePoint, + 0, myCentrePoint, myRadius, + kCGGradientDrawsAfterEndLocation); + + // Grab it as an Image + UIImage *backgroundColorImage = UIGraphicsGetImageFromCurrentImageContext(); + + // Clean up + CGColorSpaceRelease(myColorspace); // Necessary? + CGGradientRelease(myGradient); // Necessary? + UIGraphicsEndImageContext(); + + [self setGradientImage:backgroundColorImage]; + return [UIColor colorWithPatternImage:backgroundColorImage]; + } + + case UIGradientStyleTopToBottom: + default: { + + //Set out gradient's colors + backgroundGradientLayer.colors = cgColors; + + //Convert our CALayer to a UIImage object + UIGraphicsBeginImageContextWithOptions(backgroundGradientLayer.bounds.size,NO, [UIScreen mainScreen].scale); + [backgroundGradientLayer renderInContext:UIGraphicsGetCurrentContext()]; + UIImage *backgroundColorImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + [self setGradientImage:backgroundColorImage]; + return [UIColor colorWithPatternImage:backgroundColorImage]; + } + + } +} + ++ (UIColor *)colorWithHexString:(NSString *)string { + + //Color with string and a defualt alpha value of 1.0 + return [self colorWithHexString:string withAlpha:1.0]; +} + ++ (UIColor *)colorWithHexString:(NSString *)string withAlpha:(CGFloat)alpha { + + //Quick return in case string is empty + if (string.length == 0) { + return nil; + } + + //Check to see if we need to add a hashtag + if('#' != [string characterAtIndex:0]) { + string = [NSString stringWithFormat:@"#%@", string]; + } + + //Make sure we have a working string length + if (string.length != 7 && string.length != 4) { + + #ifdef DEBUG + NSLog(@"Unsupported string format: %@", string); + #endif + + return nil; + } + + //Check for short hex strings + if(string.length == 4) { + + //Convert to full length hex string + string = [NSString stringWithFormat:@"#%@%@%@%@%@%@", + [string substringWithRange:NSMakeRange(1, 1)],[string substringWithRange:NSMakeRange(1, 1)], + [string substringWithRange:NSMakeRange(2, 1)],[string substringWithRange:NSMakeRange(2, 1)], + [string substringWithRange:NSMakeRange(3, 1)],[string substringWithRange:NSMakeRange(3, 1)]]; + } + + NSString *redHex = [NSString stringWithFormat:@"0x%@", [string substringWithRange:NSMakeRange(1, 2)]]; + unsigned red = [[self class] hexValueToUnsigned:redHex]; + + NSString *greenHex = [NSString stringWithFormat:@"0x%@", [string substringWithRange:NSMakeRange(3, 2)]]; + unsigned green = [[self class] hexValueToUnsigned:greenHex]; + + NSString *blueHex = [NSString stringWithFormat:@"0x%@", [string substringWithRange:NSMakeRange(5, 2)]]; + unsigned blue = [[self class] hexValueToUnsigned:blueHex]; + + return [UIColor colorWithRed:(float)red/255 green:(float)green/255 blue:(float)blue/255 alpha:alpha]; +} + ++ (unsigned)hexValueToUnsigned:(NSString *)hexValue { + + //Define default unsigned value + unsigned value = 0; + + //Scan unsigned value + NSScanner *hexValueScanner = [NSScanner scannerWithString:hexValue]; + [hexValueScanner scanHexInt:&value]; + + //Return found value + return value; +} + +#pragma mark - Chameleon - Random Color Methods + ++ (NSInteger)generateRandomNumberWithMax:(NSInteger)max { + + //Choose a random number between 0 and our number of available colors + return arc4random_uniform((UInt32)max); +} + ++ (UIColor *)randomFlatColor { + + //Number of colors to choose from + const uint32_t numberOfPossibleColors = 48; + + //Chose one of those colors at random + NSInteger randomColorChosen = [[self class] generateRandomNumberWithMax:numberOfPossibleColors]; + + //Check if a previous random number exists + if (![[NSUserDefaults standardUserDefaults] integerForKey:@"previousRandomNumber"]) { + + //If no previous number exists, save it as such and find the matching color + [[NSUserDefaults standardUserDefaults] setInteger:randomColorChosen forKey:@"previousRandomNumber"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + + } else { + + //Keep generating a random number until it is different than the one generated last time + while (randomColorChosen == [[NSUserDefaults standardUserDefaults] integerForKey:@"previousRandomNumber"]) { + randomColorChosen = [[self class] generateRandomNumberWithMax:numberOfPossibleColors]; + } + + //Once a new number has been generated then store it as the previous number for next time and proceed + [[NSUserDefaults standardUserDefaults] setInteger:randomColorChosen forKey:@"previousRandomNumber"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + } + + return [self flatColors][randomColorChosen]; +} + ++ (UIColor *)colorWithRandomColorInArray:(NSArray *)colors { + + UIColor *randomColor; + if (colors.count) { + + //Pick a random index + NSInteger randomIndex = arc4random() % colors.count; + + //Return the color at the random index + randomColor = colors[randomIndex]; + + } else { + return nil; + } + + NSAssert([randomColor isKindOfClass:[UIColor class]], @"Hmm... one of your objects in your 'colors' array is not a UIColor object."); + + //Return + return randomColor; +} + ++ (UIColor *)colorWithRandomFlatColorExcludingColorsInArray:(NSArray *)colors { + + //Set random flat color + UIColor *randomColor = [[self class] randomFlatColor]; + + //If the selected color is blacklisted select a new color + while ([colors containsObject:randomColor]) { + randomColor = [[self class] randomFlatColor]; + } + + //Return + return randomColor; +} + ++ (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle { + + //Return color with default alpha value of 1.0 + return [[self class] colorWithRandomFlatColorOfShadeStyle:shadeStyle withAlpha:1.0]; +} + ++ (UIColor *)colorWithRandomFlatColorOfShadeStyle:(UIShadeStyle)shadeStyle withAlpha:(CGFloat)alpha { + + //Number of colors to choose from + const NSInteger numberOfPossibleColors = 24; + + //Chose one of those colors at random + NSInteger randomColorChosen = [[self class] generateRandomNumberWithMax:numberOfPossibleColors]; + + //Check if a previous random number exists + if (![[NSUserDefaults standardUserDefaults] integerForKey:@"previousRandomNumber"]) { + + //If no previous number exists, save it as such and find the matching color + [[NSUserDefaults standardUserDefaults] setInteger:randomColorChosen forKey:@"previousRandomNumber"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + + } else { + + //Keep generating a random number until it is different than the one generated last time + while (randomColorChosen == [[NSUserDefaults standardUserDefaults] integerForKey:@"previousRandomNumber"]) { + randomColorChosen = [[self class] generateRandomNumberWithMax:numberOfPossibleColors]; + } + + //Once a new number has been generated then store it as the previous number for next time and proceed + [[NSUserDefaults standardUserDefaults] setInteger:randomColorChosen forKey:@"previousRandomNumber"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + } + + //Assign a random color based on randomColorChosen + UIColor *randomColor; + + //Return a color depending on the specified shade + switch (shadeStyle) { + case UIShadeStyleDark: { + + NSArray *darkColors = @[FlatBlackDark, FlatBlueDark, FlatBrownDark, FlatCoffeeDark, FlatForestGreenDark, FlatGrayDark, FlatGreenDark, FlatLimeDark, FlatMagentaDark, FlatMaroonDark, FlatMintDark, FlatNavyBlueDark, FlatOrangeDark, FlatPinkDark, FlatPlumDark, FlatPowderBlueDark, FlatPurpleDark, FlatRedDark, FlatSandDark, FlatSkyBlueDark, FlatTealDark, FlatWatermelonDark, FlatWhiteDark, FlatYellowDark]; + + randomColor = darkColors[randomColorChosen]; + break; + } + + case UIShadeStyleLight: + default: { + + NSArray *lightColors = @[FlatBlack, FlatBlue, FlatBrown, FlatCoffee, FlatForestGreen, FlatGray, FlatGreen, FlatLime, FlatMagenta, FlatMaroon, FlatMint, FlatNavyBlue, FlatOrange, FlatPink, FlatPlum, FlatPowderBlue, FlatPurple, FlatRed, FlatSand, FlatSkyBlue, FlatTeal, FlatWatermelon, FlatWhite, FlatYellow]; + + randomColor = lightColors[randomColorChosen]; + break; + } + } + + //Return color with correct alpha value + randomColor = [randomColor colorWithAlphaComponent:alpha]; + + return randomColor; +} + +#pragma mark - Chameleon Instance Methods + +- (UIColor *)flatten { + + return [UIColor colorWithFlatVersionFrom:self]; +} + +- (UIColor *)darkenByPercentage:(CGFloat)percentage { + + //Define HSBA values + CGFloat h, s, b, a; + + //Check if HSBA values exist + if ([self getHue:&h saturation:&s brightness:&b alpha:&a]) { + + //Make sure our percentage is greater than 0 + if (percentage > 0) { + b = MIN(b - percentage, 1.0); + } + + //Return darker color + return [UIColor colorWithHue:h saturation:s brightness:b alpha:a]; + } + + return nil; +} + +- (NSString *)hexValue { + + UIColor *currentColor = self; + if (CGColorGetNumberOfComponents(self.CGColor) < 4) { + const CGFloat *components = CGColorGetComponents(self.CGColor); + currentColor = [UIColor colorWithRed:components[0] green:components[0] blue:components[0] alpha:components[1]]; + } + + if (CGColorSpaceGetModel(CGColorGetColorSpace(currentColor.CGColor)) != kCGColorSpaceModelRGB) { + return [NSString stringWithFormat:@"#FFFFFF"]; + } + + return [NSString stringWithFormat:@"#%02X%02X%02X", (int)((CGColorGetComponents(currentColor.CGColor))[0]*255.0), (int)((CGColorGetComponents(currentColor.CGColor))[1]*255.0), (int)((CGColorGetComponents(currentColor.CGColor))[2]*255.0)]; + +} + +- (UIColor *)lightenByPercentage:(CGFloat)percentage { + + //Define HSBA values + CGFloat h, s, b, a; + + //Check if HSBA values exist + if ([self getHue:&h saturation:&s brightness:&b alpha:&a]) { + + //Make sure our percentage is greater than 0 + if (percentage > 0) { + b = MIN(b + percentage, 1.0); + } + + //Return lighter color + return [UIColor colorWithHue:h saturation:s brightness:b alpha:a]; + } + + return nil; +} + +- (BOOL)isEqualToColor:(UIColor *)color { + + //Check if both colors are in the Monochrome / RGB color space + if ([self isMonochromeOrRGB] && [color isMonochromeOrRGB]) { + + //Return comparison + return self.RGBAValue == color.RGBAValue; + } + + //Return comparison + return [self isEqual:color]; +} + +#pragma mark - Chameleon Internal Methods + +//Array of all our colors ++ (NSArray *)flatColors { + + return @[FlatBlack, FlatBlackDark, FlatBlue, FlatBlueDark, FlatBrown, FlatBrownDark, FlatCoffee, FlatCoffeeDark, FlatForestGreen, FlatForestGreenDark, FlatGray, FlatGrayDark, FlatGreen, FlatGreenDark, FlatLime, FlatLimeDark, FlatMagenta, FlatMagentaDark, FlatMaroon, FlatMaroonDark, FlatMint, FlatMintDark, FlatNavyBlue, FlatNavyBlueDark, FlatOrange, FlatOrangeDark, FlatPink, FlatPinkDark, FlatPlum, FlatPlumDark, FlatPowderBlue, FlatPowderBlueDark, FlatPurple, FlatPurpleDark, FlatRed, FlatRedDark, FlatSand, FlatSandDark, FlatSkyBlue, FlatSkyBlueDark, FlatTeal, FlatTealDark, FlatWatermelon, FlatWatermelonDark, FlatWhite, FlatWhiteDark, FlatYellow, FlatYellowDark]; +} + +- (uint32_t)RGBAValue { + + CGFloat rgba[4]; + [self getRGBAComponents:rgba]; + uint8_t red = rgba[0]*255; + uint8_t green = rgba[1]*255; + uint8_t blue = rgba[2]*255; + uint8_t alpha = rgba[3]*255; + + return (red << 24) + (green << 16) + (blue << 8) + alpha; +} + +- (void)getRGBAComponents:(CGFloat[4])rgba { + + CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(self.CGColor)); + const CGFloat *components = CGColorGetComponents(self.CGColor); + switch (model) { + + case kCGColorSpaceModelMonochrome: { + rgba[0] = components[0]; + rgba[1] = components[0]; + rgba[2] = components[0]; + rgba[3] = components[1]; + break; + } + + case kCGColorSpaceModelRGB: { + rgba[0] = components[0]; + rgba[1] = components[1]; + rgba[2] = components[2]; + rgba[3] = components[3]; + break; + } + + case kCGColorSpaceModelCMYK: + case kCGColorSpaceModelDeviceN: + case kCGColorSpaceModelIndexed: + case kCGColorSpaceModelLab: + case kCGColorSpaceModelPattern: + case kCGColorSpaceModelUnknown: { + + #ifdef DEBUG + NSLog(@"Unsupported color model: %i", model); + #endif + + rgba[0] = 0.0f; + rgba[1] = 0.0f; + rgba[2] = 0.0f; + rgba[3] = 1.0f; + break; + } + } +} + +//Check if color is in the monochrome or rgb color space +- (BOOL)isMonochromeOrRGB { + + CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(self.CGColor)); + return model == kCGColorSpaceModelMonochrome || model == kCGColorSpaceModelRGB; +} + +//Calculate the total sum of differences - Euclidian distance +//Chameleon is now using the CIEDE2000 formula to calculate distances between 2 colors. +//More info: http://en.wikipedia.org/wiki/Color_difference ++ (float)totalSumOfDifferencesFroml1:(CGFloat)L1 l2:(CGFloat)L2 a1:(CGFloat)A1 + a2:(CGFloat)A2 b1:(CGFloat)B1 b2:(CGFloat)B2 { + + //Get C Values in LCH from LAB Values + CGFloat C1 = sqrt(pow(A1, 2) + pow(B1, 2)); + CGFloat C2 = sqrt(pow(A2, 2) + pow(B2, 2)); + + //CIE Weights + CGFloat KL = 1; + CGFloat KC = 1; + CGFloat KH = 1; + + //Variables specifically set for CIE:2000 + CGFloat DeltaPrimeL = L2 - L1; + CGFloat MeanL = ((L1 + L2) / 2); + CGFloat MeanC = ((C1 + C2) / 2); + CGFloat A1Prime = A1 + A1 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); + CGFloat A2Prime = A2 + A2 / 2 * (1 - sqrt(pow(MeanC, 7.0) / (pow(MeanC, 7.0) + pow(25.0, 7.0)))); + CGFloat C1Prime = sqrt(pow(A1Prime, 2) + pow(B1, 2)); + CGFloat C2Prime = sqrt(pow(A2Prime, 2) + pow(B2, 2)); + CGFloat DeltaPrimeC = C1Prime - C2Prime; + CGFloat DeltaC = C1 - C2; + CGFloat MeanCPrime = (C1Prime + C2Prime) / 2; + CGFloat H1Prime = fmodf(atan2(B1, A1Prime), (360.0 * M_PI/180)); + CGFloat H2Prime = fmodf(atan2(B2, A2Prime), (360.0 * M_PI/180)); + + //Run everything through our △H' Function + CGFloat hDeltaPrime = 0; + if (fabs(H1Prime - H2Prime) <= (180.0 * M_PI/180)) { + + hDeltaPrime = H2Prime - H1Prime; + + } else if (H2Prime <= H1Prime) { + + hDeltaPrime = (H2Prime - H1Prime) + ((360.0 * M_PI/180)); + + } else { + + hDeltaPrime = (H2Prime - H1Prime) - ((360.0 * M_PI/180)); + } + + CGFloat deltaHPrime = 2 * (sqrt(C1Prime*C2Prime)) * sin(hDeltaPrime/2); + + //Get Mean H' Value + CGFloat MeanHPrime = 0; + if (fabs(H1Prime-H2Prime) > (180.0 * M_PI/180)) { + + MeanHPrime = (H1Prime + H2Prime + (360.0 * M_PI/180)) / 2; + + } else { + + MeanHPrime = (H1Prime + H2Prime) / 2; + } + + CGFloat T = 1 - 0.17 * cos(MeanHPrime - (30.0 * M_PI/180)) + 0.24 * cos(2 * MeanHPrime)+0.32 * cos(3 * MeanHPrime + (6.0 * M_PI/180)) - 0.20 * cos(4 * MeanHPrime - (63.0 * M_PI/180)); + + CGFloat SL = 1 + (0.015 * pow((MeanL - 50), 2))/sqrt(20 + pow((MeanL - 50), 2)); + CGFloat SC = 1 + 0.045 * MeanCPrime; + CGFloat SH = 1 + 0.015 * MeanCPrime * T; + + CGFloat RT = -2 * sqrt(pow(MeanCPrime, 7) / (pow(MeanCPrime, 7) + pow(25.0, 7))) * sin((60.0 * M_PI/180)* exp(-1 * pow((MeanCPrime - (275.0 * M_PI/180)) / (25.0 * M_PI/180), 2))); + + + //Get total difference + CGFloat TotalDifference = sqrt(pow((DeltaPrimeL / (KL * SL)), 2) + pow((DeltaPrimeC / (KC * SC)), 2) + pow((deltaHPrime / (KH * SH)), 2) + RT * (DeltaC / (KC * SC)) * (deltaHPrime / (KH * SH))); + + return TotalDifference; +} + ++ (UIColor *)nearestFlatColorForL:(CGFloat)l1 A:(CGFloat)a1 B:(CGFloat)b1 alpha:(CGFloat)alpha{ + + //Keep track of our index + int index = 0; + + //Start with a random big number to make sure the first comparison gets saved. + float smallestDistance = 1000000; + float previousDistance = 1000000; + float currentDistance; + + //Our values + CGFloat l2, a2, b2; + + //We're interested in the color with values returning the smallest sum of total differences so we need to cross reference our input color's values with every flat color's values + for (int i=0; i<[[self flatColors] count]; i++ ) { + + //Check that index is not zero + if (i!=0 ) { + //Extract LAB values from colors in array and store it as the previous index + [[self flatColors][i - 1] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; + + previousDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 + a1:a1 a2:a2 + b1:b1 b2:b2]; + } + + //Extract LAB values from colors in array and store it as the current index + [[self flatColors][i] getLightness:&l2 valueForA:&a2 valueForB:&b2 alpha:nil]; + + currentDistance = [self totalSumOfDifferencesFroml1:l1 l2:l2 + a1:a1 a2:a2 + b1:b1 b2:b2]; + + //We're only interested in the smallest difference + if (currentDistance < previousDistance) { + if (currentDistance < smallestDistance) { + smallestDistance = currentDistance; + index = i; + } + } + } + + + //Collect the RGB Values of the color where the smallest difference was found + CGFloat red, green, blue; + [[self flatColors][index] getRed:&red green:&green blue:&blue alpha:nil]; + + //Return the closest flat color + return rgba(red * 255, green * 255, blue * 255, alpha); +} + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.h new file mode 100755 index 0000000..f81e69a --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.h @@ -0,0 +1,36 @@ +// +// UIColor+ChameleonPrivate.h +// Chameleon +// +// Created by Vicc Alexander on 6/6/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import +#import + +@interface UIColor (ChameleonPrivate) + +@property (nonatomic, readwrite) NSUInteger count; + +#pragma mark - Class Methods + ++ (UIColor *)colorFromImage:(UIImage *)image atPoint:(CGPoint)point; + +- (UIColor *)colorWithMinimumSaturation:(CGFloat)saturation; + +#pragma mark - Instance Methods + +- (BOOL)isDistinct:(UIColor *)color; + +- (BOOL)getValueForX:(CGFloat *)X + valueForY:(CGFloat *)Y + valueForZ:(CGFloat *)Z + alpha:(CGFloat *)alpha; + +- (BOOL)getLightness:(CGFloat *)L + valueForA:(CGFloat *)A + valueForB:(CGFloat *)B + alpha:(CGFloat *)alpha; + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m new file mode 100755 index 0000000..c5c7d47 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m @@ -0,0 +1,251 @@ +// +// UIColor+ChameleonPrivate.m +// Chameleon +// +// Created by Vicc Alexander on 6/6/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import "UIColor+ChameleonPrivate.h" + +@implementation UIColor (ChameleonPrivate) + +@dynamic count; + +#pragma mark - Associated Objects Methods + +- (void)setCount:(NSUInteger)count { + objc_setAssociatedObject(self, @selector(count), [NSNumber numberWithUnsignedInteger:count], OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (NSUInteger)count { + NSNumber *number = objc_getAssociatedObject(self, @selector(count)); + return [number unsignedIntegerValue]; +} + +#pragma mark - Class Methods + +// Would not have been possible without - http://stackoverflow.com/a/1262893 ++ (UIColor *)colorFromImage:(UIImage *)image atPoint:(CGPoint)point { + + //Encapsulate our image + CGImageRef imageRef = image.CGImage; + NSUInteger width = CGImageGetWidth(imageRef); + NSUInteger height = CGImageGetHeight(imageRef); + + //Specify the colorspace we're in + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + + //Extract the data we need + unsigned char *rawData = calloc(height * width * 4, sizeof(unsigned char)); + NSUInteger bytesPerPixel = 4; + NSUInteger bytesPerRow = bytesPerPixel * width; + NSUInteger bitsPerComponent = 8; + CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, + colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); + //Release colorspace + CGColorSpaceRelease(colorSpace); + + //Draw and release image + CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); + CGContextRelease(context); + + //rawData now contains the image data in RGBA8888 + NSInteger byteIndex = (bytesPerRow * point.y) + (point.x * bytesPerPixel); + + //Define our RGBA values + CGFloat red = (rawData[byteIndex] * 1.f) / 255.f; + CGFloat green = (rawData[byteIndex + 1] * 1.f) / 255.f; + CGFloat blue = (rawData[byteIndex + 2] * 1.f) / 255.f; + CGFloat alpha = (rawData[byteIndex + 3] * 1.0) / 255.f; + + //Free our rawData + free(rawData); + + //Return color + return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; +} + +- (UIColor *)colorWithMinimumSaturation:(CGFloat)saturation { + if (!self) + return nil; + + CGFloat h, s, b, a; + [self getHue:&h saturation:&s brightness:&b alpha:&a]; + + if (s < saturation) + return [UIColor colorWithHue:h saturation:saturation brightness:b alpha:a]; + + return self; +} + +#pragma mark - Instance Methods + +- (BOOL)isDistinct:(UIColor *)color { + + if (!self || !color) { + return NO; + } + + CGFloat r, g, b, a; + CGFloat rc, gc, bc, ac; + + [self getRed:&r green:&g blue:&b alpha:&a]; + [color getRed:&rc green:&gc blue:&bc alpha:&ac]; + + CGFloat threshold = 0.25f; + + if (fabs(r - rc) > threshold || fabs(g - gc) > threshold || + + fabs(b - bc) > threshold || fabs(a - ac) > threshold) { + + // Check for grays + if (fabs(r - g) < 0.03f && fabs(r - b) < 0.03f) { + + if (fabs(rc - gc) < 0.03f && (fabs(rc - bc) < 0.03f)) { + return NO; + } + + } + + return YES; + } + + return NO; +} + +- (BOOL)getValueForX:(CGFloat *)X valueForY:(CGFloat *)Y valueForZ:(CGFloat *)Z alpha:(CGFloat *)alpha{ + + if ([self respondsToSelector:@selector(getRed:green:blue:alpha:)]) { + + //Get RGB values from the input color + CGFloat red = 0, green = 0, blue = 0, alpha1 = 0; + [self getRed:&red green:&green blue:&blue alpha:&alpha1]; + + //Run our input color's RGB values through the XYZ algorithm to convert them into XYZ values + NSArray *XYZValues = [self arrayOfXYZValuesForR:red G:green B:blue A:alpha1]; + *X = [XYZValues[0] floatValue]; + *Y = [XYZValues[1] floatValue]; + *Z = [XYZValues[2] floatValue]; + *alpha = [XYZValues[3] floatValue]; + + return YES; + } + + return NO; +} + +- (BOOL)getLightness:(CGFloat *)L valueForA:(CGFloat *)A valueForB:(CGFloat *)B alpha:(CGFloat *)alpha { + + if ([self respondsToSelector:@selector(getRed:green:blue:alpha:)]) { + + //Get RGB values from the input color + CGFloat red = 0, green = 0, blue = 0, alpha1 = 0; + [self getRed:&red green:&green blue:&blue alpha:&alpha1]; + + //Run our input color's RGB values through the XYZ algorithm to convert them into XYZ values + NSArray *XYZValues = [self arrayOfXYZValuesForR:red G:green B:blue A:alpha1]; + CGFloat X = [XYZValues[0] floatValue]; + CGFloat Y = [XYZValues[1] floatValue]; + CGFloat Z = [XYZValues[2] floatValue]; + + if (L != nil && A != nil && B != nil) { + //Run our new XYZ values through our LAB algorithm to convert them into LAB values + NSArray *LABValues = [self arrayOfLABValuesForX:X Y:Y Z:Z alpha:alpha1]; + *L = [LABValues[0] floatValue]; + *A = [LABValues[1] floatValue]; + *B = [LABValues[2] floatValue]; + } + + return YES; + } + + return NO; +} + +#pragma mark - Internal Helper Methods + +- (NSArray *)arrayOfXYZValuesForR:(CGFloat)red G:(CGFloat)green B:(CGFloat)blue A:(CGFloat)alpha { + + /* + Let's begin by converting from RGB to sRGB. + We're going to use the Reverse Transformation Equation. + http://en.wikipedia.org/wiki/SRGB + */ + + void (^sRGB)(CGFloat *C); + sRGB = ^(CGFloat *C) { + if (*C > 0.04045) { + *C = pow(((*C + 0.055)/ (1 + 0.055)), 2.40); + } else { + *C /= 12.92; + } + }; + + sRGB(&red); + sRGB(&green); + sRGB(&blue); + + /* + Now we're going to convert to XYZ values, using a matrix multiplication of the linear values + http://upload.wikimedia.org/math/4/3/3/433376fc18cccd887758beffb7e7c625.png + */ + + CGFloat X = (red * 0.4124) + (green * 0.3576) + (blue * 0.1805); + CGFloat Y = (red * 0.2126) + (green * 0.7152) + (blue * 0.0722); + CGFloat Z = (red * 0.0193) + (green * 0.1192) + (blue * 0.9505); + + X *= 100; + Y *= 100; + Z *= 100; + + return @[@(X), @(Y), @(Z), @(alpha)]; +} + +- (NSArray *)arrayOfLABValuesForX:(CGFloat)X Y:(CGFloat)Y Z:(CGFloat)Z alpha:(CGFloat)alpha { + + /* + The corresponding original XYZ values are such that white is D65 with unit luminance (X,Y,Z = 0.9505, 1.0000, 1.0890). + Calculations are also to assume the 2° standard colorimetric observer. + D65: http://en.wikipedia.org/wiki/CIE_Standard_Illuminant_D65 + Standard Colorimetric Observer: http://en.wikipedia.org/wiki/Standard_colorimetric_observer#CIE_standard_observer + + Since we mutiplied our XYZ values by 100 to produce a percentage we should also multiply our unit luminance values by 100. + */ + + X /= (0.9505 * 100); + Y /= (1.0000 * 100); + Z /= (1.0890 * 100); + + /* + Next we need to use the forward transformation function for CIELAB-CIEXYZ conversions + Function: http://upload.wikimedia.org/math/e/5/1/e513d25d50d406bfffb6ed3c854bd8a4.png + */ + + void (^XYZtoLAB)(CGFloat *f); + XYZtoLAB = ^(CGFloat *f) { + if ((*f > pow((6.0/29.0), 3.0)) ) { + *f = pow(*f, 1.0/3.0); + } else { + *f = (1/3)*pow((29.0/6.0), 2.0) * *f + 4/29.0; + } + }; + + XYZtoLAB(&X); + XYZtoLAB(&Y); + XYZtoLAB(&Z); + + /* + Next we get our LAB values using the following equations and the results from the function above + http://upload.wikimedia.org/math/0/0/6/006164b74314e2fdcdc34ac9d0aa6fe4.png + */ + + CGFloat L = (116 * Y) - 16; + CGFloat A = 500 * (X - Y); + CGFloat B = 200 * (Y - Z); + + + return @[@(L), @(A), @(B), @(alpha)]; +} + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIImage+ChameleonPrivate.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIImage+ChameleonPrivate.h new file mode 100755 index 0000000..91fdc45 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIImage+ChameleonPrivate.h @@ -0,0 +1,21 @@ +// +// UIImage+ChameleonPrivate.h +// Chameleon +// +// Created by Vicc Alexander on 6/8/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import + +@interface UIImage (ChameleonPrivate) + +#pragma mark - Class Methods + ++ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize; + +#pragma mark - Instance Methods + +- (UIImage *)imageScaledToSize:(CGSize)newSize; + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIImage+ChameleonPrivate.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIImage+ChameleonPrivate.m new file mode 100755 index 0000000..707c64a --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIImage+ChameleonPrivate.m @@ -0,0 +1,74 @@ +// +// UIImage+ChameleonPrivate.m +// Chameleon +// +// Created by Vicc Alexander on 6/8/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import "UIImage+ChameleonPrivate.h" + +@implementation UIImage (ChameleonPrivate) + +// Would not have been possible without - http://stackoverflow.com/a/1262893 ++ (UIColor *)colorFromImage:(UIImage *)image atPoint:(CGPoint)point { + + //Encapsulate our image + CGImageRef imageRef = image.CGImage; + NSUInteger width = CGImageGetWidth(imageRef); + NSUInteger height = CGImageGetHeight(imageRef); + + //Specify the colorspace we're in + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + + //Extract the data we need + unsigned char *rawData = calloc(height * width * 4, sizeof(unsigned char)); + NSUInteger bytesPerPixel = 4; + NSUInteger bytesPerRow = bytesPerPixel * width; + NSUInteger bitsPerComponent = 8; + CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, + colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); + //Release colorspace + CGColorSpaceRelease(colorSpace); + + //Draw and release image + CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); + CGContextRelease(context); + + //rawData now contains the image data in RGBA8888 + NSInteger byteIndex = (bytesPerRow * point.y) + (point.x * bytesPerPixel); + + //Define our RGBA values + CGFloat red = (rawData[byteIndex] * 1.f) / 255.f; + CGFloat green = (rawData[byteIndex + 1] * 1.f) / 255.f; + CGFloat blue = (rawData[byteIndex + 2] * 1.f) / 255.f; + CGFloat alpha = (rawData[byteIndex + 3] * 1.0) / 255.f; + + //Free our rawData + free(rawData); + + //Return color + return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; +} + ++ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize { + + UIGraphicsBeginImageContextWithOptions(newSize, NO, 1.0); + [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; + UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return newImage; +} + +#pragma mark - Instance Methods + +- (UIImage *)imageScaledToSize:(CGSize)newSize { + + UIGraphicsBeginImageContextWithOptions(newSize, NO, 1.0); + [self drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; + UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return newImage; +} + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UILabel+Chameleon.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UILabel+Chameleon.h new file mode 100755 index 0000000..6bc8e22 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UILabel+Chameleon.h @@ -0,0 +1,15 @@ +// +// UILabel+Chameleon.h +// Chameleon +// +// Created by Vicc Alexander on 9/20/15. +// Copyright © 2015 Vicc Alexander. All rights reserved. +// + +#import + +@interface UILabel (Chameleon) + +- (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR; + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UILabel+Chameleon.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UILabel+Chameleon.m new file mode 100755 index 0000000..bb28af0 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UILabel+Chameleon.m @@ -0,0 +1,18 @@ +// +// UILabel+Chameleon.m +// Chameleon +// +// Created by Vicc Alexander on 9/20/15. +// Copyright © 2015 Vicc Alexander. All rights reserved. +// + +#import "UILabel+Chameleon.h" + +@implementation UILabel (Chameleon) + +- (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR { + + self.font = [UIFont fontWithName:name size:self.font.pointSize]; +} + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UINavigationController+Chameleon.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UINavigationController+Chameleon.h new file mode 100755 index 0000000..6913d49 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UINavigationController+Chameleon.h @@ -0,0 +1,32 @@ +// +// UINavigationController+Chameleon.h +// ChameleonDemo +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import +#import "ChameleonEnums.h" + +@interface UINavigationController (Chameleon) + +/** + * Sets the status bar style for the specified @c UINavigationController and all its child controllers. + * + * @param statusBarStyle The style of the device's status bar. + * + * @note Chameleon introduces a new @c statusBarStyle called @c UIStatusBarStyleContrast. + * + * @since 2.0 + */ +- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle; + +/** + * Hides the hairline view at the bottom of a navigation bar. The default value is @c NO. + * + * @since 2.0.3 + */ +@property (nonatomic, assign) BOOL hidesNavigationBarHairline; + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UINavigationController+Chameleon.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UINavigationController+Chameleon.m new file mode 100755 index 0000000..1599815 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UINavigationController+Chameleon.m @@ -0,0 +1,214 @@ +// +// UINavigationController+Chameleon.m +// ChameleonDemo +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import "UINavigationController+Chameleon.h" +#import + +#import "ChameleonConstants.h" +#import "ChameleonEnums.h" +#import "ChameleonMacros.h" + +#import "NSArray+Chameleon.h" +#import "UIColor+Chameleon.h" +#import "UIViewController+Chameleon.h" + +@interface UINavigationController () + +@property (readwrite) BOOL shouldContrast; +@property (readwrite) BOOL shouldUseLightContent; + +@end + +@implementation UINavigationController (Chameleon) + +@dynamic hidesNavigationBarHairline; + +#pragma mark - Swizzling + ++ (void)load { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + Class class = [self class]; + + SEL originalSelector = @selector(viewDidLoad); + SEL swizzledSelector = @selector(chameleon_viewDidLoad); + + Method originalMethod = class_getInstanceMethod(class, originalSelector); + Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); + + BOOL didAddMethod = + class_addMethod(class, + originalSelector, + method_getImplementation(swizzledMethod), + method_getTypeEncoding(swizzledMethod)); + + if (didAddMethod) { + class_replaceMethod(class, + swizzledSelector, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)); + + } else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } + }); +} + +- (void)chameleon_viewDidLoad { + + [self chameleon_viewDidLoad]; + + UIView *hairlineImageView = [self findHairlineImageViewUnder:self.navigationBar]; + + if (hairlineImageView) { + + if (self.hidesNavigationBarHairline) { + hairlineImageView.hidden = YES; + + } else { + hairlineImageView.hidden = NO; + } + } +} + +- (UIImageView *)findHairlineImageViewUnder:(UIView *)view { + + if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) { + return (UIImageView *)view; + } + + for (UIView *subview in view.subviews) { + UIImageView *imageView = [self findHairlineImageViewUnder:subview]; + if (imageView) { + return imageView; + } + } + + return nil; +} + +#pragma mark - Runtime + +- (void)setShouldContrast:(BOOL)contrast { + + NSNumber *number = [NSNumber numberWithBool:contrast]; + objc_setAssociatedObject(self, @selector(shouldContrast), number, OBJC_ASSOCIATION_RETAIN); +} + +- (BOOL)shouldContrast { + + NSNumber *number = objc_getAssociatedObject(self, @selector(shouldContrast)); + return [number boolValue]; +} + +- (void)setShouldUseLightContent:(BOOL)shouldUseLightContent { + + NSNumber *number = [NSNumber numberWithBool:shouldUseLightContent]; + objc_setAssociatedObject(self, @selector(shouldUseLightContent), number, OBJC_ASSOCIATION_RETAIN); +} + +- (BOOL)shouldUseLightContent { + + NSNumber *number = objc_getAssociatedObject(self, @selector(shouldUseLightContent)); + return [number boolValue]; +} + +- (void)setHidesNavigationBarHairline:(BOOL)hidesNavigationBarHairline { + + NSNumber *number = [NSNumber numberWithBool:hidesNavigationBarHairline]; + objc_setAssociatedObject(self, @selector(hidesNavigationBarHairline), number, OBJC_ASSOCIATION_RETAIN); + + //Find Hairline Image + UIView *hairlineImageView = [self findHairlineImageViewUnder:self.navigationBar]; + + //Check if it exists + if (hairlineImageView) { + + //Check if we should hide it or not + if (hidesNavigationBarHairline) { + hairlineImageView.hidden = YES; + + } else { + hairlineImageView.hidden = NO; + } + } +} + +- (BOOL)hidesNavigationBarHairline { + + NSNumber *number = objc_getAssociatedObject(self, @selector(hidesNavigationBarHairline)); + return [number boolValue]; +} + + +#pragma mark - Public Methods + +- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle { + + if (statusBarStyle == UIStatusBarStyleContrast) { + + self.shouldContrast = YES; + + } else { + + if (statusBarStyle == UIStatusBarStyleLightContent) { + + self.shouldUseLightContent = YES; + + } else { + + self.shouldUseLightContent = NO; + } + + } +} + +#pragma mark - Private Methods + +- (UIStatusBarStyle)preferredStatusBarStyle { + + [super preferredStatusBarStyle]; + + if (self.shouldContrast) { + + return [self contrastingStatusBarStyleForColor:self.navigationBar.barTintColor]; + + } else { + + if (self.shouldUseLightContent) { + + return UIStatusBarStyleLightContent; + + } else { + + return UIStatusBarStyleDefault; + } + } +} + +- (UIStatusBarStyle)contrastingStatusBarStyleForColor:(UIColor *)backgroundColor { + + //Calculate Luminance + CGFloat luminance; + CGFloat red, green, blue; + + //Check for clear or uncalculatable color and assume white + if (![backgroundColor getRed:&red green:&green blue:&blue alpha:nil]) { + return UIStatusBarStyleDefault; + } + + //Relative luminance in colorimetric spaces - http://en.wikipedia.org/wiki/Luminance_(relative) + red *= 0.2126f; green *= 0.7152f; blue *= 0.0722f; + luminance = red + green + blue; + + return (luminance > 0.6f) ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent; +} + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIView+ChameleonPrivate.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIView+ChameleonPrivate.h new file mode 100755 index 0000000..cc3b6ce --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIView+ChameleonPrivate.h @@ -0,0 +1,16 @@ +// +// UIView+ChameleonPrivate.h +// Chameleon +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import + +@interface UIView (ChameleonPrivate) + +- (BOOL)isTopViewInWindow; +- (UIView *)findTopMostViewForPoint:(CGPoint)point; + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIView+ChameleonPrivate.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIView+ChameleonPrivate.m new file mode 100755 index 0000000..bc5203d --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIView+ChameleonPrivate.m @@ -0,0 +1,46 @@ +// +// UIView+ChameleonPrivate.m +// Chameleon +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import "UIView+ChameleonPrivate.h" + +@implementation UIView (ChameleonPrivate) + +- (BOOL)isTopViewInWindow { + + if (!self.window) { + return NO; + } + + CGPoint centerPointInSelf = CGPointMake(CGRectGetMidX(self.bounds), + CGRectGetMidY(self.bounds)); + + CGPoint centerPointOfSelfInWindow = [self convertPoint:centerPointInSelf + toView:self.window]; + + UIView *view = [self.window findTopMostViewForPoint:centerPointOfSelfInWindow]; + BOOL isTopMost = view == self || [view isDescendantOfView:self]; + + return isTopMost; +} + +- (UIView *)findTopMostViewForPoint:(CGPoint)point { + + for (int i = (int)self.subviews.count - 1; i >= 0; i--) { + + UIView *subview = self.subviews[i]; + + if (!subview.hidden && CGRectContainsPoint(subview.frame, point) && subview.alpha > 0.01) { + CGPoint pointConverted = [self convertPoint:point toView:subview]; + return [subview findTopMostViewForPoint:pointConverted]; + } + } + + return self; +} + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIViewController+Chameleon.h b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIViewController+Chameleon.h new file mode 100755 index 0000000..f84b945 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIViewController+Chameleon.h @@ -0,0 +1,64 @@ +// +// UIViewController+Chameleon.h +// Chameleon +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import +#import "ChameleonEnums.h" + +@interface UIViewController (Chameleon) + +/** + * Sets the color theme for the specified view controller using a primary color and the specified content style. + * + * @param primaryColor The primary color. + * @param contentStyle The contentStyle. + * + * @since 2.0 + */ +- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle; + +/** + * Sets the color theme for the specified view controller using a primary color, secondary color, and the specified content style. + * + * @param primaryColor The primary color. + * @param secondaryColor The secondary color. + * @param contentStyle The contentStyle. + * + * @since 2.0 + */ +- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor + withSecondaryColor:(UIColor *)secondaryColor + andContentStyle:(UIContentStyle)contentStyle; + +/** + * Sets the color theme for the specified view controller using a primary color, secondary color, font name, and the specified content style. + * + * @param primaryColor The primary color. + * @param secondaryColor The secondary color. + * @param fontName The main font to use for all text-based elements. + * @param contentStyle The contentStyle. + * + * @since 2.0 + */ +- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor + withSecondaryColor:(UIColor *)secondaryColor + usingFontName:(NSString *)fontName + andContentStyle:(UIContentStyle)contentStyle; + +/** + * Sets the status bar style for the specified @c UIViewController and all its child controllers. + * + * @param statusBarStyle The style of the device's status bar. + * + * @note Chameleon introduces a new @c statusBarStyle called @c UIStatusBarStyleContrast. + * + * @since 2.0 + */ +- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle; + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIViewController+Chameleon.m b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIViewController+Chameleon.m new file mode 100755 index 0000000..b6b4691 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/Pod/Classes/Objective-C/UIViewController+Chameleon.m @@ -0,0 +1,900 @@ +// +// UIViewController+Chameleon.m +// Chameleon +// +// Created by Vicc Alexander on 6/4/15. +// Copyright (c) 2015 Vicc Alexander. All rights reserved. +// + +#import "UIViewController+Chameleon.h" +#import + +#import "ChameleonConstants.h" +#import "ChameleonEnums.h" +#import "ChameleonMacros.h" + +#import "NSArray+Chameleon.h" +#import "UIColor+Chameleon.h" +#import "UIViewController+Chameleon.h" +#import "UIView+ChameleonPrivate.h" +#import "UILabel+Chameleon.h" +#import "UIButton+Chameleon.h" +#import "UIAppearance+Swift.h" + +@interface UIViewController () + +@property (readwrite) BOOL shouldContrast; +@property (readwrite) BOOL shouldUseLightContent; + +@end + +@implementation UIViewController (Chameleon) + + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - Runtime + +- (void)setShouldContrast:(BOOL)contrast { + + NSNumber *number = [NSNumber numberWithBool:contrast]; + objc_setAssociatedObject(self, @selector(shouldContrast), number, OBJC_ASSOCIATION_RETAIN); +} + +- (BOOL)shouldContrast { + + NSNumber *number = objc_getAssociatedObject(self, @selector(shouldContrast)); + return [number boolValue]; +} + +- (void)setShouldUseLightContent:(BOOL)shouldUseLightContent { + + NSNumber *number = [NSNumber numberWithBool:shouldUseLightContent]; + objc_setAssociatedObject(self, @selector(shouldUseLightContent), number, OBJC_ASSOCIATION_RETAIN); +} + +- (BOOL)shouldUseLightContent { + + NSNumber *number = objc_getAssociatedObject(self, @selector(shouldUseLightContent)); + return [number boolValue]; +} + +#pragma mark - Swizzling + ++ (void)load { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + Class class = [self class]; + + SEL originalSelector = @selector(preferredStatusBarStyle); + SEL swizzledSelector = @selector(chameleon_preferredStatusBarStyle); + + Method originalMethod = class_getInstanceMethod(class, originalSelector); + Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); + + BOOL didAddMethod = + class_addMethod(class, + originalSelector, + method_getImplementation(swizzledMethod), + method_getTypeEncoding(swizzledMethod)); + + if (didAddMethod) { + class_replaceMethod(class, + swizzledSelector, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)); + + } else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } + }); +} + +#pragma mark - Methods + + +- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle { + + if (statusBarStyle == UIStatusBarStyleContrast) { + + [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate) withObject:nil afterDelay:0.01]; + self.shouldContrast = YES; + + } else { + + if (statusBarStyle == UIStatusBarStyleLightContent) { + + [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate) withObject:nil afterDelay:0.01]; + self.shouldUseLightContent = YES; + + } else { + + [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate) withObject:nil afterDelay:0.01]; + self.shouldUseLightContent = NO; + } + } + + [self preferredStatusBarStyle]; +} + +- (UIStatusBarStyle)chameleon_preferredStatusBarStyle { + + [self chameleon_preferredStatusBarStyle]; + + if (self.shouldContrast) { + + CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; + UIView *topView = [self.view findTopMostViewForPoint:CGPointMake(CGRectGetMidX(statusBarFrame), 2)]; + + return [self contrastingStatusBarStyleForColor:topView.backgroundColor]; + + } else { + + if (self.shouldUseLightContent) { + return UIStatusBarStyleLightContent; + + } else { + return [self chameleon_preferredStatusBarStyle]; + } + } +} + +- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + if (contentStyle == UIContentStyleContrast) { + + if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + } else { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + } else if (contentStyle == UIContentStyleLight) { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + + } else { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor contentStyle:contentStyle]; + [[self class] customizeButtonWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeNavigationBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeProgressViewWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSliderWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSwitchWithPrimaryColor:primaryColor]; + [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; + [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; +} + +- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor + withSecondaryColor:(UIColor *)secondaryColor + andContentStyle:(UIContentStyle)contentStyle { + + if (contentStyle == UIContentStyleContrast) { + + if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + } else { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + } else if (contentStyle == UIContentStyleLight) { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + + } else { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor contentStyle:contentStyle]; + [[self class] customizeButtonWithPrimaryColor:primaryColor secondaryColor:secondaryColor withContentStyle:contentStyle]; + [[self class] customizeNavigationBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; + [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; +} + +- (void)setThemeUsingPrimaryColor:(UIColor *)primaryColor + withSecondaryColor:(UIColor *)secondaryColor + usingFontName:(NSString *)fontName + andContentStyle:(UIContentStyle)contentStyle { + + if (contentStyle == UIContentStyleContrast) { + + if ([ContrastColor(primaryColor, YES) isEqual:FlatWhite]) { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + } else { + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + } else if (contentStyle == UIContentStyleLight) { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; + + } else { + + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; + } + + [[UILabel appearance] setSubstituteFontName:fontName]; + [[UIButton appearance] setSubstituteFontName:fontName]; + + [[self class] customizeButtonWithPrimaryColor:primaryColor secondaryColor:secondaryColor withContentStyle:contentStyle]; + [[self class] customizeBarButtonItemWithPrimaryColor:primaryColor fontName:fontName fontSize:18 contentStyle:contentStyle]; + [[self class] customizeNavigationBarWithBarColor:primaryColor textColor:ContrastColor(primaryColor, YES) fontName:fontName fontSize:20 buttonColor:ContrastColor(primaryColor, YES)]; + [[self class] customizePageControlWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeProgressViewWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeSearchBarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSegmentedControlWithPrimaryColor:primaryColor withFontName:fontName withFontSize:14 withContentStyle:contentStyle]; + [[self class] customizeSliderWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeStepperWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeSwitchWithPrimaryColor:primaryColor andSecondaryColor:secondaryColor]; + [[self class] customizeTabBarWithBarTintColor:FlatWhite andTintColor:primaryColor]; + [[self class] customizeToolbarWithPrimaryColor:primaryColor withContentStyle:contentStyle]; + [[self class] customizeImagePickerControllerWithPrimaryColor:primaryColor withContentStyle:contentStyle]; +} + +#pragma mark - UIBarButtonItem + ++ (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor + contentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIBarButtonItem appearance] setTintColor:primaryColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; +} + ++ (void)customizeBarButtonItemWithPrimaryColor:(UIColor *)primaryColor + fontName:(NSString *)fontName + fontSize:(float)fontSize + contentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIBarButtonItem appearance] setTintColor:primaryColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; + [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; + + + if ([UIFont fontWithName:fontName size:fontSize]) { + [[UIBarButtonItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:contentColor, NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize]} forState:UIControlStateNormal]; + } +} + +#pragma mark - UIButton + ++ (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIButton appearance] setTintColor:contentColor]; + [[UIButton appearance] setBackgroundColor:primaryColor]; + + + [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setTintColor:primaryColor]; + [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; + +} + ++ (void)customizeButtonWithPrimaryColor:(UIColor *)primaryColor + secondaryColor:(UIColor *)secondaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + UIColor *secondaryContentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + secondaryContentColor = ContrastColor(secondaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + secondaryContentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + secondaryContentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + secondaryContentColor = ContrastColor(secondaryColor, NO); + break; + } + } + + [[UIButton appearance] setTintColor:secondaryContentColor]; + [[UIButton appearance] setBackgroundColor:secondaryColor]; + + + [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setTintColor:primaryColor]; + [[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundColor:ClearColor]; + + [[UIButton appearance] setTitleShadowColor:ClearColor forState:UIControlStateNormal]; + +} + +#pragma mark - UIImagePickerController + ++ (void)customizeImagePickerControllerWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + //Workaround for Swift http://stackoverflow.com/a/28765193 + [[UIButton appearanceWhenContainedWithin:@[[UIView class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + [[UIButton appearanceWhenContainedWithin:@[[UIView class],[UIImagePickerController class]]] setTintColor:ClearColor]; + [[UIButton appearanceWhenContainedWithin:@[[UINavigationBar class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + [[UIButton appearanceWhenContainedWithin:@[[UINavigationBar class],[UIImagePickerController class]]] setTintColor:contentColor]; + [[UIButton appearanceWhenContainedWithin:@[[UITableViewCell class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIView class],[UIImagePickerController class]]] setTintColor:contentColor]; + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class],[UIImagePickerController class]]] setTintColor:contentColor]; + //[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UITableViewCell class],[UIImagePickerController class]]] setBackgroundColor:ClearColor]; +} + +#pragma mark - UILabel + ++ (void)customizeLabelWithPrimaryColor:(UIColor *)primaryColor + fontName:(NSString *)fontName + fontSize:(CGFloat)fontSize + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UILabel appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setTextColor:contentColor]; + [[UILabel appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setTextColor:contentColor]; + + UIFont *font = [UIFont fontWithName:fontName size:fontSize]; + + if (font) { + [[UILabel appearanceWhenContainedIn:[self class], nil] setFont:[UIFont fontWithName:fontName size:fontSize]]; + [[UILabel appearanceWhenContainedIn:[self class], [UITextField class], nil] setFont:[UIFont fontWithName:fontName size:14]]; + [[UILabel appearanceWhenContainedIn:[self class], [UIButton class], nil] setFont:[UIFont fontWithName:fontName size:18]]; + } +} + +#pragma mark - UINavigationBar + ++ (void)customizeNavigationBarWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:primaryColor]; + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTintColor:contentColor]; + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName:contentColor}]; + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setShadowImage:[UIImage new]]; +// [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; +} + ++ (void)customizeNavigationBarWithBarColor:(UIColor *)barColor + textColor:(UIColor *)textColor + buttonColor:(UIColor *)buttonColor { + + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:barColor]; + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTintColor:buttonColor]; + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName:textColor}]; + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setShadowImage:[UIImage new]]; +// [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; +} + ++ (void)customizeNavigationBarWithBarColor:(UIColor *)barColor + textColor:(UIColor *)textColor + fontName:(NSString *)fontName + fontSize:(CGFloat)fontSize + buttonColor:(UIColor *)buttonColor { + + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:barColor]; + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTintColor:buttonColor]; + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setShadowImage:[UIImage new]]; +// [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; + + if ([UIFont fontWithName:fontName size:fontSize]) { + [[UINavigationBar appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{ NSForegroundColorAttributeName:textColor, NSFontAttributeName:[UIFont fontWithName:fontName size:fontSize] }]; + } +} + +#pragma mark - UIPageControl + ++ (void)customizePageControlWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIPageControl appearanceWhenContainedIn:[self class], nil] setCurrentPageIndicatorTintColor:primaryColor]; + [[UIPageControl appearanceWhenContainedIn:[self class], nil] setPageIndicatorTintColor:[primaryColor colorWithAlphaComponent:0.4]]; + [[UIPageControl appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setCurrentPageIndicatorTintColor:contentColor]; + [[UIPageControl appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setPageIndicatorTintColor:[contentColor colorWithAlphaComponent:0.4]]; + [[UIPageControl appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setCurrentPageIndicatorTintColor:contentColor]; + [[UIPageControl appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setPageIndicatorTintColor:[contentColor colorWithAlphaComponent:0.4]]; +} + +#pragma mark - UIProgressView + ++ (void)customizeProgressViewWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIProgressView appearanceWhenContainedIn:[self class], nil] setProgressTintColor:primaryColor]; + [[UIProgressView appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setProgressTintColor:contentColor]; + [[UIProgressView appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setProgressTintColor:contentColor]; + [[UIProgressView appearanceWhenContainedIn:[self class], nil] setTrackTintColor:[UIColor lightGrayColor]]; + [[UIProgressView appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UIProgressView appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; +} + ++ (void)customizeProgressViewWithPrimaryColor:(UIColor *)primaryColor + andSecondaryColor:(UIColor *)secondaryColor { + + [[UIProgressView appearanceWhenContainedIn:[self class], nil] setProgressTintColor:secondaryColor]; + [[UIProgressView appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setProgressTintColor:secondaryColor]; + [[UIProgressView appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setProgressTintColor:secondaryColor]; + [[UIProgressView appearanceWhenContainedIn:[self class], nil] setTrackTintColor:[UIColor lightGrayColor]]; + [[UIProgressView appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UIProgressView appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; +} + +#pragma mark - UISearchBar + ++ (void)customizeSearchBarWithPrimaryColor:(UIColor *)primaryColor withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UISearchBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:primaryColor]; + [[UISearchBar appearanceWhenContainedIn:[self class], nil] setBackgroundColor:primaryColor]; + [[UISearchBar appearanceWhenContainedIn:[self class], nil] setTintColor:contentColor]; + [[UISearchBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; +} + +#pragma mark - UISegmentedControl + ++ (void)customizeSegmentedControlWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UISegmentedControl appearanceWhenContainedIn:[self class], nil] setTintColor:primaryColor]; + [[UISegmentedControl appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] + setTintColor:contentColor]; + [[UISegmentedControl appearanceWhenContainedIn:[self class], [UIToolbar class], nil] + setTintColor:contentColor]; +} + ++ (void)customizeSegmentedControlWithPrimaryColor:(UIColor *)primaryColor + withFontName:(NSString *)fontName + withFontSize:(CGFloat)fontSize + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UISegmentedControl appearanceWhenContainedIn:[self class], nil] setTintColor:primaryColor]; + [[UISegmentedControl appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] + setTintColor:contentColor]; + [[UISegmentedControl appearanceWhenContainedIn:[self class], [UIToolbar class], nil] + setTintColor:contentColor]; + + UIFont *font = [UIFont fontWithName:fontName size:fontSize]; + if (font) { + [[UISegmentedControl appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{NSFontAttributeName:font} + forState:UIControlStateNormal]; + } +} + +#pragma mark - UISlider + ++ (void)customizeSliderWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UISlider appearanceWhenContainedIn:[self class], nil] setMinimumTrackTintColor:primaryColor]; + [[UISlider appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setMinimumTrackTintColor:contentColor]; + [[UISlider appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setMinimumTrackTintColor:contentColor]; + [[UISlider appearanceWhenContainedIn:[self class], nil] setMaximumTrackTintColor:[UIColor lightGrayColor]]; + [[UISlider appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UISlider appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; +} + ++ (void)customizeSliderWithPrimaryColor:(UIColor *)primaryColor + andSecondaryColor:(UIColor *)secondaryColor { + + [[UISlider appearanceWhenContainedIn:[self class], nil] setMinimumTrackTintColor:secondaryColor]; + [[UISlider appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setMinimumTrackTintColor:secondaryColor]; + [[UISlider appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setMinimumTrackTintColor:secondaryColor]; + [[UISlider appearanceWhenContainedIn:[self class], nil] setMaximumTrackTintColor:[UIColor lightGrayColor]]; + [[UISlider appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UISlider appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setMaximumTrackTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; +} + +#pragma mark - UIStepper + ++ (void)customizeStepperWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIStepper appearanceWhenContainedIn:[self class], nil] setTintColor:primaryColor]; + [[UIStepper appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] + setTintColor:contentColor]; + [[UIStepper appearanceWhenContainedIn:[self class], [UIToolbar class], nil] + setTintColor:contentColor]; +} + +#pragma mark - UISwitch + ++ (void)customizeSwitchWithPrimaryColor:(UIColor *)primaryColor { + + [[UISwitch appearanceWhenContainedIn:[self class], nil] setOnTintColor:primaryColor]; + [[UISwitch appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setOnTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; + [[UISwitch appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setOnTintColor:[[primaryColor darkenByPercentage:0.25] flatten]]; +} + ++ (void)customizeSwitchWithPrimaryColor:(UIColor *)primaryColor + andSecondaryColor:(UIColor *)secondaryColor { + + [[UISwitch appearanceWhenContainedIn:[self class], nil] setOnTintColor:secondaryColor]; + [[UISwitch appearanceWhenContainedIn:[self class], [UINavigationBar class], nil] setOnTintColor:secondaryColor]; + [[UISwitch appearanceWhenContainedIn:[self class], [UIToolbar class], nil] setOnTintColor:secondaryColor]; +} + +#pragma mark - UITabBar + ++ (void)customizeTabBarWithBarTintColor:(UIColor *)barTintColor + andTintColor:(UIColor *)tintColor { + + [[UITabBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:barTintColor]; + [[UITabBar appearanceWhenContainedIn:[self class], nil] setTintColor:tintColor]; +} + ++ (void)customizeTabBarWithBarTintColor:(UIColor *)barTintColor + tintColor:(UIColor *)tintColor + fontName:(NSString *)fontName + fontSize:(CGFloat)fontSize { + + [[UITabBar appearanceWhenContainedIn:[self class], nil] setBarTintColor:barTintColor]; + [[UITabBar appearanceWhenContainedIn:[self class], nil] setTintColor:tintColor]; + + UIFont *font = [UIFont fontWithName:fontName size:fontSize]; + if (font) { + [[UITabBarItem appearanceWhenContainedIn:[self class], nil] setTitleTextAttributes:@{NSFontAttributeName:font} + forState:UIControlStateNormal]; + } +} + +#pragma mark - UIToolbar + ++ (void)customizeToolbarWithPrimaryColor:(UIColor *)primaryColor + withContentStyle:(UIContentStyle)contentStyle { + + UIColor *contentColor; + switch (contentStyle) { + case UIContentStyleContrast: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + case UIContentStyleLight: { + contentColor = [UIColor whiteColor]; + break; + } + case UIContentStyleDark: { + contentColor = FlatBlackDark; + break; + } + default: { + contentColor = ContrastColor(primaryColor, NO); + break; + } + } + + [[UIToolbar appearanceWhenContainedIn:[self class], nil] setTintColor:contentColor]; + [[UIToolbar appearanceWhenContainedIn:[self class], nil] setBarTintColor:primaryColor]; + [[UIToolbar appearanceWhenContainedIn:[self class], nil] setClipsToBounds:YES]; +} + + +#pragma mark - Private Methods + +- (UIStatusBarStyle)contrastingStatusBarStyleForColor:(UIColor *)backgroundColor { + + //Calculate Luminance + CGFloat luminance; + CGFloat red, green, blue; + + //Check for clear or uncalculatable color and assume white + if (![backgroundColor getRed:&red green:&green blue:&blue alpha:nil]) { + return UIStatusBarStyleDefault; + } + + //Relative luminance in colorimetric spaces - http://en.wikipedia.org/wiki/Luminance_(relative) + red *= 0.2126f; green *= 0.7152f; blue *= 0.0722f; + luminance = red + green + blue; + + return (luminance > 0.6f) ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent; +} + +#pragma GCC diagnostic pop + +@end diff --git a/HeadsUpper/Pods/ChameleonFramework/README.md b/HeadsUpper/Pods/ChameleonFramework/README.md new file mode 100644 index 0000000..2dbbdf0 --- /dev/null +++ b/HeadsUpper/Pods/ChameleonFramework/README.md @@ -0,0 +1,768 @@ +

+ Chameleon by Vicc Alexander +

+ +

+ Downloads + Platform: iOS 8+ + Language: Swift 2 + Carthage compatible + Cocoapods compatible + License: MIT

+ Donate +

+ +## Introduction + +**Chameleon** is a lightweight, yet powerful, color framework for iOS (Objective-C & Swift). It is built on the idea that software applications should function effortlessly while simultaneously maintaining their beautiful interfaces. + +With Chameleon, you can easily stop tinkering with RGB values, wasting hours figuring out the right color combinations to use in your app, and worrying about whether your text will be readable on the various background colors of your app. + +### Features + +

+ Features +

+ +### App Showcase ![New](http://i.imgur.com/BX3b9ES.png) + +###### In an upcoming update we'll begin showcasing some of the best apps and companies making use of Chameleon. If you'd like to see your app featured in this section, make sure to add it [here](https://airtable.com/shrr1WK6dLQBZfXV0). + +## Table of Contents +[● Product Features](https://github.com/ViccAlexander/Chameleon#-product-features) +[● Requirements](https://github.com/ViccAlexander/Chameleon#%EF%B8%8F-requirements) +[● License](https://github.com/ViccAlexander/Chameleon#-license) +[● Contributions](https://github.com/ViccAlexander/Chameleon#-contributions) +[● Documentation](https://github.com/ViccAlexander/Chameleon#-documentation) +[● Storyboard Add-On](https://github.com/ViccAlexander/Chameleon#storyboard-add-on) +[● Author](https://github.com/ViccAlexander/Chameleon#-author) +[● Special Thanks](https://github.com/ViccAlexander/Chameleon#-special-thanks) +[● To Do List](https://github.com/ViccAlexander/Chameleon#-to-do-list) +[● Change Log](https://github.com/ViccAlexander/Chameleon#-change-log) + + + +## 🌟 Product Features + +### 100% Flat & Gorgeous + +Chameleon features over 24 hand-picked colors that come in both light and dark shades. + +

+ Swatches +

+ +### Flat Color Schemes + +Chameleon equips you with 3 different classes of flat color schemes that can be generated from a flat or non-flat color. *In the examples below, the white stars indicate the color used to generate the schemes.* + +###### Analogous Flat Color Scheme + +

+ Analogous Scheme +

+ +###### Complementary Flat Color Scheme +

+ Complementary Scheme +

+ +###### Triadic Flat Color Scheme +

+ Triadic Scheme +

+ +### Contrasting Text +With a plethora of color choices available for text, it's difficult to choose one that all users will appreciate and be able to read. Whether you're in doubt of your text and tint color choices, or afraid to let users customize their profile colors because it may disturb the legibility or usability of the app, you no longer have to worry. With Chameleon, you can ensure that all text stands out independent of the background color. + +Oh... Chameleon works with the status bar as well. : ) + +

+ Status Bar +

+ +### Themes ![Beta](http://i.imgur.com/JyYiUJq.png) + +Chameleon now allows you easily theme your app with as little as **one line of code**. You can set a theme for all your views, and for specific views as well. + +

+ Themes +

+ +### Colors From Images + +Chameleon allows you to seamlessly extract non-flat or flat color schemes from images without hassle. You can also generate the average color from an image with ease. You can now mold the UI colors of a profile, or product based on an image! + +

+ Colors from images +

+ +### Gradient Colors +With iOS 7 & 8, Apple mainstreamed flat colors. Now, with the release of iOS 9, Chameleon strives to elevate the game once more. Say hello to gradient colors. Using one line of code, you can easily set any object's color properties to a gradient (background colors, text colors, tint colors, etc). Other features, like Chameleon's contrasting feature, can also be applied to create a seamless product. Experimentation is encouraged, and gutsiness is applauded! + +

+ Gradients +

+ +![](http://i.imgur.com/2jN72eh.png) + +### Xcode Quick Help Documentation + +Chameleon's documentation, while written as clearly and concisely as possible may still render some slightly confused. But don't fret! Staying true to our vision of simplifying the entire color process, we added Xcode Quick Help's Documentation Support! Simply highlight a Chameleon method or tap it with three fingers to find out more about what it is and what it does! + +

+ Xcode Quick Help Documentation +

+ +### Storyboard Palette + +If you're like me and love to use storyboard, Chameleon's got you covered. We've provided you with a quick and easy way to access Chameleon colors right from Storyboard, and any other app that uses the color picker (i.e. TextEdit). + +

+ Chameleon Palette +

+ +## ⚠️ Requirements + +* Objective-C or Swift +* Requires a minimum of iOS 7.0 for Objective-C (No active development for anything earlier, but may work with 6.0) and a minimum of iOS 8.0 for Swift. +* Requires Xcode 6.3 for use in any iOS Project + +## 🔑 License +Chameleon is released and distributed under the terms and conditions of the [MIT license](https://github.com/ViccAlexander/Chameleon/blob/master/LICENSE.md). + +## 👥 Contributions +If you run into problems, please open up an issue. We also actively welcome pull requests. By contributing to Chameleon you agree that your contributions will be licensed under its MIT license. + +If you use Chameleon in your app we would love to hear about it! Drop Vicc a line on [twitter](http://twitter.com/viccsmind). + +## 📗 Documentation +All methods, properties, and types available in Chameleon are documented below. + +#####Documentation Table of Contents +[● Installation](https://github.com/ViccAlexander/Chameleon#installation) +[● Storyboard-Add On](https://github.com/ViccAlexander/Chameleon#storyboard-add-on-) +[● Usage](https://github.com/ViccAlexander/Chameleon#usage) +[● UIColor Methods](https://github.com/ViccAlexander/Chameleon#uicolor-methods) +[● Colors From Images](https://github.com/ViccAlexander/Chameleon#colors-from-images--1) +[● UIStatusBarStyle Methods](https://github.com/ViccAlexander/Chameleon#uistatusbarstyle-methods) +[● Color Scheme Methods](https://github.com/ViccAlexander/Chameleon#color-schemes-methods) +[● Theme Methods](https://github.com/ViccAlexander/Chameleon#theme-methods-) + +###Installation +####CocoaPods Installation +Chameleon is now available on [CocoaPods](http://cocoapods.org). Simply add the following to your project Podfile, and you'll be good to go. + +######Objective-C +```ruby +use_frameworks! + +pod 'ChameleonFramework' +``` +######Swift +```ruby +use_frameworks! + +pod 'ChameleonFramework/Swift' +``` + +###### **Note:** Swift support for Chameleon 2.0 is almost complete. + +======= +####Carthage Installation +Add this to your Cartfile: +```ruby +github "ViccAlexander/Chameleon" +``` + +======= +####Manual Installation +If you rather install this framework manually, just drag and drop the Chameleon folder into your project, and make sure you check the following boxes. Note: Don't forget to manually import the *QuartzCore* & *CoreGraphics* framework if you plan on using gradient colors! + +

+ Manual Installation +

+ +If you're working with Swift and are manually installing Chameleon, there's an additional step. Make sure to download and drag the following file, [ChameleonShorthand.swift](https://github.com/ViccAlexander/Chameleon/blob/master/Pod/Classes/Swift/ChameleonShorthand.swift), into your project, and you'll be good to go. + +####Storyboard Add-On +Using Chameleon's awesome palette in Storyboard is easy! Simply download and install [Chameleon Palette](https://github.com/ViccAlexander/Chameleon/blob/master/Extras/Chameleon.dmg?raw=true). + +Once installed, make sure to restart XCode. You'll find all of Chameleon's colors in the Palette Color Picker whenever they're needed! :) + +

+ Chameleon Palette +

+ +

+ Chameleon Palette +

+ +###Usage +To use the myriad of features in Chameleon, include the following import: + +###### If you installed Chameleon using cocoapods: + +######Objective-C + +``` objective-c +#import +``` + +######Swift: +``` swift +import ChameleonFramework +``` + +###### If you installed Chameleon manually: +``` objective-c +#import "Chameleon.h" +``` +###UIColor Methods +[● Flat Colors](https://github.com/ViccAlexander/Chameleon#flat-colors) +[● Random Colors](https://github.com/ViccAlexander/Chameleon#random-colors) +[● Complementary Colors](https://github.com/ViccAlexander/Chameleon#complementary-colors) +[● Contrasting Colors](https://github.com/ViccAlexander/Chameleon#contrasting-colors) +[● Flattening Non-Flat Colors](https://github.com/ViccAlexander/Chameleon#flattening-non-flat-colors) +[● Gradient Colors](https://github.com/ViccAlexander/Chameleon#gradient-colors-1) +[● Hex Colors](https://github.com/ViccAlexander/Chameleon#hex-colors-) +[● Lighter & Darker Colors](https://github.com/ViccAlexander/Chameleon#lighter-and-darker-colors-) + +####Flat Colors +Using a flat color is as easy as adding any other color in your app (if not easier). For example, to set a view's background property to a flat color with a dark shade, you simply have to do the following: + +#####Normal Convention: + +######Objective-C +``` objective-c +self.view.backgroundColor = [UIColor flatGreenColorDark]; +``` +######Swift +``` swift +view.backgroundColor = UIColor.flatGreenColorDark() +``` + +#####Chameleon Shorthand: + +######Objective-C +``` objective-c +self.view.backgroundColor = FlatGreenDark; +``` +######Swift +``` swift +view.backgroundColor = FlatGreenDark() +``` + +Setting the color for a light shade is the same, except without adding the *Dark* suffix. (By default, all colors without a *Dark* suffix are light shades). For example: + +#####Normal Convention: +######Objective-C +``` objective-c +self.view.backgroundColor = [UIColor flatGreenColor]; +``` +######Swift +``` swift +view.backgroundColor = UIColor.flatGreenColor() +``` + +#####Chameleon Shorthand: + +######Objective-C +``` objective-c +self.view.backgroundColor = FlatGreen; +``` +######Swift +``` swift +view.backgroundColor = FlatGreen() +``` + +####Random Colors +There are four ways to generate a random flat color. If you have no preference as to whether you want a light shade or a dark shade, you can do the following: + +#####Normal Convention: +######Objective-C +``` objective-c +self.view.backgroundColor = [UIColor randomFlatColor]; +``` +######Swift +``` swift +view.backgroundColor = UIColor.randomFlatColor() +``` + +#####Chameleon Shorthand: +###### Objective-C +``` objective-c +self.view.backgroundColor = RandomFlatColor; +``` + +######Swift +``` swift +view.backgroundColor = RandomFlatColor() +``` + +Otherwise, you can perform the following method call to specify whether it should return either a light or dark shade: + +#####Normal Convention: +######Objective-C +``` objective-c +[UIColor colorWithRandomFlatColorOfShadeStyle:UIShadeStyleLight]; +``` + +######Swift +``` swift +UIColor(randomFlatColorOfShadeStyle:.Light) +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +RandomFlatColorWithShade(UIShadeStyleLight); +``` +######Swift +``` swift +RandomFlatColorWithShade(.Light) +``` + +**UIShadeStyles:** +- `UIShadeStyleLight` (`UIShadeStyle.Light` in Swift) +- `UIShadeStyleDark` (`UIShadeStyle.Dark` in Swift) + +##### Choosing A Random Color From a List of Colors ![New](http://i.imgur.com/BX3b9ES.png) + +If you need to be a bit more selective and only display a random color from a set list of colors, you can use the following method: + +#####Normal Convention: +######Objective-C +``` objective-c +[UIColor colorWithRandomColorInArray:@[FlatWhite, FlatRed, FlatBlue]]; +``` + +######Swift +``` swift +TBA +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +RandomFlatColorInArray(@[FlatWhite, FlatRed, FlatBlue]) +``` +######Swift +``` swift +TBA +``` + +##### Choosing A Random Flat Color But Excluding A Few ![New](http://i.imgur.com/BX3b9ES.png) + +Last but certainly not least, you can also choose form the list of random colors and exclude the ones you don't want. For example say you want to randomly select a flat color for a user's profile, but don't want to use any blacks, grays, or whites. You can simply do: + +#####Normal Convention: +######Objective-C +``` objective-c +[UIColor colorWithRandomFlatColorExcludingColorsInArray:@[FlatBlack, FlatBlackDark, FlatGray, FlatGrayDark, FlatWhite, FlatWhiteDark]]; +``` + +######Swift +``` swift +TBA +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +RandomFlatColorExcluding(@[FlatBlack, FlatBlackDark, FlatGray, FlatGrayDark, FlatWhite, FlatWhiteDark]) +``` +######Swift +``` swift +TBA +``` + +####Complementary Colors +To generate a complementary color, perform the following method call, remembering to specify the color whose complement you want: + +#####Normal Convention: +######Objective-C +``` objective-c +[UIColor colorWithComplementaryFlatColorOf:(UIColor *)someUIColor]; +``` + +######Swift +``` swift +UIColor(complementaryFlatColorOf:someUIColor) +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +ComplementaryFlatColorOf(color); +``` + +######Swift +``` swift +ComplementaryFlatColorOf(color) +``` + +####Contrasting Colors +The contrasting color feature returns either a dark color a light color depending on what the Chameleon algorithm believes is a better choice. You can specify whether the dark or light colors are flat: *`([UIColor flatWhiteColor]` & `[UIColor flatBlackColorDark]`)* or non-flat *(`[UIColor whiteColor]` & `[UIColor blackColor]`).* + +If you're trying to set a `UILabel's textColor` property, make sure you provide the `UILabel's backgroundColor`. If your label has a clear `backgroundColor`, just provide the `backgroundColor` property of the object directly behind the `UILabel`. + +Here's an example: + +#####Normal Convention: +######Objective-C +``` objective-c +[UIColor colorWithContrastingBlackOrWhiteColorOn:(UIColor *)backgroundColor isFlat:(BOOL)flat]; +``` + +######Swift +``` swift +UIColor(contrastingBlackOrWhiteColorOn:UIColor!, isFlat:Bool) +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +ContrastColor(backgroundColor, isFlat); +``` + +######Swift +``` swift +ContrastColor(backgroundColor, isFlat) +``` + +####Flattening Non-Flat Colors +As mentioned previously, this feature is unique to Chameleon. While this feature is in its early stages of operation and can be improved, it is accurate in finding the nearest flat version of any color in the spectrum, and very simple to use: + +#####Normal Convention: +######Objective-C +``` objective-c +[(UIColor *)color flatten]; +``` + +######Swift +``` swift +UIColor.pinkColor().flatten() +``` + +#### Gradient Colors +Using a gradient to color an object usually requires a couple of lines of code plus many more lines to superimpose smart contrasting text. Thankfully, Chameleon takes care of that for you. We've introduced a new way to have multicolored objects, and that's with gradients! + +#####Gradient Styles +Chameleon provides three simple gradient styles. Gradients can be created from any number of colors you desire as long as at least two colors are provided. Don't forget that the contrasting text feature is also compatible with gradient colors! + +**UIGradientStyles:** +* `UIGradientStyleLeftToRight` (UIGradientStyle.LeftToRight in Swift) +* `UIGradientStyleTopToBottom` (UIGradientStyle.TopToBottom in Swift) +* `UIGradientStyleRadial` (UIGradientStyle.Radial in Swift) + +#####Normal Convention: +######Objective-C +``` objective-c +[UIColor colorWithGradientStyle:(UIGradientStyle)gradientStyle withFrame:(CGRect)frame andColors:(NSArray *)colors]; +``` + +######Swift +``` swift +UIColor(gradientStyle:UIGradientStyle, withFrame:CGRect, andColors:[UIColor]) +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +GradientColor(gradientStyle, frame, colors); +``` + +######Swift +``` swift +GradientColor(gradientStyle, frame, colors) +``` + +**Objective-C Note**: If you use the Chameleon Shorthand, and use the `NSArray` literal ```@[]``` to set the array of colors, make sure you add parenthesis around it, or else you'll get an error. + +Note: `UIGradientStyleRadial` only uses a maximum of 2 colors at the moment. So if more colors are provided, they will not show. + +#### Hex Colors + +One of the most requested features, *hex colors*, is now available. You can simply provide a hex string with or without a *#* sign: + +#####Normal Convention: +######Objective-C +``` objective-c +[UIColor colorWithHexString:(NSString *)string]; +``` + +######Swift +``` swift +UIColor(hexString:string) +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +HexColor(hexString) +``` + +######Swift +``` swift +HexColor(hexString) +``` +#### Hex Values ![New](http://i.imgur.com/BX3b9ES.png) + +Retrieving the `hexValue` of a UIColor is just as easy. + +######Objective-C +``` objective-c +[FlatGreen hexValue]; //Returns @"2ecc71" +``` + +######Swift +``` swift +FlatGreen.hexValue //Returns @"2ecc71" +``` + +#### Lighter and Darker Colors + +Sometimes all you need is a color a shade lighter or a shade darker. Well for those rare, but crucial moments, Chameleon's got you covered. You can now lighten any color the following way: + +#####Normal Convention: +######Objective-C +``` objective-c +[color lightenByPercentage:(CGFloat)percentage]; +``` + +######Swift +``` swift +color.lightenByPercentage(percentage: CGFloat) +``` + +You can also generate a darker version of a color: + +#####Normal Convention: +######Objective-C +``` objective-c +[color darkenByPercentage:(CGFloat)percentage]; +``` + +######Swift +``` swift +color.darkenByPercentage(percentage: CGFloat) +``` + +### Colors From Images + +Chameleon now supports the extraction of colors from images. You can either generate both flat and non-flat color schemes from an image, or easily extract the average color. + +To generate a color scheme simply do the following: +#####Normal Convention: +######Objective-C +``` objective-c +[NSArray arrayOfColorsFromImage:(UIImage *)image withFlatScheme:(BOOL)flatScheme]; +``` + +######Swift (**Array extension missing**) +``` swift +NSArray(ofColorsFromImage: UIImage, withFlatScheme: Bool) +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +ColorsFromImage(image, isFlatScheme) +``` + +######Swift +``` swift +ColorsFromImage(image, isFlatScheme) +``` + +To extract the average color from an image, you can also do: +#####Normal Convention: +######Objective-C +``` objective-c +[UIColor colorWithAverageColorFromImage:(UIImage *)image]; +``` + +######Swift +``` swift +UIColor(averageColorFromImage: UIImage) +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +AverageColorFromImage(image) +``` + +######Swift +``` swift +AverageColorFromImage(image) +``` + +###UIStatusBarStyle Methods +####Contrasting UIStatusBarStyle +Many apps on the market, even the most popular ones, overlook this aspect of a beautiful app: the status bar style. Chameleon has done something no other framework has... it has created a new status bar style: `UIStatusBarStyleContrast`. Whether you have a `ViewController` embedded in a `NavigationController`, or not, you can do the following: + +#####Normal Convention: +######Objective-C +``` objective-c +[self setStatusBarStyle:UIStatusBarStyleContrast]; +``` + +######Swift +``` swift +self.setStatusBarStyle(UIStatusBarStyleContrast) +``` +######**Note**: Make sure that the key *View controller-based status bar appearance* in **Info.plist** is set to `YES`. + +###Color Schemes Methods +######**Note**: *Due to the limited number of flat colors currently available, color schemes may return results that reuse certain flat colors. Because of this redundancy, we have provided an option to return either a flat color scheme or a non-flat color scheme until more flat colors are added to the inventory.* + +The initial color can be either a non-flat color or flat color. Chameleon will return an `NSArray` of 5 `UIColors` in which the original color will be the third object of the scheme. This allows for Chameleon to designate the colors of the color scheme (2 colors counter-clockwise and 2 clockwise from the initial color), and thus, the chosen colors are aligned specifically in that order. + +####Analogous Color Scheme +An analogous color scheme uses three adjacent colors on the color wheel. According to Wikipedia, it’s best used with either warm or cool colors, creating a cohesive collection with certain temperature qualities as well as proper color harmony; however, this particular scheme lacks contrast and is less vibrant than complementary schemes. Within the scheme, choose one color to dominate and two to support. The remaining two colors should be used (along with black, white or gray) as accents. + +####Complementary Color Scheme +A complementary color scheme uses opposite colors on the color wheel. To put into slightly more technical terms, they are two colors that, when combined, produce a neutral color. Complementary colors are tricky to use extensively, but work well when you want a point of emphasis. Complementary colors are generally not favorable to use for text. + +####Triadic Color Scheme +A triadic scheme uses evenly spaced colors on the color wheel. The colors tend to be richly vivid and offer a higher degree of contrast while, at the same time, retain color harmony. Let one color dominate and use the two others for accent. + +####Getting Colors in a Color Scheme +To retrieve an array of colors, first make sure to initialize an NSMutableArray (in case you want to use the same array to replace with different colors later): + +#####Normal Convention: +######Objective-C +``` objective-c +NSMutableArray *colorArray = [NSMutableArray alloc] initWithArray:[NSArray arrayOfColorsWithColorScheme:(ColorScheme)colorScheme + with:(UIColor *)color + flatScheme:(BOOL)isFlatScheme]]; +``` + +######Swift +``` swift +var colorArray = NSArray(ofColorsWithColorScheme:ColorScheme, with:UIColor!, flatScheme:Bool) +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +NSMutableArray *colorArray = [[NSMutableArray alloc] initWithArray:ColorScheme(colorSchemeType, color, isFlatScheme)]; +``` + +######Swift +``` swift +var colorArray = ColorSchemeOf(colorSchemeType, color, isFlatScheme) +``` + +#####Example: +Assuming you want to generate an analogous color scheme for the light shade of Flat Red, perform the following method call: + +#####Normal Convention: +######Objective-C +``` objective-c +NSMutableArray *colorArray = [NSMutableArray alloc] initWithArray:[NSArray arrayOfColorsWithColorScheme:ColorSchemeAnalogous + with:[UIColor flatRedColor] + flatScheme:YES]]; +``` + +######Swift +``` swift +var colorArray = NSArray(ofColorsWithColorScheme:ColorScheme.Analogous, with:UIColor.flatRedColor(), flatScheme:true) +``` + +#####Chameleon Shorthand: +######Objective-C +``` objective-c +NSMutableArray *colorArray = [[NSMutableArray alloc] initWithArray:ColorScheme(ColorSchemeAnalogous, FlatRed, YES)]; +``` + +######Swift +``` swift +var colorArray = ColorSchemeOf(ColorScheme.Analogous, FlatRed(), true) +``` + +You can then retrieve each individual color the same way you would normally retrieve any object from an array: + +######Objective-C +```objective-c +UIColor *firstColor = colorArray[0]; +``` + +######Swift +``` swift +var firstColor = colorArray[0] as! UIColor +``` + +###Theme Methods + +With Chameleon, you can now specify a global color theme with simply one line of code (It even takes care of dealing with the status bar style as well)! Here's one of three methods to get you started. `ContentStyle` allows you to decide whether text and a few other elements should be white, black, or whichever contrasts more over any UI element's `backgroundColor`. + +To set a global theme, you can do the following in your app delegate: + +#####Normal Convention: +######Objective-C +``` objective-c +[Chameleon setGlobalThemeUsingPrimaryColor:(UIColor *)color withContentStyle:(UIContentStyle)contentStyle]; +``` + +But what if you want a different theme for a specific `UIViewController?` No problem, Chameleon allows you to override the global theme in any `UIViewController` and `UINavigationController`, by simply doing the following: + +#####Normal Convention: +######Objective-C +```objective-c +//This would go in the controller you specifically want to theme differently +[self setThemeUsingPrimaryColor:FlatMint withSecondaryColor:FlatBlue andContentStyle:UIContentStyleContrast]; +``` + +###### **Note:** In order for the status bar style to automatically be set using a theme, you need to make sure that the *View controller-based status bar appearance* key in **Info.plist** is set to `NO`. + +#### Navigation Bar Hairline + +![No Hairline](http://i.imgur.com/tjwx53y.png) + +As of `2.0.3` the navigation bar hairline view is no longer hidden by default. However, if you're seeking a true flat look (like the image above), you can hide the hairline at the bottom of the navigation bar by doing the following: + +######Objective-C +```objective-c +[self.navigationController setHidesNavigationBarHairline:YES]; + +//or + +self.navigationController.hidesNavigationBarHairline = YES; +``` + +## 👑 Author +Chameleon was developed by **Vicc Alexander** [(@ViccsMind)](https://twitter.com/viccsmind) in 2014. Currently, it is being maintained by [@ViccAlexander](https://github.com/ViccAlexander) and [@Bre7](https://github.com/bre7). + +##### Support ☕️ +If you enjoy Chameleon and would like to buy us a coffee we'd appreciate it. Donate + +## 📝 To Do List +* ~~Cocoapods Support~~ ![1.0.1](http://i.imgur.com/8Li5aRR.png) +* ~~Table of Contents~~ ![1.0.1](http://i.imgur.com/8Li5aRR.png) +* ~~Storyboard Color Picker Add-On~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) +* ~~Xcode In-App Documentation~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) +* ~~Switch from RGB values over to HSB and LAB~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) +* ~~Gradient Colors~~ ![1.1.0](http://i.imgur.com/Py4QvaK.png) +* ~~Update GradientStyle & ShadeStyle Syntax~~ ![1.1.1](http://i.imgur.com/AHxj8Rb.png) +* ~~Add Radial Gradient Support~~ ![1.1.1](http://i.imgur.com/AHxj8Rb.png) +* ~~Fix Swift Conflict with `initWithArray:for:flatScheme:` method~~ ![1.1.12](http://i.imgur.com/7NrZ7yx.png) +* ~~Swift Support~~ ![1.1.3](http://i.imgur.com/WgpBlLo.png) +* ~~Color Scheme From Images~~ ![2.0.0](http://i.imgur.com/HdE8kjQ.png) +* ~~UIAppearance Convenience Methods~~ ![2.0.0](http://i.imgur.com/HdE8kjQ.png) +* ~~Add option to hide `NavigationBar` hairline~~ ![2.0.3](http://i.imgur.com/DmlOKPJ.png) +* Allow Gradient Colors to Adapt To Frame Changes + +## 📄 Change Log + +### See [Changelog.md](https://github.com/ViccAlexander/Chameleon/blob/master/CHANGELOG.md) 👀 + diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h new file mode 120000 index 0000000..f9dc7db --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h new file mode 120000 index 0000000..56feb9f --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFImageDownloader.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFImageDownloader.h new file mode 120000 index 0000000..ce47c92 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFImageDownloader.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 120000 index 0000000..67519d9 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h new file mode 120000 index 0000000..68fc774 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFNetworking.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFNetworking.h new file mode 120000 index 0000000..a5a38da --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworking.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h new file mode 120000 index 0000000..fd1322d --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFSecurityPolicy.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h new file mode 120000 index 0000000..ca8209b --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h new file mode 120000 index 0000000..e36a765 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h new file mode 120000 index 0000000..835101d --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLSessionManager.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 120000 index 0000000..c534ebf --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h new file mode 120000 index 0000000..8f2e221 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h new file mode 120000 index 0000000..74f6649 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h new file mode 120000 index 0000000..a95d673 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h new file mode 120000 index 0000000..95017cc --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h new file mode 120000 index 0000000..730b167 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h new file mode 120000 index 0000000..8efd826 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h new file mode 120000 index 0000000..c8df6ef --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/Chameleon.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/Chameleon.h new file mode 120000 index 0000000..f0cd1b4 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/Chameleon.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/Chameleon.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/ChameleonConstants.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/ChameleonConstants.h new file mode 120000 index 0000000..51aa580 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/ChameleonConstants.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/ChameleonConstants.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/ChameleonEnums.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/ChameleonEnums.h new file mode 120000 index 0000000..8dae61b --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/ChameleonEnums.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/ChameleonEnums.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/ChameleonMacros.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/ChameleonMacros.h new file mode 120000 index 0000000..f8f6295 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/ChameleonMacros.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/ChameleonMacros.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/Chameleon_.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/Chameleon_.h new file mode 120000 index 0000000..79c30ab --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/Chameleon_.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/Chameleon_.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/NSArray+Chameleon.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/NSArray+Chameleon.h new file mode 120000 index 0000000..7ff10d4 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/NSArray+Chameleon.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/NSArray+Chameleon.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIAppearance+Swift.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIAppearance+Swift.h new file mode 120000 index 0000000..63a7d28 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIAppearance+Swift.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/UIAppearance+Swift.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIButton+Chameleon.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIButton+Chameleon.h new file mode 120000 index 0000000..0fac48a --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIButton+Chameleon.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/UIButton+Chameleon.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIColor+Chameleon.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIColor+Chameleon.h new file mode 120000 index 0000000..05e4379 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIColor+Chameleon.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/UIColor+Chameleon.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIColor+ChameleonPrivate.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIColor+ChameleonPrivate.h new file mode 120000 index 0000000..9b926b3 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIColor+ChameleonPrivate.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/UIColor+ChameleonPrivate.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIImage+ChameleonPrivate.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIImage+ChameleonPrivate.h new file mode 120000 index 0000000..c93db3d --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIImage+ChameleonPrivate.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/UIImage+ChameleonPrivate.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UILabel+Chameleon.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UILabel+Chameleon.h new file mode 120000 index 0000000..4350e1e --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UILabel+Chameleon.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/UILabel+Chameleon.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UINavigationController+Chameleon.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UINavigationController+Chameleon.h new file mode 120000 index 0000000..2052867 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UINavigationController+Chameleon.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/UINavigationController+Chameleon.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIView+ChameleonPrivate.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIView+ChameleonPrivate.h new file mode 120000 index 0000000..9713ec0 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIView+ChameleonPrivate.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/UIView+ChameleonPrivate.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIViewController+Chameleon.h b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIViewController+Chameleon.h new file mode 120000 index 0000000..be31ef4 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/ChameleonFramework/UIViewController+Chameleon.h @@ -0,0 +1 @@ +../../../ChameleonFramework/Pod/Classes/Objective-C/UIViewController+Chameleon.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/NSData+ImageContentType.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/NSData+ImageContentType.h new file mode 120000 index 0000000..8457498 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/NSData+ImageContentType.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/NSData+ImageContentType.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/SDImageCache.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDImageCache.h new file mode 120000 index 0000000..0040b06 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDImageCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCache.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageCompat.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageCompat.h new file mode 120000 index 0000000..6ca2478 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageCompat.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageCompat.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h new file mode 120000 index 0000000..a2f3a68 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDecoder.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageDownloader.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageDownloader.h new file mode 120000 index 0000000..303b03b --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageDownloader.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloader.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderOperation.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderOperation.h new file mode 120000 index 0000000..99441c4 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageManager.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageManager.h new file mode 120000 index 0000000..1b81848 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageManager.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageOperation.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageOperation.h new file mode 120000 index 0000000..20e5b89 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImageOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageOperation.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImagePrefetcher.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImagePrefetcher.h new file mode 120000 index 0000000..50585c6 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/SDWebImagePrefetcher.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImagePrefetcher.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/UIButton+WebCache.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIButton+WebCache.h new file mode 120000 index 0000000..19d2d8e --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIButton+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIButton+WebCache.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImage+GIF.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImage+GIF.h new file mode 120000 index 0000000..14d5aad --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImage+GIF.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+GIF.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImage+MultiFormat.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImage+MultiFormat.h new file mode 120000 index 0000000..1fb9650 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImage+MultiFormat.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+MultiFormat.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImageView+HighlightedWebCache.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImageView+HighlightedWebCache.h new file mode 120000 index 0000000..fd4dea4 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImageView+HighlightedWebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImageView+WebCache.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImageView+WebCache.h new file mode 120000 index 0000000..0c53a47 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIImageView+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImageView+WebCache.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SDWebImage/UIView+WebCacheOperation.h b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIView+WebCacheOperation.h new file mode 120000 index 0000000..f9890c4 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SDWebImage/UIView+WebCacheOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIView+WebCacheOperation.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Headers/Private/SIAlertView/SIAlertView.h b/HeadsUpper/Pods/Headers/Private/SIAlertView/SIAlertView.h new file mode 120000 index 0000000..630cc31 --- /dev/null +++ b/HeadsUpper/Pods/Headers/Private/SIAlertView/SIAlertView.h @@ -0,0 +1 @@ +../../../SIAlertView/SIAlertView/SIAlertView.h \ No newline at end of file diff --git a/HeadsUpper/Pods/Manifest.lock b/HeadsUpper/Pods/Manifest.lock new file mode 100644 index 0000000..1d642d7 --- /dev/null +++ b/HeadsUpper/Pods/Manifest.lock @@ -0,0 +1,37 @@ +PODS: + - AFNetworking (3.0.4): + - AFNetworking/NSURLSession (= 3.0.4) + - AFNetworking/Reachability (= 3.0.4) + - AFNetworking/Security (= 3.0.4) + - AFNetworking/Serialization (= 3.0.4) + - AFNetworking/UIKit (= 3.0.4) + - AFNetworking/NSURLSession (3.0.4): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (3.0.4) + - AFNetworking/Security (3.0.4) + - AFNetworking/Serialization (3.0.4) + - AFNetworking/UIKit (3.0.4): + - AFNetworking/NSURLSession + - ChameleonFramework (2.1.0): + - ChameleonFramework/Default (= 2.1.0) + - ChameleonFramework/Default (2.1.0) + - SDWebImage (3.7.5): + - SDWebImage/Core (= 3.7.5) + - SDWebImage/Core (3.7.5) + - SIAlertView (1.3) + +DEPENDENCIES: + - AFNetworking (~> 3.0) + - ChameleonFramework (~> 2.1) + - SDWebImage (~> 3.7) + - SIAlertView (~> 1.3) + +SPEC CHECKSUMS: + AFNetworking: a0075feb321559dc78d9d85b55d11caa19eabb93 + ChameleonFramework: d21a3cc247abfe5e37609a283a8238b03575cf64 + SDWebImage: 69c6303e3348fba97e03f65d65d4fbc26740f461 + SIAlertView: 20c794b55eaf44d888773ea51647cf8907723919 + +COCOAPODS: 0.39.0 diff --git a/HeadsUpper/Pods/Pods.xcodeproj/project.pbxproj b/HeadsUpper/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000..79606b2 --- /dev/null +++ b/HeadsUpper/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,1430 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 00E3A68D030F24BE47B99D1D1A1720E2 /* UIColor+ChameleonPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = BE4DF15D2CD93F28E93E0255333E8AF2 /* UIColor+ChameleonPrivate.m */; }; + 072BEEF7E71F00675E87028A9A668B84 /* UIImage+ChameleonPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D2B7187E8CD92B370BDED591331791 /* UIImage+ChameleonPrivate.m */; }; + 0B7BBE1823A00619148E2C6CF9BDEA2C /* SIAlertView-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = D6DFDBCA26FE67CFAAF748ACE2B398CC /* SIAlertView-dummy.m */; }; + 0BCEB4526A2E5952C5A58A347D6C3D06 /* SDWebImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 79C6BE498D9F6870CF1E2565FFACFB10 /* SDWebImageDownloader.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 10F4AA3E8A1DE840EB69CDA0CD0BE848 /* NSData+ImageContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 14B310D1EE4EEAB229349E0FB55039EA /* NSData+ImageContentType.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 131F64370D44DB8EAF6D1046ED2CFB3A /* SDWebImageDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = E07B6ECF12F149E697A66A3C985463AF /* SDWebImageDecoder.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 13AE3036636034BB4E50A218D3EE27CD /* UIImage+MultiFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B8B39F9BFE1B49BAD4FFE8014C78C0F /* UIImage+MultiFormat.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 1480F4923DBBF217F60572EEECB4027C /* AFNetworkActivityIndicatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 3678A579063EE57B009031ECAB496DAB /* AFNetworkActivityIndicatorManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1584A0B442DA93BF1AF49A8D82432AF4 /* SIAlertView.h in Headers */ = {isa = PBXBuildFile; fileRef = 71C2519592D6ABFB2BE4CECD790B9C60 /* SIAlertView.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 160634C0F5454A32E810DDF5BA9E5985 /* NSArray+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FEEC272573BE197E4BBB1FC139FDC2 /* NSArray+Chameleon.m */; }; + 1716FA0939818C49FE4BBE6A658E9834 /* UIButton+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BF8991AAEDDC5F26734BCAC875F4A7B /* UIButton+Chameleon.m */; }; + 174202BD6AE0E4A41F5CE66E975EAE52 /* UIRefreshControl+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD17CF93C3CD37548ACAB340BD0B279 /* UIRefreshControl+AFNetworking.m */; }; + 1A19A456017D2EB235DA00961A8A664F /* SDWebImage-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 0222DD3060B4FDB5F67C0B9E73EF62E4 /* SDWebImage-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1DE26E57570167EE496080D68F855A01 /* UIImage+ChameleonPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DF518081FD49CFD1C5E46CC45689EAA /* UIImage+ChameleonPrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1E5B8F12ED7CC40ECDB9B1F755F387E5 /* UIActivityIndicatorView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 13F0254858ED1938ED0DDDC534E0AFC7 /* UIActivityIndicatorView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 20607BE2B1E5F31765026E5AC64DB27D /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C9432229A2D2E8D7B1339B6FCE39B08 /* AFSecurityPolicy.m */; }; + 20EE8030FCF2402DAC7F1C9B9DDAEF79 /* AFURLRequestSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1D56168357FBA6F995515CF005A94F /* AFURLRequestSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2139B6A9B4241F53BB478C43D51921CC /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1441BB11E4761F1BC04D6C0E00872AEC /* QuartzCore.framework */; }; + 21D927B42CB12293E5E57756F9F5D943 /* SDWebImageCompat.h in Headers */ = {isa = PBXBuildFile; fileRef = DBEB0DA0ECC4FCD504E89FE705872E88 /* SDWebImageCompat.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 233031A4C2D25B3DD6515CC3C3FEA4F8 /* SDWebImage-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = A9BE151AA560C3E90597FE53A05954A7 /* SDWebImage-dummy.m */; }; + 23795D7EC1AF274A6AFF4233B1E84C4C /* UINavigationController+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E308322DA038B33575B3583CA0798A8 /* UINavigationController+Chameleon.m */; }; + 2E2946436612A5B920BE18E09BF80CAF /* UIViewController+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 292B12936E492B93444D42044987B350 /* UIViewController+Chameleon.m */; }; + 2E8A32ED46194EDBE22146271F6D26DE /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 05149083EA6274F979042D7B5A1BE849 /* UIImageView+AFNetworking.m */; }; + 3132A9EBC1F85B6971B934C88914CD58 /* UILabel+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE55F1DC9E05C9F1B8AEC331057C952 /* UILabel+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 33413A8B4EF4F2D0D463271F93B090B4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E69C6C2578C5EE54655B31E8BD7F779B /* Foundation.framework */; }; + 3751DD3EE60E97490755E539B619A01C /* SDWebImageDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 261824B849239DE2DFF2B95C452EC74C /* SDWebImageDecoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3997DB2DDBBA43002E76791E759AD67F /* SIAlertView.bundle in Resources */ = {isa = PBXBuildFile; fileRef = F904731712EE1E15DE07E4A384C387D0 /* SIAlertView.bundle */; }; + 3A10EF6ABF51D1D00B06AC5EF3A8C28C /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AEE6A3B7D517C1E9D060E13F636167F0 /* SystemConfiguration.framework */; }; + 3CC775A00BF15E8E6B6E495741E64A85 /* UIView+WebCacheOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8986E57FEDECCECA19D6F456A7F810DF /* UIView+WebCacheOperation.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 3CCCC6F0C10F65283522C54CF1D6E761 /* UIButton+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C9ED7629FB1AB491D321D2665095792 /* UIButton+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3D1FF907F6AD5186FAF926C0F20083AE /* Chameleon_.m in Sources */ = {isa = PBXBuildFile; fileRef = 222696BBCD1EADA99117A5586F2182C4 /* Chameleon_.m */; }; + 3D2789FC760A97301909F0B1201626CD /* AFNetworking-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EF8296E82FB9AA440D7FDFDE07B59DB /* AFNetworking-dummy.m */; }; + 3F1BC9BAFFEEABB1ABC7614DF0FC97D5 /* AFAutoPurgingImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = AB0FE5062FDEF326A4028F2F7D543045 /* AFAutoPurgingImageCache.m */; }; + 3F380B6D0B4DD2E6D87AA320AFC86D09 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E69C6C2578C5EE54655B31E8BD7F779B /* Foundation.framework */; }; + 41E19345B5C2331DAA02119D782F4E5F /* ChameleonMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F6A620F784540CCAC8826D3F35BC267 /* ChameleonMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 42B81612C22744B21A3AC57DC36F7DD3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E69C6C2578C5EE54655B31E8BD7F779B /* Foundation.framework */; }; + 4605EEF216A3BAC0CC1F6F5F133A80CE /* SDWebImageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7254B6EBAAA3E58D8E0BD374F0AB6A26 /* SDWebImageManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 481D2695D475A2BC649D64D2D1C6A03E /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 40182B7FF44217D3F633FF36BE3E4831 /* ImageIO.framework */; }; + 4B181B0AC8894DE05050B3F6718D392C /* ChameleonConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C924B0030AA0F805839E520FEBDA66C /* ChameleonConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4E53C48294089DC928E3A7BD1C2DE4D7 /* UIColor+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = 47331CFA95DE5A83D806E6213F4C871B /* UIColor+Chameleon.m */; }; + 4FEB67CF6D76321459C7DF80EE6F92CD /* Pods-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 894E5DA93A9F359521A89826BE6DA777 /* Pods-dummy.m */; }; + 560698A4D707DCBCC1C8F98BC9B89B23 /* AFURLSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 671E7BEAD7E869CB593B71038B4DE327 /* AFURLSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5808B477EFF509D810B5CDCFDC944F80 /* AFImageDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 92A6631228DA9142C15A208B112CBE85 /* AFImageDownloader.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 59DCF5EA20D577A83170787EB14A7C5B /* SDWebImagePrefetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = D75CEC495D289B978D7FC3454DFA2A64 /* SDWebImagePrefetcher.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5A6D94B2D866B061E659E29D8B332063 /* UIImage+GIF.h in Headers */ = {isa = PBXBuildFile; fileRef = 8559AD718FB3DDF73F7E35A6030BEE57 /* UIImage+GIF.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5BF38591007E7E4ADAD878E405949598 /* ChameleonConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = FE7083BC499DDD66A7582D2C7478E2A7 /* ChameleonConstants.m */; }; + 5C65C36731C43213CDF68B10802AA2DB /* SDWebImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 061891051576CD0D66997B91A922A3C1 /* SDWebImageManager.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 5E1AB9270BCE9081098EDB82F9A8B511 /* SDWebImageDownloaderOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AC26E4849C4688AB2833C0203BD5EFD /* SDWebImageDownloaderOperation.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 5FF6453E55785669885F626B853FD2AA /* UIProgressView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = C2F1201EEE0CA2057A3219FF00CC9BFA /* UIProgressView+AFNetworking.m */; }; + 60E3009342BEE96D32C546BE2DB60052 /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 29391A1EC984788CE098CAED891CB388 /* UIImageView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 63460DFE31F42291286A2B2BB53A8553 /* UIImage+GIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 19DDE813B74AB915ED3F8EE1B38E8188 /* UIImage+GIF.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 6497DED0C01B70FA6A79A4FC392EE473 /* SDWebImagePrefetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = F45CBFA61BA8D483714567618CC670FE /* SDWebImagePrefetcher.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 659960F7E28E993E08CCC1E8A383E710 /* UIKit+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 77F5211664F5579DF283409D0A987B58 /* UIKit+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 68152D921ABF6A423C192C04FDF94F0F /* AFNetworkReachabilityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C933923BF252C9E19340FF630BA1D5F /* AFNetworkReachabilityManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 68A38977EBAE334DC3C22386D00D2622 /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = AB99830EE90188AF93FA50631EA5E1CD /* AFNetworkReachabilityManager.m */; }; + 6ED4ABEE8A5F51F5ECB59FA1781D29C6 /* UIActivityIndicatorView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F5502E8D9885E107FB9D917CBD17C9CA /* UIActivityIndicatorView+AFNetworking.m */; }; + 707B1A7541C8DBDDE8C27896A61370BE /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 27F4E4B5EA42C02400CF305F1468B26C /* AFURLSessionManager.m */; }; + 7332F15718920917F544F35CE2C038AA /* AFURLResponseSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 1684D4556D43287C736258444195B29C /* AFURLResponseSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7A8C05065D9F9BA2C218F75AD6B1F798 /* UIAppearance+Swift.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E2E35694543CC52199588655D064843 /* UIAppearance+Swift.m */; }; + 7AF712E95A1110B47775A10777DA6CFE /* Pods-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BCC458FDD5F692BBB2BFC64BB5701FC /* Pods-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7E6A4EFA32969CDB9F9C57903152BA54 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EEC0CA412D7FB80A0AB6CD28BD7C44E /* CoreGraphics.framework */; }; + 7EDDB8F47291F592694D7135A10DAFFF /* UIViewController+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 301EE93398BD24FF57949ADFAC7555E5 /* UIViewController+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7F17EA5E2787B6F2BBB359854B42A0E3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E69C6C2578C5EE54655B31E8BD7F779B /* Foundation.framework */; }; + 81B617F8D26BB10C5726D75E85D21EB7 /* UIButton+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 69B22AD40C656C5C8EF7BC256A3AAC50 /* UIButton+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 8AAC2FBF0DE93A078EBDEFF92CF0D4F7 /* UIImage+MultiFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = A3CA95455AD72EA80ABD1A120C4650E1 /* UIImage+MultiFormat.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 8D261B47DAB28AB33C79C140A39EA3F8 /* SIAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 78A4335ADD114F848EAC73C718093613 /* SIAlertView.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 932E320A9BBD2B15F8823A2AF7382C2F /* SDWebImageDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = A2BD16ECE03FDEF2DC51C919647943D5 /* SDWebImageDownloader.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 99C65AA7B2590E1151C5342409E4FD7B /* UIButton+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = A59E5B619A049EBE85BA63D35F3EB6B0 /* UIButton+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DFA471A792EF016C2F1A672CF10CEBE /* UIImageView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = DB8A82F916E40BB68E0A31C09766D5BE /* UIImageView+WebCache.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 9E1E90DED74B73ECE53C9AD76DE53E2D /* UIImage+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = F9B6FE84AFEF2AD2006E42F29AA5F117 /* UIImage+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9EEBF7B1602C1C17236C4EA0DD9717E2 /* UILabel+Chameleon.m in Sources */ = {isa = PBXBuildFile; fileRef = D9D179FF755EFD14DAE003FDB957D3ED /* UILabel+Chameleon.m */; }; + 9F10DE788137C16984164B6EA67B27EF /* SDWebImageCompat.m in Sources */ = {isa = PBXBuildFile; fileRef = 79DA00548D047B39D7865C7FB8F4CA45 /* SDWebImageCompat.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + A462945883F7729B185B64B679A6BFBE /* UIWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = D0FEAA2EA123F086A95DE4443024BD5E /* UIWebView+AFNetworking.m */; }; + A6C6019D45BE62C61210A9CC619368EF /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A8808E8D69DB0F13C7D17978C1115D5 /* AFNetworkActivityIndicatorManager.m */; }; + A9EF5BAE4367A92E58C3BAE6B97E849B /* UIImageView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E69F80FBF41C5991FCEAFDD3F7D2998 /* UIImageView+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AB39AC9746E7575D7449700475E41B0B /* AFHTTPSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AD017890591F8499F271B6A80DDA76 /* AFHTTPSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AE2A07407FB50BA249984DC0620E84C0 /* UIWebView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 94071DEE80170761AD89A23DAD197E95 /* UIWebView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AF03C11A1FAC8132AD3749D8F541701A /* UIButton+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 00928814FCF3BC55D5493A10707B40CB /* UIButton+AFNetworking.m */; }; + B3429381360BE9C37D00301284E4B63A /* UIView+ChameleonPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E142146DAE6D0F0F7D44656D80C9D6B /* UIView+ChameleonPrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + B5852322ADE88AAD56EE042B80BA81E4 /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 24C1F326D69F202E5391182C8199EA1C /* AFURLResponseSerialization.m */; }; + B8721458CA3A54F8241D117A718A08AE /* UIImageView+HighlightedWebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = EA4A2816CC27CC81B26803660B5DF9C4 /* UIImageView+HighlightedWebCache.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + BF2143417C483F5D9D794113D5051BF0 /* UIView+WebCacheOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = C8AF67C0E1630C70E3C2C13563B6C01F /* UIView+WebCacheOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C01AC3BAD9037A8A1E45FD17336C15F3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F7B9818167212F7413F0950564EDA45 /* Security.framework */; }; + C0F98157BC58FC156904C9198FDFC712 /* SDImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 96F35AD2449B9CB67A2ECC7726EE2A32 /* SDImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C2DD28375E1F0B1D0D1D2E4E607C499F /* AFSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 0548FC51C30DA6BA6A5CD9BAA8ECC879 /* AFSecurityPolicy.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C4D89B2B2A66551C30E50AA6277B490B /* SIAlertView-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = C002D5796E8DC72B699FBFD7CB0C2E83 /* SIAlertView-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C5A569BD6FD764853397C8C6DCF32AD3 /* UIImageView+HighlightedWebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 36480C55417C1CE218EDC8C29D6DE27B /* UIImageView+HighlightedWebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C5D22B9D6600C31DC02CEC59BDA086B0 /* UIColor+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E892333521B02CED2C188199C4FC260 /* UIColor+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C61ED2CF225C6D9872D34F5455C945D4 /* NSArray+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = B3B3288E024D0F755C575B7D8450B667 /* NSArray+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C6354FEC7728A4C86DAD8092509BA7D4 /* UIRefreshControl+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 0256C091480F0D741C7251028BD1FCF1 /* UIRefreshControl+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C67E03EC22D124DE998695EF86B99E25 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A566ABA6EE8D60B1990A0F955E25E76 /* UIKit.framework */; }; + C84DFC79CACF46C6275670861ADBA6D4 /* UINavigationController+Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = FA1A10E040B375EF112B41C4A0F58516 /* UINavigationController+Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C9CD229C670F4FD567692E66C8477577 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1441BB11E4761F1BC04D6C0E00872AEC /* QuartzCore.framework */; }; + CAC483EF637FB4A2C2E2FC75BA631B87 /* AFAutoPurgingImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = A0E0F24194609FBC5961FE88B29BADF0 /* AFAutoPurgingImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CC51E5C010ABC87B9CAAA1CB721A6A94 /* UIColor+ChameleonPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A00447FDCEB071E39255C79188E58FE7 /* UIColor+ChameleonPrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CDF0F982DFF346BC5CBB44DDD15AE9DA /* SDWebImageOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 86BD1FB960BE84CCA878F92E5A3CF958 /* SDWebImageOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CEB79FC05B4B5DC7AB1C60B17E206426 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E69C6C2578C5EE54655B31E8BD7F779B /* Foundation.framework */; }; + CFA8D6B529A0EBFF0316F2629AB2556E /* AFImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A42091A5CF7ACF7633FE12F30B5A96E /* AFImageDownloader.m */; }; + D04B84B53456B9CD8A7236126075571B /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6944ED9DFD7B5B9887BDA5FDA5193EF3 /* MobileCoreServices.framework */; }; + D9F4E833E37B611B432F6B5D7072DDA2 /* UIProgressView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = A1D4AD56677F149286A0500097D6A092 /* UIProgressView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DDD470435EE37EBA46CD0FF081559295 /* ChameleonFramework-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = DE85BCCC2A5129323CEEEC0AEC32027D /* ChameleonFramework-dummy.m */; }; + DFFA215EEAA8DDBD540076927535275C /* AFURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A66B0E8FA78C381B0F7ECE70A5ED69D /* AFURLRequestSerialization.m */; }; + E04963F0C6D76377186361A0AF79A4C6 /* Chameleon_.h in Headers */ = {isa = PBXBuildFile; fileRef = 91E576039DB210C4C22154E3648739A1 /* Chameleon_.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E0D4045AC4C1B41917FCA23A042D18B2 /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B9F6CD8068797152C94DC8221A170A /* AFHTTPSessionManager.m */; }; + E1A9C067A09E9F17BEE220DD68EBCFC8 /* UIButton+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = AF2DD425FF9D3D40F9BBDEC2097BFC2C /* UIButton+WebCache.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + E53E2CD0E939A133E73880E7B3BB4DBF /* ChameleonEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 6186E72B27ED368B2B15B2E59E9874CC /* ChameleonEnums.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E5A4261DB22000B4610387FA7BE880E3 /* SDImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F636878B51E135C2796D04FF25FFD9 /* SDImageCache.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + E7988678C81F7CCB95D239375FC6986D /* AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 09B5CAD28C440E32969A20EE7E7BE9D9 /* AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E98AA3E890BE4D11B192EB37F6A4408C /* NSData+ImageContentType.m in Sources */ = {isa = PBXBuildFile; fileRef = DF7D3CD05575BD1BC15ED5C4B09B7D35 /* NSData+ImageContentType.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + EC7CADE416A78A1CD6936018A6695126 /* AFNetworking-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = ABA27B678AEF9BCDB3C7046D7F895A12 /* AFNetworking-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + ED545537CDC6C83EBA629FE6524D550A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EEC0CA412D7FB80A0AB6CD28BD7C44E /* CoreGraphics.framework */; }; + F20F6CEB143FB1C11261424DBD6684B9 /* SDWebImageDownloaderOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F4A9D5372ED87B652AF325B765CB3B /* SDWebImageDownloaderOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F32D7BD1DA58639964C91FA86A002AB4 /* UIView+ChameleonPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = B0156B96EE5A7F87BC5F7D5D68C45AE7 /* UIView+ChameleonPrivate.m */; }; + F5CC9B27F3CF472FE72A905E8C2D7A9D /* Chameleon.h in Headers */ = {isa = PBXBuildFile; fileRef = 9758519051975CBBF187957B9F45CD4A /* Chameleon.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F85099F6E9B7DB837BAB856EB61A6F07 /* UIAppearance+Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 045A0795AD66897AA232937311DCDD7B /* UIAppearance+Swift.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FA90B7D6EBE7A289796856FF2B310FC0 /* ChameleonFramework-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E972BD575C71E413202FB208CE11820 /* ChameleonFramework-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 21B1BF1CE89E3A0058A7A1C4A9D0254F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = F4A7EEEFE72653B329822E7F980DEB17; + remoteInfo = SIAlertView; + }; + 87BBC3CF8F5719970699DD53DEB01BAD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = B288D3B845DF95DB82ED94BED76C6960; + remoteInfo = SDWebImage; + }; + A42011885E18F4AE5EA18396A9CB26C6 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1C3436CEA5C3D39764C5F54374794ECB; + remoteInfo = AFNetworking; + }; + E8795D0ED7A3D25C79B7F86CB32E1437 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 9B57F4EE4746045CEAE2D933A3C8EC9E; + remoteInfo = ChameleonFramework; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 00928814FCF3BC55D5493A10707B40CB /* UIButton+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+AFNetworking.m"; path = "UIKit+AFNetworking/UIButton+AFNetworking.m"; sourceTree = ""; }; + 0222DD3060B4FDB5F67C0B9E73EF62E4 /* SDWebImage-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SDWebImage-umbrella.h"; sourceTree = ""; }; + 0256C091480F0D741C7251028BD1FCF1 /* UIRefreshControl+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIRefreshControl+AFNetworking.h"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.h"; sourceTree = ""; }; + 045A0795AD66897AA232937311DCDD7B /* UIAppearance+Swift.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIAppearance+Swift.h"; path = "Pod/Classes/Objective-C/UIAppearance+Swift.h"; sourceTree = ""; }; + 05149083EA6274F979042D7B5A1BE849 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+AFNetworking.m"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.m"; sourceTree = ""; }; + 0548FC51C30DA6BA6A5CD9BAA8ECC879 /* AFSecurityPolicy.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFSecurityPolicy.h; path = AFNetworking/AFSecurityPolicy.h; sourceTree = ""; }; + 061891051576CD0D66997B91A922A3C1 /* SDWebImageManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageManager.m; path = SDWebImage/SDWebImageManager.m; sourceTree = ""; }; + 07AD017890591F8499F271B6A80DDA76 /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPSessionManager.h; path = AFNetworking/AFHTTPSessionManager.h; sourceTree = ""; }; + 09B5CAD28C440E32969A20EE7E7BE9D9 /* AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworking.h; path = AFNetworking/AFNetworking.h; sourceTree = ""; }; + 0C9432229A2D2E8D7B1339B6FCE39B08 /* AFSecurityPolicy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFSecurityPolicy.m; path = AFNetworking/AFSecurityPolicy.m; sourceTree = ""; }; + 133355A5A8E882B8C3C3996649C5D184 /* AFNetworking-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "AFNetworking-prefix.pch"; sourceTree = ""; }; + 13F0254858ED1938ED0DDDC534E0AFC7 /* UIActivityIndicatorView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIActivityIndicatorView+AFNetworking.h"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h"; sourceTree = ""; }; + 1441BB11E4761F1BC04D6C0E00872AEC /* QuartzCore.framework */ = {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; }; + 14B310D1EE4EEAB229349E0FB55039EA /* NSData+ImageContentType.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSData+ImageContentType.h"; path = "SDWebImage/NSData+ImageContentType.h"; sourceTree = ""; }; + 1684D4556D43287C736258444195B29C /* AFURLResponseSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLResponseSerialization.h; path = AFNetworking/AFURLResponseSerialization.h; sourceTree = ""; }; + 19858785CC92C12C9FC67C1A3C448B71 /* ChameleonFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ChameleonFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 19DDE813B74AB915ED3F8EE1B38E8188 /* UIImage+GIF.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+GIF.m"; path = "SDWebImage/UIImage+GIF.m"; sourceTree = ""; }; + 1A66B0E8FA78C381B0F7ECE70A5ED69D /* AFURLRequestSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLRequestSerialization.m; path = AFNetworking/AFURLRequestSerialization.m; sourceTree = ""; }; + 1AE55F1DC9E05C9F1B8AEC331057C952 /* UILabel+Chameleon.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UILabel+Chameleon.h"; path = "Pod/Classes/Objective-C/UILabel+Chameleon.h"; sourceTree = ""; }; + 1EF8296E82FB9AA440D7FDFDE07B59DB /* AFNetworking-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "AFNetworking-dummy.m"; sourceTree = ""; }; + 222696BBCD1EADA99117A5586F2182C4 /* Chameleon_.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Chameleon_.m; path = "Pod/Classes/Objective-C/Chameleon_.m"; sourceTree = ""; }; + 24C1F326D69F202E5391182C8199EA1C /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLResponseSerialization.m; path = AFNetworking/AFURLResponseSerialization.m; sourceTree = ""; }; + 261824B849239DE2DFF2B95C452EC74C /* SDWebImageDecoder.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDecoder.h; path = SDWebImage/SDWebImageDecoder.h; sourceTree = ""; }; + 27F4E4B5EA42C02400CF305F1468B26C /* AFURLSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLSessionManager.m; path = AFNetworking/AFURLSessionManager.m; sourceTree = ""; }; + 292B12936E492B93444D42044987B350 /* UIViewController+Chameleon.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIViewController+Chameleon.m"; path = "Pod/Classes/Objective-C/UIViewController+Chameleon.m"; sourceTree = ""; }; + 29391A1EC984788CE098CAED891CB388 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+AFNetworking.h"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.h"; sourceTree = ""; }; + 2BCC458FDD5F692BBB2BFC64BB5701FC /* Pods-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-umbrella.h"; sourceTree = ""; }; + 2E69F80FBF41C5991FCEAFDD3F7D2998 /* UIImageView+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+WebCache.h"; path = "SDWebImage/UIImageView+WebCache.h"; sourceTree = ""; }; + 301EE93398BD24FF57949ADFAC7555E5 /* UIViewController+Chameleon.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIViewController+Chameleon.h"; path = "Pod/Classes/Objective-C/UIViewController+Chameleon.h"; sourceTree = ""; }; + 32D2B7187E8CD92B370BDED591331791 /* UIImage+ChameleonPrivate.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+ChameleonPrivate.m"; path = "Pod/Classes/Objective-C/UIImage+ChameleonPrivate.m"; sourceTree = ""; }; + 36480C55417C1CE218EDC8C29D6DE27B /* UIImageView+HighlightedWebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+HighlightedWebCache.h"; path = "SDWebImage/UIImageView+HighlightedWebCache.h"; sourceTree = ""; }; + 3678A579063EE57B009031ECAB496DAB /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkActivityIndicatorManager.h; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h"; sourceTree = ""; }; + 3AC26E4849C4688AB2833C0203BD5EFD /* SDWebImageDownloaderOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloaderOperation.m; path = SDWebImage/SDWebImageDownloaderOperation.m; sourceTree = ""; }; + 3B8B39F9BFE1B49BAD4FFE8014C78C0F /* UIImage+MultiFormat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+MultiFormat.m"; path = "SDWebImage/UIImage+MultiFormat.m"; sourceTree = ""; }; + 3BCA564B0F4EEE904D7A979B401E9D66 /* AFNetworking.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = AFNetworking.modulemap; sourceTree = ""; }; + 3E892333521B02CED2C188199C4FC260 /* UIColor+Chameleon.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIColor+Chameleon.h"; path = "Pod/Classes/Objective-C/UIColor+Chameleon.h"; sourceTree = ""; }; + 40182B7FF44217D3F633FF36BE3E4831 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/ImageIO.framework; sourceTree = DEVELOPER_DIR; }; + 40FEEC272573BE197E4BBB1FC139FDC2 /* NSArray+Chameleon.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSArray+Chameleon.m"; path = "Pod/Classes/Objective-C/NSArray+Chameleon.m"; sourceTree = ""; }; + 460B6F09D8F4B5F3B88C9D288514D92A /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 47331CFA95DE5A83D806E6213F4C871B /* UIColor+Chameleon.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIColor+Chameleon.m"; path = "Pod/Classes/Objective-C/UIColor+Chameleon.m"; sourceTree = ""; }; + 4A42091A5CF7ACF7633FE12F30B5A96E /* AFImageDownloader.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFImageDownloader.m; path = "UIKit+AFNetworking/AFImageDownloader.m"; sourceTree = ""; }; + 4C1D56168357FBA6F995515CF005A94F /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLRequestSerialization.h; path = AFNetworking/AFURLRequestSerialization.h; sourceTree = ""; }; + 4C9ED7629FB1AB491D321D2665095792 /* UIButton+Chameleon.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+Chameleon.h"; path = "Pod/Classes/Objective-C/UIButton+Chameleon.h"; sourceTree = ""; }; + 4D7681B7F660CCAC139F2E4A99B16D1E /* SDWebImage.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SDWebImage.xcconfig; sourceTree = ""; }; + 4E972BD575C71E413202FB208CE11820 /* ChameleonFramework-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "ChameleonFramework-umbrella.h"; sourceTree = ""; }; + 4F6A620F784540CCAC8826D3F35BC267 /* ChameleonMacros.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ChameleonMacros.h; path = "Pod/Classes/Objective-C/ChameleonMacros.h"; sourceTree = ""; }; + 507F3BC6B87E2835FF5F9ABF3A38E96D /* ChameleonFramework.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = ChameleonFramework.modulemap; sourceTree = ""; }; + 5A8808E8D69DB0F13C7D17978C1115D5 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkActivityIndicatorManager.m; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m"; sourceTree = ""; }; + 5C924B0030AA0F805839E520FEBDA66C /* ChameleonConstants.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ChameleonConstants.h; path = "Pod/Classes/Objective-C/ChameleonConstants.h"; sourceTree = ""; }; + 5E2E35694543CC52199588655D064843 /* UIAppearance+Swift.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIAppearance+Swift.m"; path = "Pod/Classes/Objective-C/UIAppearance+Swift.m"; sourceTree = ""; }; + 5F7B9818167212F7413F0950564EDA45 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; + 6186E72B27ED368B2B15B2E59E9874CC /* ChameleonEnums.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ChameleonEnums.h; path = "Pod/Classes/Objective-C/ChameleonEnums.h"; sourceTree = ""; }; + 63B9F6CD8068797152C94DC8221A170A /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPSessionManager.m; path = AFNetworking/AFHTTPSessionManager.m; sourceTree = ""; }; + 671E7BEAD7E869CB593B71038B4DE327 /* AFURLSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLSessionManager.h; path = AFNetworking/AFURLSessionManager.h; sourceTree = ""; }; + 6944ED9DFD7B5B9887BDA5FDA5193EF3 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; }; + 69B22AD40C656C5C8EF7BC256A3AAC50 /* UIButton+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+AFNetworking.h"; path = "UIKit+AFNetworking/UIButton+AFNetworking.h"; sourceTree = ""; }; + 6DF518081FD49CFD1C5E46CC45689EAA /* UIImage+ChameleonPrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+ChameleonPrivate.h"; path = "Pod/Classes/Objective-C/UIImage+ChameleonPrivate.h"; sourceTree = ""; }; + 6E142146DAE6D0F0F7D44656D80C9D6B /* UIView+ChameleonPrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIView+ChameleonPrivate.h"; path = "Pod/Classes/Objective-C/UIView+ChameleonPrivate.h"; sourceTree = ""; }; + 6EEC0CA412D7FB80A0AB6CD28BD7C44E /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; + 6F24ED243F51B6BE7F54947C7BFEA4CA /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 71C2519592D6ABFB2BE4CECD790B9C60 /* SIAlertView.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SIAlertView.h; path = SIAlertView/SIAlertView.h; sourceTree = ""; }; + 7254B6EBAAA3E58D8E0BD374F0AB6A26 /* SDWebImageManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageManager.h; path = SDWebImage/SDWebImageManager.h; sourceTree = ""; }; + 77B67B56422B56FC9502C450AD6AABA0 /* ChameleonFramework.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = ChameleonFramework.xcconfig; sourceTree = ""; }; + 77F5211664F5579DF283409D0A987B58 /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIKit+AFNetworking.h"; path = "UIKit+AFNetworking/UIKit+AFNetworking.h"; sourceTree = ""; }; + 78A4335ADD114F848EAC73C718093613 /* SIAlertView.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SIAlertView.m; path = SIAlertView/SIAlertView.m; sourceTree = ""; }; + 79A9DEDC89FE8336BF5FEDAAF75BF7FC /* Pods.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = Pods.modulemap; sourceTree = ""; }; + 79C6BE498D9F6870CF1E2565FFACFB10 /* SDWebImageDownloader.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloader.m; path = SDWebImage/SDWebImageDownloader.m; sourceTree = ""; }; + 79DA00548D047B39D7865C7FB8F4CA45 /* SDWebImageCompat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageCompat.m; path = SDWebImage/SDWebImageCompat.m; sourceTree = ""; }; + 79F636878B51E135C2796D04FF25FFD9 /* SDImageCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCache.m; path = SDWebImage/SDImageCache.m; sourceTree = ""; }; + 7BF8991AAEDDC5F26734BCAC875F4A7B /* UIButton+Chameleon.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+Chameleon.m"; path = "Pod/Classes/Objective-C/UIButton+Chameleon.m"; sourceTree = ""; }; + 8559AD718FB3DDF73F7E35A6030BEE57 /* UIImage+GIF.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+GIF.h"; path = "SDWebImage/UIImage+GIF.h"; sourceTree = ""; }; + 86BD1FB960BE84CCA878F92E5A3CF958 /* SDWebImageOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageOperation.h; path = SDWebImage/SDWebImageOperation.h; sourceTree = ""; }; + 87B213035BAC5F75386F62D3C75D2342 /* Pods-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-acknowledgements.plist"; sourceTree = ""; }; + 87BCB10DAAAEF784FA72C9B3BF4A0AB0 /* SIAlertView-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SIAlertView-prefix.pch"; sourceTree = ""; }; + 893A794918CF5C97A5D11D3F131F9F57 /* AFNetworking.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = AFNetworking.xcconfig; sourceTree = ""; }; + 894E5DA93A9F359521A89826BE6DA777 /* Pods-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-dummy.m"; sourceTree = ""; }; + 8986E57FEDECCECA19D6F456A7F810DF /* UIView+WebCacheOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIView+WebCacheOperation.m"; path = "SDWebImage/UIView+WebCacheOperation.m"; sourceTree = ""; }; + 8A566ABA6EE8D60B1990A0F955E25E76 /* UIKit.framework */ = {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; }; + 8AD17CF93C3CD37548ACAB340BD0B279 /* UIRefreshControl+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIRefreshControl+AFNetworking.m"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.m"; sourceTree = ""; }; + 8C933923BF252C9E19340FF630BA1D5F /* AFNetworkReachabilityManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkReachabilityManager.h; path = AFNetworking/AFNetworkReachabilityManager.h; sourceTree = ""; }; + 8E65E6E1484B97F7902E3B3A737FC3C1 /* AFNetworking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AFNetworking.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 91E576039DB210C4C22154E3648739A1 /* Chameleon_.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Chameleon_.h; path = "Pod/Classes/Objective-C/Chameleon_.h"; sourceTree = ""; }; + 92895F469B2B958606141683B6F5DA1A /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 92A6631228DA9142C15A208B112CBE85 /* AFImageDownloader.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFImageDownloader.h; path = "UIKit+AFNetworking/AFImageDownloader.h"; sourceTree = ""; }; + 94071DEE80170761AD89A23DAD197E95 /* UIWebView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIWebView+AFNetworking.h"; path = "UIKit+AFNetworking/UIWebView+AFNetworking.h"; sourceTree = ""; }; + 96F35AD2449B9CB67A2ECC7726EE2A32 /* SDImageCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCache.h; path = SDWebImage/SDImageCache.h; sourceTree = ""; }; + 9758519051975CBBF187957B9F45CD4A /* Chameleon.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Chameleon.h; path = "Pod/Classes/Objective-C/Chameleon.h"; sourceTree = ""; }; + 977577C045EDA9D9D1F46E2598D19FC7 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.debug.xcconfig; sourceTree = ""; }; + 9E308322DA038B33575B3583CA0798A8 /* UINavigationController+Chameleon.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UINavigationController+Chameleon.m"; path = "Pod/Classes/Objective-C/UINavigationController+Chameleon.m"; sourceTree = ""; }; + A00447FDCEB071E39255C79188E58FE7 /* UIColor+ChameleonPrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIColor+ChameleonPrivate.h"; path = "Pod/Classes/Objective-C/UIColor+ChameleonPrivate.h"; sourceTree = ""; }; + A0E0F24194609FBC5961FE88B29BADF0 /* AFAutoPurgingImageCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFAutoPurgingImageCache.h; path = "UIKit+AFNetworking/AFAutoPurgingImageCache.h"; sourceTree = ""; }; + A1D4AD56677F149286A0500097D6A092 /* UIProgressView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIProgressView+AFNetworking.h"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.h"; sourceTree = ""; }; + A1E782472E43D6E684C78520E0B31936 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A2BD16ECE03FDEF2DC51C919647943D5 /* SDWebImageDownloader.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloader.h; path = SDWebImage/SDWebImageDownloader.h; sourceTree = ""; }; + A3CA95455AD72EA80ABD1A120C4650E1 /* UIImage+MultiFormat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+MultiFormat.h"; path = "SDWebImage/UIImage+MultiFormat.h"; sourceTree = ""; }; + A59E5B619A049EBE85BA63D35F3EB6B0 /* UIButton+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+WebCache.h"; path = "SDWebImage/UIButton+WebCache.h"; sourceTree = ""; }; + A91DF00F58D2CD70592F12FAC84D3BC2 /* SIAlertView.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = SIAlertView.modulemap; sourceTree = ""; }; + A9BE151AA560C3E90597FE53A05954A7 /* SDWebImage-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SDWebImage-dummy.m"; sourceTree = ""; }; + AB0FE5062FDEF326A4028F2F7D543045 /* AFAutoPurgingImageCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFAutoPurgingImageCache.m; path = "UIKit+AFNetworking/AFAutoPurgingImageCache.m"; sourceTree = ""; }; + AB99830EE90188AF93FA50631EA5E1CD /* AFNetworkReachabilityManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkReachabilityManager.m; path = AFNetworking/AFNetworkReachabilityManager.m; sourceTree = ""; }; + ABA27B678AEF9BCDB3C7046D7F895A12 /* AFNetworking-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "AFNetworking-umbrella.h"; sourceTree = ""; }; + AEE6A3B7D517C1E9D060E13F636167F0 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; + AF2DD425FF9D3D40F9BBDEC2097BFC2C /* UIButton+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+WebCache.m"; path = "SDWebImage/UIButton+WebCache.m"; sourceTree = ""; }; + B0156B96EE5A7F87BC5F7D5D68C45AE7 /* UIView+ChameleonPrivate.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIView+ChameleonPrivate.m"; path = "Pod/Classes/Objective-C/UIView+ChameleonPrivate.m"; sourceTree = ""; }; + B3B3288E024D0F755C575B7D8450B667 /* NSArray+Chameleon.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSArray+Chameleon.h"; path = "Pod/Classes/Objective-C/NSArray+Chameleon.h"; sourceTree = ""; }; + B8F637A66EE8F93892DB27F45CC5C8E3 /* ChameleonFramework-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "ChameleonFramework-prefix.pch"; sourceTree = ""; }; + BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + BB433473714BA06CCF41B7DBED90F88F /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + BE4DF15D2CD93F28E93E0255333E8AF2 /* UIColor+ChameleonPrivate.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIColor+ChameleonPrivate.m"; path = "Pod/Classes/Objective-C/UIColor+ChameleonPrivate.m"; sourceTree = ""; }; + C002D5796E8DC72B699FBFD7CB0C2E83 /* SIAlertView-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SIAlertView-umbrella.h"; sourceTree = ""; }; + C2F1201EEE0CA2057A3219FF00CC9BFA /* UIProgressView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIProgressView+AFNetworking.m"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.m"; sourceTree = ""; }; + C8AF67C0E1630C70E3C2C13563B6C01F /* UIView+WebCacheOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIView+WebCacheOperation.h"; path = "SDWebImage/UIView+WebCacheOperation.h"; sourceTree = ""; }; + CBC0F7C552B739C909B650A0F42F7F38 /* Pods-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-resources.sh"; sourceTree = ""; }; + D0405803033A2A777B8E4DFA0C1800ED /* Pods-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-acknowledgements.markdown"; sourceTree = ""; }; + D0FEAA2EA123F086A95DE4443024BD5E /* UIWebView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIWebView+AFNetworking.m"; path = "UIKit+AFNetworking/UIWebView+AFNetworking.m"; sourceTree = ""; }; + D3E9928D614F687AE64723D366E4C025 /* SDWebImage-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SDWebImage-prefix.pch"; sourceTree = ""; }; + D6DFDBCA26FE67CFAAF748ACE2B398CC /* SIAlertView-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SIAlertView-dummy.m"; sourceTree = ""; }; + D75CEC495D289B978D7FC3454DFA2A64 /* SDWebImagePrefetcher.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImagePrefetcher.h; path = SDWebImage/SDWebImagePrefetcher.h; sourceTree = ""; }; + D9D179FF755EFD14DAE003FDB957D3ED /* UILabel+Chameleon.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UILabel+Chameleon.m"; path = "Pod/Classes/Objective-C/UILabel+Chameleon.m"; sourceTree = ""; }; + DA312349A49333542E6F4B36B329960E /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.release.xcconfig; sourceTree = ""; }; + DB8A82F916E40BB68E0A31C09766D5BE /* UIImageView+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+WebCache.m"; path = "SDWebImage/UIImageView+WebCache.m"; sourceTree = ""; }; + DBEB0DA0ECC4FCD504E89FE705872E88 /* SDWebImageCompat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageCompat.h; path = SDWebImage/SDWebImageCompat.h; sourceTree = ""; }; + DE85BCCC2A5129323CEEEC0AEC32027D /* ChameleonFramework-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "ChameleonFramework-dummy.m"; sourceTree = ""; }; + DF7D3CD05575BD1BC15ED5C4B09B7D35 /* NSData+ImageContentType.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSData+ImageContentType.m"; path = "SDWebImage/NSData+ImageContentType.m"; sourceTree = ""; }; + E07B6ECF12F149E697A66A3C985463AF /* SDWebImageDecoder.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDecoder.m; path = SDWebImage/SDWebImageDecoder.m; sourceTree = ""; }; + E4F4A9D5372ED87B652AF325B765CB3B /* SDWebImageDownloaderOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloaderOperation.h; path = SDWebImage/SDWebImageDownloaderOperation.h; sourceTree = ""; }; + E69C6C2578C5EE54655B31E8BD7F779B /* Foundation.framework */ = {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; }; + E7F21354943D9F42A70697D5A5EF72E9 /* Pods-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-frameworks.sh"; sourceTree = ""; }; + E8446514FBAD26C0E18F24A5715AEF67 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + EA4A2816CC27CC81B26803660B5DF9C4 /* UIImageView+HighlightedWebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+HighlightedWebCache.m"; path = "SDWebImage/UIImageView+HighlightedWebCache.m"; sourceTree = ""; }; + F003BD3E21CB9DB7488F151BE3608260 /* SDWebImage.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImage.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F31677979CB7EFFAA1EB9BBE0FA2330B /* SIAlertView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SIAlertView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F45CBFA61BA8D483714567618CC670FE /* SDWebImagePrefetcher.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImagePrefetcher.m; path = SDWebImage/SDWebImagePrefetcher.m; sourceTree = ""; }; + F5502E8D9885E107FB9D917CBD17C9CA /* UIActivityIndicatorView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIActivityIndicatorView+AFNetworking.m"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m"; sourceTree = ""; }; + F5B6DF504037B1523126C71C6386DCD9 /* SDWebImage.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = SDWebImage.modulemap; sourceTree = ""; }; + F904731712EE1E15DE07E4A384C387D0 /* SIAlertView.bundle */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "wrapper.plug-in"; name = SIAlertView.bundle; path = SIAlertView/SIAlertView.bundle; sourceTree = ""; }; + F9486A437875BAA795DFEA8396B82E3D /* SIAlertView.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SIAlertView.xcconfig; sourceTree = ""; }; + F9B6FE84AFEF2AD2006E42F29AA5F117 /* UIImage+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+AFNetworking.h"; path = "UIKit+AFNetworking/UIImage+AFNetworking.h"; sourceTree = ""; }; + FA1A10E040B375EF112B41C4A0F58516 /* UINavigationController+Chameleon.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UINavigationController+Chameleon.h"; path = "Pod/Classes/Objective-C/UINavigationController+Chameleon.h"; sourceTree = ""; }; + FE7083BC499DDD66A7582D2C7478E2A7 /* ChameleonConstants.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = ChameleonConstants.m; path = "Pod/Classes/Objective-C/ChameleonConstants.m"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1F704B335FE4D11FE6DDC33D41D2CE38 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 3F380B6D0B4DD2E6D87AA320AFC86D09 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3D0E661242C853E94F4299270086801D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ED545537CDC6C83EBA629FE6524D550A /* CoreGraphics.framework in Frameworks */, + 42B81612C22744B21A3AC57DC36F7DD3 /* Foundation.framework in Frameworks */, + 2139B6A9B4241F53BB478C43D51921CC /* QuartzCore.framework in Frameworks */, + C67E03EC22D124DE998695EF86B99E25 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C151364F15F39F7CC60CBF9A3AB49B44 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 7E6A4EFA32969CDB9F9C57903152BA54 /* CoreGraphics.framework in Frameworks */, + 7F17EA5E2787B6F2BBB359854B42A0E3 /* Foundation.framework in Frameworks */, + D04B84B53456B9CD8A7236126075571B /* MobileCoreServices.framework in Frameworks */, + C01AC3BAD9037A8A1E45FD17336C15F3 /* Security.framework in Frameworks */, + 3A10EF6ABF51D1D00B06AC5EF3A8C28C /* SystemConfiguration.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D77C2CE6331C3B56EF41780CCF490502 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 33413A8B4EF4F2D0D463271F93B090B4 /* Foundation.framework in Frameworks */, + 481D2695D475A2BC649D64D2D1C6A03E /* ImageIO.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DA18E87D6E7AACB2B2024ECD4CFDD0E6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + CEB79FC05B4B5DC7AB1C60B17E206426 /* Foundation.framework in Frameworks */, + C9CD229C670F4FD567692E66C8477577 /* QuartzCore.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 10D0CF7566B1073CA2E9CFF57727C539 /* Support Files */ = { + isa = PBXGroup; + children = ( + 3BCA564B0F4EEE904D7A979B401E9D66 /* AFNetworking.modulemap */, + 893A794918CF5C97A5D11D3F131F9F57 /* AFNetworking.xcconfig */, + 1EF8296E82FB9AA440D7FDFDE07B59DB /* AFNetworking-dummy.m */, + 133355A5A8E882B8C3C3996649C5D184 /* AFNetworking-prefix.pch */, + ABA27B678AEF9BCDB3C7046D7F895A12 /* AFNetworking-umbrella.h */, + 6F24ED243F51B6BE7F54947C7BFEA4CA /* Info.plist */, + ); + name = "Support Files"; + path = "../Target Support Files/AFNetworking"; + sourceTree = ""; + }; + 12FF1B0D18F052F63614B7EEC50105E5 /* Pods */ = { + isa = PBXGroup; + children = ( + D245BEF9BCC0DD6A1D3ED96A61511EB4 /* AFNetworking */, + 266E28E647F70CA52FA8E54A41C150C6 /* ChameleonFramework */, + B9B60A1312696EE0FD7EDD089BD7A3BC /* SDWebImage */, + 1EA7ED024DCA2402C5FC8735F139123B /* SIAlertView */, + ); + name = Pods; + sourceTree = ""; + }; + 1EA7ED024DCA2402C5FC8735F139123B /* SIAlertView */ = { + isa = PBXGroup; + children = ( + 71C2519592D6ABFB2BE4CECD790B9C60 /* SIAlertView.h */, + 78A4335ADD114F848EAC73C718093613 /* SIAlertView.m */, + CB4F1CE2D0137DCFEA4A405493E3E6DC /* Resources */, + D183D1ADD9F21EAD429BEE97DF8B9789 /* Support Files */, + ); + path = SIAlertView; + sourceTree = ""; + }; + 23490FC4709A17FE75567BCC4A6E7F0F /* Support Files */ = { + isa = PBXGroup; + children = ( + 507F3BC6B87E2835FF5F9ABF3A38E96D /* ChameleonFramework.modulemap */, + 77B67B56422B56FC9502C450AD6AABA0 /* ChameleonFramework.xcconfig */, + DE85BCCC2A5129323CEEEC0AEC32027D /* ChameleonFramework-dummy.m */, + B8F637A66EE8F93892DB27F45CC5C8E3 /* ChameleonFramework-prefix.pch */, + 4E972BD575C71E413202FB208CE11820 /* ChameleonFramework-umbrella.h */, + BB433473714BA06CCF41B7DBED90F88F /* Info.plist */, + ); + name = "Support Files"; + path = "../Target Support Files/ChameleonFramework"; + sourceTree = ""; + }; + 266E28E647F70CA52FA8E54A41C150C6 /* ChameleonFramework */ = { + isa = PBXGroup; + children = ( + F70AECF279372D4F5818229CD53EBE2D /* Default */, + 23490FC4709A17FE75567BCC4A6E7F0F /* Support Files */, + ); + path = ChameleonFramework; + sourceTree = ""; + }; + 29DC22EAF1296C7886ECA3704AAD3093 /* Security */ = { + isa = PBXGroup; + children = ( + 0548FC51C30DA6BA6A5CD9BAA8ECC879 /* AFSecurityPolicy.h */, + 0C9432229A2D2E8D7B1339B6FCE39B08 /* AFSecurityPolicy.m */, + ); + name = Security; + sourceTree = ""; + }; + 2A23C0A3C752A894BC28FF0765851596 /* Serialization */ = { + isa = PBXGroup; + children = ( + 4C1D56168357FBA6F995515CF005A94F /* AFURLRequestSerialization.h */, + 1A66B0E8FA78C381B0F7ECE70A5ED69D /* AFURLRequestSerialization.m */, + 1684D4556D43287C736258444195B29C /* AFURLResponseSerialization.h */, + 24C1F326D69F202E5391182C8199EA1C /* AFURLResponseSerialization.m */, + ); + name = Serialization; + sourceTree = ""; + }; + 405545D026BE28B54B2EE45D2E942C6D /* Support Files */ = { + isa = PBXGroup; + children = ( + A1E782472E43D6E684C78520E0B31936 /* Info.plist */, + F5B6DF504037B1523126C71C6386DCD9 /* SDWebImage.modulemap */, + 4D7681B7F660CCAC139F2E4A99B16D1E /* SDWebImage.xcconfig */, + A9BE151AA560C3E90597FE53A05954A7 /* SDWebImage-dummy.m */, + D3E9928D614F687AE64723D366E4C025 /* SDWebImage-prefix.pch */, + 0222DD3060B4FDB5F67C0B9E73EF62E4 /* SDWebImage-umbrella.h */, + ); + name = "Support Files"; + path = "../Target Support Files/SDWebImage"; + sourceTree = ""; + }; + 50CA3C815548D8CA4FFFFC34D66643D6 /* iOS */ = { + isa = PBXGroup; + children = ( + 6EEC0CA412D7FB80A0AB6CD28BD7C44E /* CoreGraphics.framework */, + E69C6C2578C5EE54655B31E8BD7F779B /* Foundation.framework */, + 40182B7FF44217D3F633FF36BE3E4831 /* ImageIO.framework */, + 6944ED9DFD7B5B9887BDA5FDA5193EF3 /* MobileCoreServices.framework */, + 1441BB11E4761F1BC04D6C0E00872AEC /* QuartzCore.framework */, + 5F7B9818167212F7413F0950564EDA45 /* Security.framework */, + AEE6A3B7D517C1E9D060E13F636167F0 /* SystemConfiguration.framework */, + 8A566ABA6EE8D60B1990A0F955E25E76 /* UIKit.framework */, + ); + name = iOS; + sourceTree = ""; + }; + 5797A23E100940F524B9CDD398914EC5 /* UIKit */ = { + isa = PBXGroup; + children = ( + A0E0F24194609FBC5961FE88B29BADF0 /* AFAutoPurgingImageCache.h */, + AB0FE5062FDEF326A4028F2F7D543045 /* AFAutoPurgingImageCache.m */, + 92A6631228DA9142C15A208B112CBE85 /* AFImageDownloader.h */, + 4A42091A5CF7ACF7633FE12F30B5A96E /* AFImageDownloader.m */, + 3678A579063EE57B009031ECAB496DAB /* AFNetworkActivityIndicatorManager.h */, + 5A8808E8D69DB0F13C7D17978C1115D5 /* AFNetworkActivityIndicatorManager.m */, + 13F0254858ED1938ED0DDDC534E0AFC7 /* UIActivityIndicatorView+AFNetworking.h */, + F5502E8D9885E107FB9D917CBD17C9CA /* UIActivityIndicatorView+AFNetworking.m */, + 69B22AD40C656C5C8EF7BC256A3AAC50 /* UIButton+AFNetworking.h */, + 00928814FCF3BC55D5493A10707B40CB /* UIButton+AFNetworking.m */, + F9B6FE84AFEF2AD2006E42F29AA5F117 /* UIImage+AFNetworking.h */, + 29391A1EC984788CE098CAED891CB388 /* UIImageView+AFNetworking.h */, + 05149083EA6274F979042D7B5A1BE849 /* UIImageView+AFNetworking.m */, + 77F5211664F5579DF283409D0A987B58 /* UIKit+AFNetworking.h */, + A1D4AD56677F149286A0500097D6A092 /* UIProgressView+AFNetworking.h */, + C2F1201EEE0CA2057A3219FF00CC9BFA /* UIProgressView+AFNetworking.m */, + 0256C091480F0D741C7251028BD1FCF1 /* UIRefreshControl+AFNetworking.h */, + 8AD17CF93C3CD37548ACAB340BD0B279 /* UIRefreshControl+AFNetworking.m */, + 94071DEE80170761AD89A23DAD197E95 /* UIWebView+AFNetworking.h */, + D0FEAA2EA123F086A95DE4443024BD5E /* UIWebView+AFNetworking.m */, + ); + name = UIKit; + sourceTree = ""; + }; + 69001B73BC89C4419DA782EE8005EFB5 /* Reachability */ = { + isa = PBXGroup; + children = ( + 8C933923BF252C9E19340FF630BA1D5F /* AFNetworkReachabilityManager.h */, + AB99830EE90188AF93FA50631EA5E1CD /* AFNetworkReachabilityManager.m */, + ); + name = Reachability; + sourceTree = ""; + }; + 75D98FF52E597A11900E131B6C4E1ADA /* Pods */ = { + isa = PBXGroup; + children = ( + E8446514FBAD26C0E18F24A5715AEF67 /* Info.plist */, + 79A9DEDC89FE8336BF5FEDAAF75BF7FC /* Pods.modulemap */, + D0405803033A2A777B8E4DFA0C1800ED /* Pods-acknowledgements.markdown */, + 87B213035BAC5F75386F62D3C75D2342 /* Pods-acknowledgements.plist */, + 894E5DA93A9F359521A89826BE6DA777 /* Pods-dummy.m */, + E7F21354943D9F42A70697D5A5EF72E9 /* Pods-frameworks.sh */, + CBC0F7C552B739C909B650A0F42F7F38 /* Pods-resources.sh */, + 2BCC458FDD5F692BBB2BFC64BB5701FC /* Pods-umbrella.h */, + 977577C045EDA9D9D1F46E2598D19FC7 /* Pods.debug.xcconfig */, + DA312349A49333542E6F4B36B329960E /* Pods.release.xcconfig */, + ); + name = Pods; + path = "Target Support Files/Pods"; + sourceTree = ""; + }; + 785553737B06AFC3DA711DDEB7D56194 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 50CA3C815548D8CA4FFFFC34D66643D6 /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 7DB346D0F39D3F0E887471402A8071AB = { + isa = PBXGroup; + children = ( + BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */, + 785553737B06AFC3DA711DDEB7D56194 /* Frameworks */, + 12FF1B0D18F052F63614B7EEC50105E5 /* Pods */, + DAC06A2E43582354E7B862D3D23312D8 /* Products */, + B7B80995527643776607AFFA75B91E24 /* Targets Support Files */, + ); + sourceTree = ""; + }; + B519D279A67361AB74C228B713353CDF /* Core */ = { + isa = PBXGroup; + children = ( + 14B310D1EE4EEAB229349E0FB55039EA /* NSData+ImageContentType.h */, + DF7D3CD05575BD1BC15ED5C4B09B7D35 /* NSData+ImageContentType.m */, + 96F35AD2449B9CB67A2ECC7726EE2A32 /* SDImageCache.h */, + 79F636878B51E135C2796D04FF25FFD9 /* SDImageCache.m */, + DBEB0DA0ECC4FCD504E89FE705872E88 /* SDWebImageCompat.h */, + 79DA00548D047B39D7865C7FB8F4CA45 /* SDWebImageCompat.m */, + 261824B849239DE2DFF2B95C452EC74C /* SDWebImageDecoder.h */, + E07B6ECF12F149E697A66A3C985463AF /* SDWebImageDecoder.m */, + A2BD16ECE03FDEF2DC51C919647943D5 /* SDWebImageDownloader.h */, + 79C6BE498D9F6870CF1E2565FFACFB10 /* SDWebImageDownloader.m */, + E4F4A9D5372ED87B652AF325B765CB3B /* SDWebImageDownloaderOperation.h */, + 3AC26E4849C4688AB2833C0203BD5EFD /* SDWebImageDownloaderOperation.m */, + 7254B6EBAAA3E58D8E0BD374F0AB6A26 /* SDWebImageManager.h */, + 061891051576CD0D66997B91A922A3C1 /* SDWebImageManager.m */, + 86BD1FB960BE84CCA878F92E5A3CF958 /* SDWebImageOperation.h */, + D75CEC495D289B978D7FC3454DFA2A64 /* SDWebImagePrefetcher.h */, + F45CBFA61BA8D483714567618CC670FE /* SDWebImagePrefetcher.m */, + A59E5B619A049EBE85BA63D35F3EB6B0 /* UIButton+WebCache.h */, + AF2DD425FF9D3D40F9BBDEC2097BFC2C /* UIButton+WebCache.m */, + 8559AD718FB3DDF73F7E35A6030BEE57 /* UIImage+GIF.h */, + 19DDE813B74AB915ED3F8EE1B38E8188 /* UIImage+GIF.m */, + A3CA95455AD72EA80ABD1A120C4650E1 /* UIImage+MultiFormat.h */, + 3B8B39F9BFE1B49BAD4FFE8014C78C0F /* UIImage+MultiFormat.m */, + 36480C55417C1CE218EDC8C29D6DE27B /* UIImageView+HighlightedWebCache.h */, + EA4A2816CC27CC81B26803660B5DF9C4 /* UIImageView+HighlightedWebCache.m */, + 2E69F80FBF41C5991FCEAFDD3F7D2998 /* UIImageView+WebCache.h */, + DB8A82F916E40BB68E0A31C09766D5BE /* UIImageView+WebCache.m */, + C8AF67C0E1630C70E3C2C13563B6C01F /* UIView+WebCacheOperation.h */, + 8986E57FEDECCECA19D6F456A7F810DF /* UIView+WebCacheOperation.m */, + ); + name = Core; + sourceTree = ""; + }; + B7B80995527643776607AFFA75B91E24 /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + 75D98FF52E597A11900E131B6C4E1ADA /* Pods */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; + B9B60A1312696EE0FD7EDD089BD7A3BC /* SDWebImage */ = { + isa = PBXGroup; + children = ( + B519D279A67361AB74C228B713353CDF /* Core */, + 405545D026BE28B54B2EE45D2E942C6D /* Support Files */, + ); + path = SDWebImage; + sourceTree = ""; + }; + CB4F1CE2D0137DCFEA4A405493E3E6DC /* Resources */ = { + isa = PBXGroup; + children = ( + F904731712EE1E15DE07E4A384C387D0 /* SIAlertView.bundle */, + ); + name = Resources; + sourceTree = ""; + }; + D183D1ADD9F21EAD429BEE97DF8B9789 /* Support Files */ = { + isa = PBXGroup; + children = ( + 92895F469B2B958606141683B6F5DA1A /* Info.plist */, + A91DF00F58D2CD70592F12FAC84D3BC2 /* SIAlertView.modulemap */, + F9486A437875BAA795DFEA8396B82E3D /* SIAlertView.xcconfig */, + D6DFDBCA26FE67CFAAF748ACE2B398CC /* SIAlertView-dummy.m */, + 87BCB10DAAAEF784FA72C9B3BF4A0AB0 /* SIAlertView-prefix.pch */, + C002D5796E8DC72B699FBFD7CB0C2E83 /* SIAlertView-umbrella.h */, + ); + name = "Support Files"; + path = "../Target Support Files/SIAlertView"; + sourceTree = ""; + }; + D245BEF9BCC0DD6A1D3ED96A61511EB4 /* AFNetworking */ = { + isa = PBXGroup; + children = ( + 09B5CAD28C440E32969A20EE7E7BE9D9 /* AFNetworking.h */, + FD79642518C50C08534DD3DDC842A8AE /* NSURLSession */, + 69001B73BC89C4419DA782EE8005EFB5 /* Reachability */, + 29DC22EAF1296C7886ECA3704AAD3093 /* Security */, + 2A23C0A3C752A894BC28FF0765851596 /* Serialization */, + 10D0CF7566B1073CA2E9CFF57727C539 /* Support Files */, + 5797A23E100940F524B9CDD398914EC5 /* UIKit */, + ); + path = AFNetworking; + sourceTree = ""; + }; + DAC06A2E43582354E7B862D3D23312D8 /* Products */ = { + isa = PBXGroup; + children = ( + 8E65E6E1484B97F7902E3B3A737FC3C1 /* AFNetworking.framework */, + 19858785CC92C12C9FC67C1A3C448B71 /* ChameleonFramework.framework */, + 460B6F09D8F4B5F3B88C9D288514D92A /* Pods.framework */, + F003BD3E21CB9DB7488F151BE3608260 /* SDWebImage.framework */, + F31677979CB7EFFAA1EB9BBE0FA2330B /* SIAlertView.framework */, + ); + name = Products; + sourceTree = ""; + }; + F70AECF279372D4F5818229CD53EBE2D /* Default */ = { + isa = PBXGroup; + children = ( + 9758519051975CBBF187957B9F45CD4A /* Chameleon.h */, + 91E576039DB210C4C22154E3648739A1 /* Chameleon_.h */, + 222696BBCD1EADA99117A5586F2182C4 /* Chameleon_.m */, + 5C924B0030AA0F805839E520FEBDA66C /* ChameleonConstants.h */, + FE7083BC499DDD66A7582D2C7478E2A7 /* ChameleonConstants.m */, + 6186E72B27ED368B2B15B2E59E9874CC /* ChameleonEnums.h */, + 4F6A620F784540CCAC8826D3F35BC267 /* ChameleonMacros.h */, + B3B3288E024D0F755C575B7D8450B667 /* NSArray+Chameleon.h */, + 40FEEC272573BE197E4BBB1FC139FDC2 /* NSArray+Chameleon.m */, + 045A0795AD66897AA232937311DCDD7B /* UIAppearance+Swift.h */, + 5E2E35694543CC52199588655D064843 /* UIAppearance+Swift.m */, + 4C9ED7629FB1AB491D321D2665095792 /* UIButton+Chameleon.h */, + 7BF8991AAEDDC5F26734BCAC875F4A7B /* UIButton+Chameleon.m */, + 3E892333521B02CED2C188199C4FC260 /* UIColor+Chameleon.h */, + 47331CFA95DE5A83D806E6213F4C871B /* UIColor+Chameleon.m */, + A00447FDCEB071E39255C79188E58FE7 /* UIColor+ChameleonPrivate.h */, + BE4DF15D2CD93F28E93E0255333E8AF2 /* UIColor+ChameleonPrivate.m */, + 6DF518081FD49CFD1C5E46CC45689EAA /* UIImage+ChameleonPrivate.h */, + 32D2B7187E8CD92B370BDED591331791 /* UIImage+ChameleonPrivate.m */, + 1AE55F1DC9E05C9F1B8AEC331057C952 /* UILabel+Chameleon.h */, + D9D179FF755EFD14DAE003FDB957D3ED /* UILabel+Chameleon.m */, + FA1A10E040B375EF112B41C4A0F58516 /* UINavigationController+Chameleon.h */, + 9E308322DA038B33575B3583CA0798A8 /* UINavigationController+Chameleon.m */, + 6E142146DAE6D0F0F7D44656D80C9D6B /* UIView+ChameleonPrivate.h */, + B0156B96EE5A7F87BC5F7D5D68C45AE7 /* UIView+ChameleonPrivate.m */, + 301EE93398BD24FF57949ADFAC7555E5 /* UIViewController+Chameleon.h */, + 292B12936E492B93444D42044987B350 /* UIViewController+Chameleon.m */, + ); + name = Default; + sourceTree = ""; + }; + FD79642518C50C08534DD3DDC842A8AE /* NSURLSession */ = { + isa = PBXGroup; + children = ( + 07AD017890591F8499F271B6A80DDA76 /* AFHTTPSessionManager.h */, + 63B9F6CD8068797152C94DC8221A170A /* AFHTTPSessionManager.m */, + 671E7BEAD7E869CB593B71038B4DE327 /* AFURLSessionManager.h */, + 27F4E4B5EA42C02400CF305F1468B26C /* AFURLSessionManager.m */, + ); + name = NSURLSession; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 21AB9F16B3D90A4367B8ECDC9DBD6CB4 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 7AF712E95A1110B47775A10777DA6CFE /* Pods-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 40F639DE65D946A85FEBA9C514E7C1F4 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + F5CC9B27F3CF472FE72A905E8C2D7A9D /* Chameleon.h in Headers */, + E04963F0C6D76377186361A0AF79A4C6 /* Chameleon_.h in Headers */, + 4B181B0AC8894DE05050B3F6718D392C /* ChameleonConstants.h in Headers */, + E53E2CD0E939A133E73880E7B3BB4DBF /* ChameleonEnums.h in Headers */, + FA90B7D6EBE7A289796856FF2B310FC0 /* ChameleonFramework-umbrella.h in Headers */, + 41E19345B5C2331DAA02119D782F4E5F /* ChameleonMacros.h in Headers */, + C61ED2CF225C6D9872D34F5455C945D4 /* NSArray+Chameleon.h in Headers */, + F85099F6E9B7DB837BAB856EB61A6F07 /* UIAppearance+Swift.h in Headers */, + 3CCCC6F0C10F65283522C54CF1D6E761 /* UIButton+Chameleon.h in Headers */, + C5D22B9D6600C31DC02CEC59BDA086B0 /* UIColor+Chameleon.h in Headers */, + CC51E5C010ABC87B9CAAA1CB721A6A94 /* UIColor+ChameleonPrivate.h in Headers */, + 1DE26E57570167EE496080D68F855A01 /* UIImage+ChameleonPrivate.h in Headers */, + 3132A9EBC1F85B6971B934C88914CD58 /* UILabel+Chameleon.h in Headers */, + C84DFC79CACF46C6275670861ADBA6D4 /* UINavigationController+Chameleon.h in Headers */, + B3429381360BE9C37D00301284E4B63A /* UIView+ChameleonPrivate.h in Headers */, + 7EDDB8F47291F592694D7135A10DAFFF /* UIViewController+Chameleon.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4BECEFD0377C4335C2B6E45810E955BA /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + C4D89B2B2A66551C30E50AA6277B490B /* SIAlertView-umbrella.h in Headers */, + 1584A0B442DA93BF1AF49A8D82432AF4 /* SIAlertView.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 7C6A0D99A9CC32A19A92A62F8A941139 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + CAC483EF637FB4A2C2E2FC75BA631B87 /* AFAutoPurgingImageCache.h in Headers */, + AB39AC9746E7575D7449700475E41B0B /* AFHTTPSessionManager.h in Headers */, + 5808B477EFF509D810B5CDCFDC944F80 /* AFImageDownloader.h in Headers */, + 1480F4923DBBF217F60572EEECB4027C /* AFNetworkActivityIndicatorManager.h in Headers */, + EC7CADE416A78A1CD6936018A6695126 /* AFNetworking-umbrella.h in Headers */, + E7988678C81F7CCB95D239375FC6986D /* AFNetworking.h in Headers */, + 68152D921ABF6A423C192C04FDF94F0F /* AFNetworkReachabilityManager.h in Headers */, + C2DD28375E1F0B1D0D1D2E4E607C499F /* AFSecurityPolicy.h in Headers */, + 20EE8030FCF2402DAC7F1C9B9DDAEF79 /* AFURLRequestSerialization.h in Headers */, + 7332F15718920917F544F35CE2C038AA /* AFURLResponseSerialization.h in Headers */, + 560698A4D707DCBCC1C8F98BC9B89B23 /* AFURLSessionManager.h in Headers */, + 1E5B8F12ED7CC40ECDB9B1F755F387E5 /* UIActivityIndicatorView+AFNetworking.h in Headers */, + 81B617F8D26BB10C5726D75E85D21EB7 /* UIButton+AFNetworking.h in Headers */, + 9E1E90DED74B73ECE53C9AD76DE53E2D /* UIImage+AFNetworking.h in Headers */, + 60E3009342BEE96D32C546BE2DB60052 /* UIImageView+AFNetworking.h in Headers */, + 659960F7E28E993E08CCC1E8A383E710 /* UIKit+AFNetworking.h in Headers */, + D9F4E833E37B611B432F6B5D7072DDA2 /* UIProgressView+AFNetworking.h in Headers */, + C6354FEC7728A4C86DAD8092509BA7D4 /* UIRefreshControl+AFNetworking.h in Headers */, + AE2A07407FB50BA249984DC0620E84C0 /* UIWebView+AFNetworking.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ED1DBE69C009B1DEF41FF44193AB584C /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 10F4AA3E8A1DE840EB69CDA0CD0BE848 /* NSData+ImageContentType.h in Headers */, + C0F98157BC58FC156904C9198FDFC712 /* SDImageCache.h in Headers */, + 1A19A456017D2EB235DA00961A8A664F /* SDWebImage-umbrella.h in Headers */, + 21D927B42CB12293E5E57756F9F5D943 /* SDWebImageCompat.h in Headers */, + 3751DD3EE60E97490755E539B619A01C /* SDWebImageDecoder.h in Headers */, + 932E320A9BBD2B15F8823A2AF7382C2F /* SDWebImageDownloader.h in Headers */, + F20F6CEB143FB1C11261424DBD6684B9 /* SDWebImageDownloaderOperation.h in Headers */, + 4605EEF216A3BAC0CC1F6F5F133A80CE /* SDWebImageManager.h in Headers */, + CDF0F982DFF346BC5CBB44DDD15AE9DA /* SDWebImageOperation.h in Headers */, + 59DCF5EA20D577A83170787EB14A7C5B /* SDWebImagePrefetcher.h in Headers */, + 99C65AA7B2590E1151C5342409E4FD7B /* UIButton+WebCache.h in Headers */, + 5A6D94B2D866B061E659E29D8B332063 /* UIImage+GIF.h in Headers */, + 8AAC2FBF0DE93A078EBDEFF92CF0D4F7 /* UIImage+MultiFormat.h in Headers */, + C5A569BD6FD764853397C8C6DCF32AD3 /* UIImageView+HighlightedWebCache.h in Headers */, + A9EF5BAE4367A92E58C3BAE6B97E849B /* UIImageView+WebCache.h in Headers */, + BF2143417C483F5D9D794113D5051BF0 /* UIView+WebCacheOperation.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 1C3436CEA5C3D39764C5F54374794ECB /* AFNetworking */ = { + isa = PBXNativeTarget; + buildConfigurationList = 57800A0D1724774333EF09E83030AA81 /* Build configuration list for PBXNativeTarget "AFNetworking" */; + buildPhases = ( + 1F17F426378DF5EC8DFB10304B8C4BA4 /* Sources */, + C151364F15F39F7CC60CBF9A3AB49B44 /* Frameworks */, + 7C6A0D99A9CC32A19A92A62F8A941139 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AFNetworking; + productName = AFNetworking; + productReference = 8E65E6E1484B97F7902E3B3A737FC3C1 /* AFNetworking.framework */; + productType = "com.apple.product-type.framework"; + }; + 6E803FEE2E9A15DD81D02620FD16AC5B /* Pods */ = { + isa = PBXNativeTarget; + buildConfigurationList = 82A4C7A608BCE950E0EDB91562C64979 /* Build configuration list for PBXNativeTarget "Pods" */; + buildPhases = ( + BC3F84363C8739E9797B2CC91A9B561B /* Sources */, + 1F704B335FE4D11FE6DDC33D41D2CE38 /* Frameworks */, + 21AB9F16B3D90A4367B8ECDC9DBD6CB4 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + BD49CD9083D8BF6A703DD12FE5D1ACFF /* PBXTargetDependency */, + 95640556C9C51694907A2B03FBDAA79F /* PBXTargetDependency */, + 76715492F935BADEFB551E4ED96BC2EF /* PBXTargetDependency */, + BC221AA9E7B5ABAA8A8D172B8EC4F1AE /* PBXTargetDependency */, + ); + name = Pods; + productName = Pods; + productReference = 460B6F09D8F4B5F3B88C9D288514D92A /* Pods.framework */; + productType = "com.apple.product-type.framework"; + }; + 9B57F4EE4746045CEAE2D933A3C8EC9E /* ChameleonFramework */ = { + isa = PBXNativeTarget; + buildConfigurationList = 085A04470B2B1DFD89B69ED30150E0C0 /* Build configuration list for PBXNativeTarget "ChameleonFramework" */; + buildPhases = ( + 89476504D00DCE7D76865152A8267270 /* Sources */, + 3D0E661242C853E94F4299270086801D /* Frameworks */, + 40F639DE65D946A85FEBA9C514E7C1F4 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ChameleonFramework; + productName = ChameleonFramework; + productReference = 19858785CC92C12C9FC67C1A3C448B71 /* ChameleonFramework.framework */; + productType = "com.apple.product-type.framework"; + }; + B288D3B845DF95DB82ED94BED76C6960 /* SDWebImage */ = { + isa = PBXNativeTarget; + buildConfigurationList = F88F3E78659566AF8FF03C461B5393F4 /* Build configuration list for PBXNativeTarget "SDWebImage" */; + buildPhases = ( + FAFA922A1C6837EC2F214D40C59FA585 /* Sources */, + D77C2CE6331C3B56EF41780CCF490502 /* Frameworks */, + ED1DBE69C009B1DEF41FF44193AB584C /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SDWebImage; + productName = SDWebImage; + productReference = F003BD3E21CB9DB7488F151BE3608260 /* SDWebImage.framework */; + productType = "com.apple.product-type.framework"; + }; + F4A7EEEFE72653B329822E7F980DEB17 /* SIAlertView */ = { + isa = PBXNativeTarget; + buildConfigurationList = F50F318150C6D07FFB8D7FF0AFD126DF /* Build configuration list for PBXNativeTarget "SIAlertView" */; + buildPhases = ( + 4A4E0D0A41F0C1BD3C804F761DBBACC2 /* Sources */, + DA18E87D6E7AACB2B2024ECD4CFDD0E6 /* Frameworks */, + 4BECEFD0377C4335C2B6E45810E955BA /* Headers */, + 8872033A7E1D09CB5901202389465E4A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SIAlertView; + productName = SIAlertView; + productReference = F31677979CB7EFFAA1EB9BBE0FA2330B /* SIAlertView.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0700; + LastUpgradeCheck = 0700; + }; + buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7DB346D0F39D3F0E887471402A8071AB; + productRefGroup = DAC06A2E43582354E7B862D3D23312D8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1C3436CEA5C3D39764C5F54374794ECB /* AFNetworking */, + 9B57F4EE4746045CEAE2D933A3C8EC9E /* ChameleonFramework */, + 6E803FEE2E9A15DD81D02620FD16AC5B /* Pods */, + B288D3B845DF95DB82ED94BED76C6960 /* SDWebImage */, + F4A7EEEFE72653B329822E7F980DEB17 /* SIAlertView */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8872033A7E1D09CB5901202389465E4A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3997DB2DDBBA43002E76791E759AD67F /* SIAlertView.bundle in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1F17F426378DF5EC8DFB10304B8C4BA4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3F1BC9BAFFEEABB1ABC7614DF0FC97D5 /* AFAutoPurgingImageCache.m in Sources */, + E0D4045AC4C1B41917FCA23A042D18B2 /* AFHTTPSessionManager.m in Sources */, + CFA8D6B529A0EBFF0316F2629AB2556E /* AFImageDownloader.m in Sources */, + A6C6019D45BE62C61210A9CC619368EF /* AFNetworkActivityIndicatorManager.m in Sources */, + 3D2789FC760A97301909F0B1201626CD /* AFNetworking-dummy.m in Sources */, + 68A38977EBAE334DC3C22386D00D2622 /* AFNetworkReachabilityManager.m in Sources */, + 20607BE2B1E5F31765026E5AC64DB27D /* AFSecurityPolicy.m in Sources */, + DFFA215EEAA8DDBD540076927535275C /* AFURLRequestSerialization.m in Sources */, + B5852322ADE88AAD56EE042B80BA81E4 /* AFURLResponseSerialization.m in Sources */, + 707B1A7541C8DBDDE8C27896A61370BE /* AFURLSessionManager.m in Sources */, + 6ED4ABEE8A5F51F5ECB59FA1781D29C6 /* UIActivityIndicatorView+AFNetworking.m in Sources */, + AF03C11A1FAC8132AD3749D8F541701A /* UIButton+AFNetworking.m in Sources */, + 2E8A32ED46194EDBE22146271F6D26DE /* UIImageView+AFNetworking.m in Sources */, + 5FF6453E55785669885F626B853FD2AA /* UIProgressView+AFNetworking.m in Sources */, + 174202BD6AE0E4A41F5CE66E975EAE52 /* UIRefreshControl+AFNetworking.m in Sources */, + A462945883F7729B185B64B679A6BFBE /* UIWebView+AFNetworking.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4A4E0D0A41F0C1BD3C804F761DBBACC2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0B7BBE1823A00619148E2C6CF9BDEA2C /* SIAlertView-dummy.m in Sources */, + 8D261B47DAB28AB33C79C140A39EA3F8 /* SIAlertView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 89476504D00DCE7D76865152A8267270 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3D1FF907F6AD5186FAF926C0F20083AE /* Chameleon_.m in Sources */, + 5BF38591007E7E4ADAD878E405949598 /* ChameleonConstants.m in Sources */, + DDD470435EE37EBA46CD0FF081559295 /* ChameleonFramework-dummy.m in Sources */, + 160634C0F5454A32E810DDF5BA9E5985 /* NSArray+Chameleon.m in Sources */, + 7A8C05065D9F9BA2C218F75AD6B1F798 /* UIAppearance+Swift.m in Sources */, + 1716FA0939818C49FE4BBE6A658E9834 /* UIButton+Chameleon.m in Sources */, + 4E53C48294089DC928E3A7BD1C2DE4D7 /* UIColor+Chameleon.m in Sources */, + 00E3A68D030F24BE47B99D1D1A1720E2 /* UIColor+ChameleonPrivate.m in Sources */, + 072BEEF7E71F00675E87028A9A668B84 /* UIImage+ChameleonPrivate.m in Sources */, + 9EEBF7B1602C1C17236C4EA0DD9717E2 /* UILabel+Chameleon.m in Sources */, + 23795D7EC1AF274A6AFF4233B1E84C4C /* UINavigationController+Chameleon.m in Sources */, + F32D7BD1DA58639964C91FA86A002AB4 /* UIView+ChameleonPrivate.m in Sources */, + 2E2946436612A5B920BE18E09BF80CAF /* UIViewController+Chameleon.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BC3F84363C8739E9797B2CC91A9B561B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4FEB67CF6D76321459C7DF80EE6F92CD /* Pods-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + FAFA922A1C6837EC2F214D40C59FA585 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E98AA3E890BE4D11B192EB37F6A4408C /* NSData+ImageContentType.m in Sources */, + E5A4261DB22000B4610387FA7BE880E3 /* SDImageCache.m in Sources */, + 233031A4C2D25B3DD6515CC3C3FEA4F8 /* SDWebImage-dummy.m in Sources */, + 9F10DE788137C16984164B6EA67B27EF /* SDWebImageCompat.m in Sources */, + 131F64370D44DB8EAF6D1046ED2CFB3A /* SDWebImageDecoder.m in Sources */, + 0BCEB4526A2E5952C5A58A347D6C3D06 /* SDWebImageDownloader.m in Sources */, + 5E1AB9270BCE9081098EDB82F9A8B511 /* SDWebImageDownloaderOperation.m in Sources */, + 5C65C36731C43213CDF68B10802AA2DB /* SDWebImageManager.m in Sources */, + 6497DED0C01B70FA6A79A4FC392EE473 /* SDWebImagePrefetcher.m in Sources */, + E1A9C067A09E9F17BEE220DD68EBCFC8 /* UIButton+WebCache.m in Sources */, + 63460DFE31F42291286A2B2BB53A8553 /* UIImage+GIF.m in Sources */, + 13AE3036636034BB4E50A218D3EE27CD /* UIImage+MultiFormat.m in Sources */, + B8721458CA3A54F8241D117A718A08AE /* UIImageView+HighlightedWebCache.m in Sources */, + 9DFA471A792EF016C2F1A672CF10CEBE /* UIImageView+WebCache.m in Sources */, + 3CC775A00BF15E8E6B6E495741E64A85 /* UIView+WebCacheOperation.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 76715492F935BADEFB551E4ED96BC2EF /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = SDWebImage; + target = B288D3B845DF95DB82ED94BED76C6960 /* SDWebImage */; + targetProxy = 87BBC3CF8F5719970699DD53DEB01BAD /* PBXContainerItemProxy */; + }; + 95640556C9C51694907A2B03FBDAA79F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = ChameleonFramework; + target = 9B57F4EE4746045CEAE2D933A3C8EC9E /* ChameleonFramework */; + targetProxy = E8795D0ED7A3D25C79B7F86CB32E1437 /* PBXContainerItemProxy */; + }; + BC221AA9E7B5ABAA8A8D172B8EC4F1AE /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = SIAlertView; + target = F4A7EEEFE72653B329822E7F980DEB17 /* SIAlertView */; + targetProxy = 21B1BF1CE89E3A0058A7A1C4A9D0254F /* PBXContainerItemProxy */; + }; + BD49CD9083D8BF6A703DD12FE5D1ACFF /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = AFNetworking; + target = 1C3436CEA5C3D39764C5F54374794ECB /* AFNetworking */; + targetProxy = A42011885E18F4AE5EA18396A9CB26C6 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 0B5D563BF2710D60DE742D336E8B2033 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 77B67B56422B56FC9502C450AD6AABA0 /* ChameleonFramework.xcconfig */; + 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/ChameleonFramework/ChameleonFramework-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/ChameleonFramework/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/ChameleonFramework/ChameleonFramework.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = ChameleonFramework; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 32D9715C38DF7558D7169BD6DA3D6586 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 77B67B56422B56FC9502C450AD6AABA0 /* ChameleonFramework.xcconfig */; + 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/ChameleonFramework/ChameleonFramework-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/ChameleonFramework/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/ChameleonFramework/ChameleonFramework.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = ChameleonFramework; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 81BDF4D1C815B1B241AB05259E621D63 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = DA312349A49333542E6F4B36B329960E /* Pods.release.xcconfig */; + 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 = 8.1; + 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 = ""; + }; + name = Release; + }; + 939844BA2F3145A178F677BD3A16C350 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F9486A437875BAA795DFEA8396B82E3D /* SIAlertView.xcconfig */; + 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/SIAlertView/SIAlertView-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SIAlertView/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SIAlertView/SIAlertView.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = SIAlertView; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 94FBD736C6FE11D5D827D73D1D053D05 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 893A794918CF5C97A5D11D3F131F9F57 /* AFNetworking.xcconfig */; + 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/AFNetworking/AFNetworking-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/AFNetworking/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/AFNetworking/AFNetworking.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = AFNetworking; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 993F4C81BF62BA1916F3808216C7A5F9 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4D7681B7F660CCAC139F2E4A99B16D1E /* SDWebImage.xcconfig */; + 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/SDWebImage/SDWebImage-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SDWebImage/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SDWebImage/SDWebImage.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = SDWebImage; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 9EB645C612834738B99727720210C23E /* Debug */ = { + isa = XCBuildConfiguration; + 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 = 8.1; + ONLY_ACTIVE_ARCH = YES; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + B8B7E75EEC9B1A716DCB133B30AE41EE /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4D7681B7F660CCAC139F2E4A99B16D1E /* SDWebImage.xcconfig */; + 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/SDWebImage/SDWebImage-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SDWebImage/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SDWebImage/SDWebImage.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = SDWebImage; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + C887752198ABE1F29935C2718E933EAC /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 893A794918CF5C97A5D11D3F131F9F57 /* AFNetworking.xcconfig */; + 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/AFNetworking/AFNetworking-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/AFNetworking/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/AFNetworking/AFNetworking.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = AFNetworking; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + E39CD1E764776175CB82EEC82A6C9948 /* Release */ = { + isa = XCBuildConfiguration; + 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 = 8.1; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + EA2A44D378A01FD36B885CC9BDF92F68 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 977577C045EDA9D9D1F46E2598D19FC7 /* Pods.debug.xcconfig */; + 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 = 8.1; + 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; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + F5AECEA9DABEC880AEAF6F3FD2EB06E6 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F9486A437875BAA795DFEA8396B82E3D /* SIAlertView.xcconfig */; + 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/SIAlertView/SIAlertView-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SIAlertView/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/SIAlertView/SIAlertView.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = SIAlertView; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 085A04470B2B1DFD89B69ED30150E0C0 /* Build configuration list for PBXNativeTarget "ChameleonFramework" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0B5D563BF2710D60DE742D336E8B2033 /* Debug */, + 32D9715C38DF7558D7169BD6DA3D6586 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9EB645C612834738B99727720210C23E /* Debug */, + E39CD1E764776175CB82EEC82A6C9948 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 57800A0D1724774333EF09E83030AA81 /* Build configuration list for PBXNativeTarget "AFNetworking" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C887752198ABE1F29935C2718E933EAC /* Debug */, + 94FBD736C6FE11D5D827D73D1D053D05 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 82A4C7A608BCE950E0EDB91562C64979 /* Build configuration list for PBXNativeTarget "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EA2A44D378A01FD36B885CC9BDF92F68 /* Debug */, + 81BDF4D1C815B1B241AB05259E621D63 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F50F318150C6D07FFB8D7FF0AFD126DF /* Build configuration list for PBXNativeTarget "SIAlertView" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F5AECEA9DABEC880AEAF6F3FD2EB06E6 /* Debug */, + 939844BA2F3145A178F677BD3A16C350 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F88F3E78659566AF8FF03C461B5393F4 /* Build configuration list for PBXNativeTarget "SDWebImage" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B8B7E75EEC9B1A716DCB133B30AE41EE /* Debug */, + 993F4C81BF62BA1916F3808216C7A5F9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; +} diff --git a/HeadsUpper/Pods/SDWebImage/LICENSE b/HeadsUpper/Pods/SDWebImage/LICENSE new file mode 100644 index 0000000..ae783e1 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2009 Olivier Poitrey + +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/HeadsUpper/Pods/SDWebImage/README.md b/HeadsUpper/Pods/SDWebImage/README.md new file mode 100644 index 0000000..62628f9 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/README.md @@ -0,0 +1,334 @@ +Web Image +========= +[![Build Status](http://img.shields.io/travis/rs/SDWebImage/master.svg?style=flat)](https://travis-ci.org/rs/SDWebImage) +[![Pod Version](http://img.shields.io/cocoapods/v/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) +[![Pod Platform](http://img.shields.io/cocoapods/p/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) +[![Pod License](http://img.shields.io/cocoapods/l/SDWebImage.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html) +[![Dependency Status](https://www.versioneye.com/objective-c/sdwebimage/3.3/badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage/3.3) +[![Reference Status](https://www.versioneye.com/objective-c/sdwebimage/reference_badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage/references) +[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/rs/SDWebImage) + +This library provides a category for UIImageView with support for remote images coming from the web. + +It provides: + +- An `UIImageView` category adding web image and cache management to the Cocoa Touch framework +- An asynchronous image downloader +- An asynchronous memory + disk image caching with automatic cache expiration handling +- Animated GIF support +- WebP format support +- A background image decompression +- A guarantee that the same URL won't be downloaded several times +- A guarantee that bogus URLs won't be retried again and again +- A guarantee that main thread will never be blocked +- Performances! +- Use GCD and ARC +- Arm64 support + +NOTE: The version 3.0 of SDWebImage isn't fully backward compatible with 2.0 and requires iOS 5.1.1 +minimum deployment version. If you need iOS < 5.0 support, please use the last [2.0 version](https://github.com/rs/SDWebImage/tree/2.0-compat). + +[How is SDWebImage better than X?](https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F) + +Who Use It +---------- + +Find out [who uses SDWebImage](https://github.com/rs/SDWebImage/wiki/Who-Uses-SDWebImage) and add your app to the list. + +How To Use +---------- + +API documentation is available at [CocoaDocs - SDWebImage](http://cocoadocs.org/docsets/SDWebImage/) + +### Using UIImageView+WebCache category with UITableView + +Just #import the UIImageView+WebCache.h header, and call the sd_setImageWithURL:placeholderImage: +method from the tableView:cellForRowAtIndexPath: UITableViewDataSource method. Everything will be +handled for you, from async downloads to caching management. + +```objective-c +#import + +... + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + static NSString *MyIdentifier = @"MyIdentifier"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault + reuseIdentifier:MyIdentifier] autorelease]; + } + + // Here we use the new provided sd_setImageWithURL: method to load the web image + [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] + placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; + + cell.textLabel.text = @"My Text"; + return cell; +} +``` + +### Using blocks + +With blocks, you can be notified about the image download progress and whenever the image retrieval +has completed with success or not: + +```objective-c +// Here we use the new provided sd_setImageWithURL: method to load the web image +[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] + placeholderImage:[UIImage imageNamed:@"placeholder.png"] + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + ... completion code here ... + }]; +``` + +Note: neither your success nor failure block will be call if your image request is canceled before completion. + +### Using SDWebImageManager + +The SDWebImageManager is the class behind the UIImageView+WebCache category. It ties the +asynchronous downloader with the image cache store. You can use this class directly to benefit +from web image downloading with caching in another context than a UIView (ie: with Cocoa). + +Here is a simple example of how to use SDWebImageManager: + +```objective-c +SDWebImageManager *manager = [SDWebImageManager sharedManager]; +[manager downloadImageWithURL:imageURL + options:0 + progress:^(NSInteger receivedSize, NSInteger expectedSize) { + // progression tracking code + } + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (image) { + // do something with image + } + }]; +``` + +### Using Asynchronous Image Downloader Independently + +It's also possible to use the async image downloader independently: + +```objective-c +SDWebImageDownloader *downloader = [SDWebImageDownloader sharedDownloader]; +[downloader downloadImageWithURL:imageURL + options:0 + progress:^(NSInteger receivedSize, NSInteger expectedSize) { + // progression tracking code + } + completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) { + if (image && finished) { + // do something with image + } + }]; +``` + +### Using Asynchronous Image Caching Independently + +It is also possible to use the async based image cache store independently. SDImageCache +maintains a memory cache and an optional disk cache. Disk cache write operations are performed +asynchronous so it doesn't add unnecessary latency to the UI. + +The SDImageCache class provides a singleton instance for convenience but you can create your own +instance if you want to create separated cache namespace. + +To lookup the cache, you use the `queryDiskCacheForKey:done:` method. If the method returns nil, it means the cache +doesn't currently own the image. You are thus responsible for generating and caching it. The cache +key is an application unique identifier for the image to cache. It is generally the absolute URL of +the image. + +```objective-c +SDImageCache *imageCache = [[SDImageCache alloc] initWithNamespace:@"myNamespace"]; +[imageCache queryDiskCacheForKey:myCacheKey done:^(UIImage *image) { + // image is not nil if image was found +}]; +``` + +By default SDImageCache will lookup the disk cache if an image can't be found in the memory cache. +You can prevent this from happening by calling the alternative method `imageFromMemoryCacheForKey:`. + +To store an image into the cache, you use the storeImage:forKey: method: + +```objective-c +[[SDImageCache sharedImageCache] storeImage:myImage forKey:myCacheKey]; +``` + +By default, the image will be stored in memory cache as well as on disk cache (asynchronously). If +you want only the memory cache, use the alternative method storeImage:forKey:toDisk: with a negative +third argument. + +### Using cache key filter + +Sometime, you may not want to use the image URL as cache key because part of the URL is dynamic +(i.e.: for access control purpose). SDWebImageManager provides a way to set a cache key filter that +takes the NSURL as input, and output a cache key NSString. + +The following example sets a filter in the application delegate that will remove any query-string from +the URL before to use it as a cache key: + +```objective-c +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + SDWebImageManager.sharedManager.cacheKeyFilter = ^(NSURL *url) { + url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; + return [url absoluteString]; + }; + + // Your app init code... + return YES; +} +``` + + +Common Problems +--------------- + +### Using dynamic image size with UITableViewCell + +UITableView determines the size of the image by the first image set for a cell. If your remote images +don't have the same size as your placeholder image, you may experience strange anamorphic scaling issue. +The following article gives a way to workaround this issue: + +[http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/](http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/) + + +### Handle image refresh + +SDWebImage does very aggressive caching by default. It ignores all kind of caching control header returned by the HTTP server and cache the returned images with no time restriction. It implies your images URLs are static URLs pointing to images that never change. If the pointed image happen to change, some parts of the URL should change accordingly. + +If you don't control the image server you're using, you may not be able to change the URL when its content is updated. This is the case for Facebook avatar URLs for instance. In such case, you may use the `SDWebImageRefreshCached` flag. This will slightly degrade the performance but will respect the HTTP caching control headers: + +``` objective-c +[imageView sd_setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"] + placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"] + options:SDWebImageRefreshCached]; +``` + +### Add a progress indicator + +See this category: https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage + +Installation +------------ + +There are three ways to use SDWebImage in your project: +- using Cocoapods +- copying all the files into your project +- importing the project as a static library + +### Installation with CocoaPods + +[CocoaPods](http://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the [Get Started](http://cocoapods.org/#get_started) section for more details. + +#### Podfile +``` +platform :ios, '6.1' +pod 'SDWebImage', '~>3.7' +``` + +If you are using Swift, be sure to add `use_frameworks!` and set your target to iOS 8+: +``` +platform :ios, '8.0' +use_frameworks! +``` + +#### Subspecs + +There are 3 subspecs available now: `Core`, `MapKit` and `WebP` (this means you can install only some of the SDWebImage modules. By default, you get just `Core`, so if you need `WebP`, you need to specify it). + +Podfile example: +``` +pod 'SDWebImage/WebP' +``` + +### Installation with Carthage (iOS 8+) + +[Carthage](https://github.com/Carthage/Carthage) is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods. + +To install with carthage, follow the instruction on [Carthage](https://github.com/Carthage/Carthage) + +#### Cartfile +``` +github "rs/SDWebImage" +``` + +#### Usage +Swift + +If you installed using CocoaPods: +``` +import SDWebImage +``` + +If you installed manually: +``` +import WebImage +``` + +Objective-C + +``` +@import WebImage; +``` + +### Installation by cloning the repository + +In order to gain access to all the files from the repository, you should clone it. +``` +git clone --recursive https://github.com/rs/SDWebImage.git +``` + +### Add the SDWebImage project to your project + +- Download and unzip the last version of the framework from the [download page](https://github.com/rs/SDWebImage/releases) +- Right-click on the project navigator and select "Add Files to "Your Project": +- In the dialog, select SDWebImage.framework: +- Check the "Copy items into destination group's folder (if needed)" checkbox + +### Add dependencies + +- In you application project app’s target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block: +- Click the "+" button again and select the "ImageIO.framework", this is needed by the progressive download feature: + +### Add Linker Flag + +Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag: + +![Other Linker Flags](http://dl.dropbox.com/u/123346/SDWebImage/10_other_linker_flags.jpg) + +Alternatively, if this causes compilation problems with frameworks that extend optional libraries, such as Parse, RestKit or opencv2, instead of the -ObjC flag use: +``` +-force_load SDWebImage.framework/Versions/Current/SDWebImage +``` + +If you're using Cocoa Pods and have any frameworks that extend optional libraries, such as Parsen RestKit or opencv2, instead of the -ObjC flag use: +``` +-force_load $(TARGET_BUILD_DIR)/libPods.a +``` +and this: +``` +$(inherited) +``` + +### Import headers in your source files + +In the source files where you need to use the library, import the header file: + +```objective-c +#import +``` + +### Build Project + +At this point your workspace should build without error. If you are having problem, post to the Issue and the +community can help you solve it. + +Future Enhancements +------------------- + +- LRU memory cache cleanup instead of reset on memory warning + +## Licenses + +All source code is licensed under the [MIT License](https://raw.github.com/rs/SDWebImage/master/LICENSE). diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h new file mode 100644 index 0000000..69c76dc --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h @@ -0,0 +1,26 @@ +// +// Created by Fabrice Aneche on 06/01/14. +// Copyright (c) 2014 Dailymotion. All rights reserved. +// + +#import + +@interface NSData (ImageContentType) + +/** + * Compute the content type for an image data + * + * @param data the input data + * + * @return the content type as string (i.e. image/jpeg, image/gif) + */ ++ (NSString *)sd_contentTypeForImageData:(NSData *)data; + +@end + + +@interface NSData (ImageContentTypeDeprecated) + ++ (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m new file mode 100644 index 0000000..0941cfa --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m @@ -0,0 +1,49 @@ +// +// Created by Fabrice Aneche on 06/01/14. +// Copyright (c) 2014 Dailymotion. All rights reserved. +// + +#import "NSData+ImageContentType.h" + + +@implementation NSData (ImageContentType) + ++ (NSString *)sd_contentTypeForImageData:(NSData *)data { + uint8_t c; + [data getBytes:&c length:1]; + switch (c) { + case 0xFF: + return @"image/jpeg"; + case 0x89: + return @"image/png"; + case 0x47: + return @"image/gif"; + case 0x49: + case 0x4D: + return @"image/tiff"; + case 0x52: + // R as RIFF for WEBP + if ([data length] < 12) { + return nil; + } + + NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; + if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { + return @"image/webp"; + } + + return nil; + } + return nil; +} + +@end + + +@implementation NSData (ImageContentTypeDeprecated) + ++ (NSString *)contentTypeForImageData:(NSData *)data { + return [self sd_contentTypeForImageData:data]; +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDImageCache.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDImageCache.h new file mode 100644 index 0000000..9577726 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDImageCache.h @@ -0,0 +1,272 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +typedef NS_ENUM(NSInteger, SDImageCacheType) { + /** + * The image wasn't available the SDWebImage caches, but was downloaded from the web. + */ + SDImageCacheTypeNone, + /** + * The image was obtained from the disk cache. + */ + SDImageCacheTypeDisk, + /** + * The image was obtained from the memory cache. + */ + SDImageCacheTypeMemory +}; + +typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType cacheType); + +typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache); + +typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize); + +/** + * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed + * asynchronous so it doesn’t add unnecessary latency to the UI. + */ +@interface SDImageCache : NSObject + +/** + * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. + * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. + */ +@property (assign, nonatomic) BOOL shouldDecompressImages; + +/** + * disable iCloud backup [defaults to YES] + */ +@property (assign, nonatomic) BOOL shouldDisableiCloud; + +/** + * use memory cache [defaults to YES] + */ +@property (assign, nonatomic) BOOL shouldCacheImagesInMemory; + +/** + * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory. + */ +@property (assign, nonatomic) NSUInteger maxMemoryCost; + +/** + * The maximum number of objects the cache should hold. + */ +@property (assign, nonatomic) NSUInteger maxMemoryCountLimit; + +/** + * The maximum length of time to keep an image in the cache, in seconds + */ +@property (assign, nonatomic) NSInteger maxCacheAge; + +/** + * The maximum size of the cache, in bytes. + */ +@property (assign, nonatomic) NSUInteger maxCacheSize; + +/** + * Returns global shared cache instance + * + * @return SDImageCache global instance + */ ++ (SDImageCache *)sharedImageCache; + +/** + * Init a new cache store with a specific namespace + * + * @param ns The namespace to use for this cache store + */ +- (id)initWithNamespace:(NSString *)ns; + +/** + * Init a new cache store with a specific namespace and directory + * + * @param ns The namespace to use for this cache store + * @param directory Directory to cache disk images in + */ +- (id)initWithNamespace:(NSString *)ns diskCacheDirectory:(NSString *)directory; + +-(NSString *)makeDiskCachePath:(NSString*)fullNamespace; + +/** + * Add a read-only cache path to search for images pre-cached by SDImageCache + * Useful if you want to bundle pre-loaded images with your app + * + * @param path The path to use for this read-only cache path + */ +- (void)addReadOnlyCachePath:(NSString *)path; + +/** + * Store an image into memory and disk cache at the given key. + * + * @param image The image to store + * @param key The unique image cache key, usually it's image absolute URL + */ +- (void)storeImage:(UIImage *)image forKey:(NSString *)key; + +/** + * Store an image into memory and optionally disk cache at the given key. + * + * @param image The image to store + * @param key The unique image cache key, usually it's image absolute URL + * @param toDisk Store the image to disk cache if YES + */ +- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk; + +/** + * Store an image into memory and optionally disk cache at the given key. + * + * @param image The image to store + * @param recalculate BOOL indicates if imageData can be used or a new data should be constructed from the UIImage + * @param imageData The image data as returned by the server, this representation will be used for disk storage + * instead of converting the given image object into a storable/compressed image format in order + * to save quality and CPU + * @param key The unique image cache key, usually it's image absolute URL + * @param toDisk Store the image to disk cache if YES + */ +- (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk; + +/** + * Query the disk cache asynchronously. + * + * @param key The unique key used to store the wanted image + */ +- (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock; + +/** + * Query the memory cache synchronously. + * + * @param key The unique key used to store the wanted image + */ +- (UIImage *)imageFromMemoryCacheForKey:(NSString *)key; + +/** + * Query the disk cache synchronously after checking the memory cache. + * + * @param key The unique key used to store the wanted image + */ +- (UIImage *)imageFromDiskCacheForKey:(NSString *)key; + +/** + * Remove the image from memory and disk cache synchronously + * + * @param key The unique image cache key + */ +- (void)removeImageForKey:(NSString *)key; + + +/** + * Remove the image from memory and disk cache asynchronously + * + * @param key The unique image cache key + * @param completion An block that should be executed after the image has been removed (optional) + */ +- (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion; + +/** + * Remove the image from memory and optionally disk cache asynchronously + * + * @param key The unique image cache key + * @param fromDisk Also remove cache entry from disk if YES + */ +- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk; + +/** + * Remove the image from memory and optionally disk cache asynchronously + * + * @param key The unique image cache key + * @param fromDisk Also remove cache entry from disk if YES + * @param completion An block that should be executed after the image has been removed (optional) + */ +- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion; + +/** + * Clear all memory cached images + */ +- (void)clearMemory; + +/** + * Clear all disk cached images. Non-blocking method - returns immediately. + * @param completion An block that should be executed after cache expiration completes (optional) + */ +- (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion; + +/** + * Clear all disk cached images + * @see clearDiskOnCompletion: + */ +- (void)clearDisk; + +/** + * Remove all expired cached image from disk. Non-blocking method - returns immediately. + * @param completionBlock An block that should be executed after cache expiration completes (optional) + */ +- (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock; + +/** + * Remove all expired cached image from disk + * @see cleanDiskWithCompletionBlock: + */ +- (void)cleanDisk; + +/** + * Get the size used by the disk cache + */ +- (NSUInteger)getSize; + +/** + * Get the number of images in the disk cache + */ +- (NSUInteger)getDiskCount; + +/** + * Asynchronously calculate the disk cache's size. + */ +- (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock; + +/** + * Async check if image exists in disk cache already (does not load the image) + * + * @param key the key describing the url + * @param completionBlock the block to be executed when the check is done. + * @note the completion block will be always executed on the main queue + */ +- (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; + +/** + * Check if image exists in disk cache already (does not load the image) + * + * @param key the key describing the url + * + * @return YES if an image exists for the given key + */ +- (BOOL)diskImageExistsWithKey:(NSString *)key; + +/** + * Get the cache path for a certain key (needs the cache path root folder) + * + * @param key the key (can be obtained from url using cacheKeyForURL) + * @param path the cache path root folder + * + * @return the cache path + */ +- (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path; + +/** + * Get the default cache path for a certain key + * + * @param key the key (can be obtained from url using cacheKeyForURL) + * + * @return the default cache path + */ +- (NSString *)defaultCachePathForKey:(NSString *)key; + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDImageCache.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDImageCache.m new file mode 100644 index 0000000..aa0ff6c --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDImageCache.m @@ -0,0 +1,650 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageCache.h" +#import "SDWebImageDecoder.h" +#import "UIImage+MultiFormat.h" +#import + +// See https://github.com/rs/SDWebImage/pull/1141 for discussion +@interface AutoPurgeCache : NSCache +@end + +@implementation AutoPurgeCache + +- (id)init +{ + self = [super init]; + if (self) { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAllObjects) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; + } + return self; +} + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; + +} + +@end + +static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week +// PNG signature bytes and data (below) +static unsigned char kPNGSignatureBytes[8] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; +static NSData *kPNGSignatureData = nil; + +BOOL ImageDataHasPNGPreffix(NSData *data); + +BOOL ImageDataHasPNGPreffix(NSData *data) { + NSUInteger pngSignatureLength = [kPNGSignatureData length]; + if ([data length] >= pngSignatureLength) { + if ([[data subdataWithRange:NSMakeRange(0, pngSignatureLength)] isEqualToData:kPNGSignatureData]) { + return YES; + } + } + + return NO; +} + +FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { + return image.size.height * image.size.width * image.scale * image.scale; +} + +@interface SDImageCache () + +@property (strong, nonatomic) NSCache *memCache; +@property (strong, nonatomic) NSString *diskCachePath; +@property (strong, nonatomic) NSMutableArray *customPaths; +@property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t ioQueue; + +@end + + +@implementation SDImageCache { + NSFileManager *_fileManager; +} + ++ (SDImageCache *)sharedImageCache { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} + +- (id)init { + return [self initWithNamespace:@"default"]; +} + +- (id)initWithNamespace:(NSString *)ns { + NSString *path = [self makeDiskCachePath:ns]; + return [self initWithNamespace:ns diskCacheDirectory:path]; +} + +- (id)initWithNamespace:(NSString *)ns diskCacheDirectory:(NSString *)directory { + if ((self = [super init])) { + NSString *fullNamespace = [@"com.hackemist.SDWebImageCache." stringByAppendingString:ns]; + + // initialise PNG signature data + kPNGSignatureData = [NSData dataWithBytes:kPNGSignatureBytes length:8]; + + // Create IO serial queue + _ioQueue = dispatch_queue_create("com.hackemist.SDWebImageCache", DISPATCH_QUEUE_SERIAL); + + // Init default values + _maxCacheAge = kDefaultCacheMaxCacheAge; + + // Init the memory cache + _memCache = [[AutoPurgeCache alloc] init]; + _memCache.name = fullNamespace; + + // Init the disk cache + if (directory != nil) { + _diskCachePath = [directory stringByAppendingPathComponent:fullNamespace]; + } else { + NSString *path = [self makeDiskCachePath:ns]; + _diskCachePath = path; + } + + // Set decompression to YES + _shouldDecompressImages = YES; + + // memory cache enabled + _shouldCacheImagesInMemory = YES; + + // Disable iCloud + _shouldDisableiCloud = YES; + + dispatch_sync(_ioQueue, ^{ + _fileManager = [NSFileManager new]; + }); + +#if TARGET_OS_IPHONE + // Subscribe to app events + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(clearMemory) + name:UIApplicationDidReceiveMemoryWarningNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(cleanDisk) + name:UIApplicationWillTerminateNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(backgroundCleanDisk) + name:UIApplicationDidEnterBackgroundNotification + object:nil]; +#endif + } + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + SDDispatchQueueRelease(_ioQueue); +} + +- (void)addReadOnlyCachePath:(NSString *)path { + if (!self.customPaths) { + self.customPaths = [NSMutableArray new]; + } + + if (![self.customPaths containsObject:path]) { + [self.customPaths addObject:path]; + } +} + +- (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path { + NSString *filename = [self cachedFileNameForKey:key]; + return [path stringByAppendingPathComponent:filename]; +} + +- (NSString *)defaultCachePathForKey:(NSString *)key { + return [self cachePathForKey:key inPath:self.diskCachePath]; +} + +#pragma mark SDImageCache (private) + +- (NSString *)cachedFileNameForKey:(NSString *)key { + const char *str = [key UTF8String]; + if (str == NULL) { + str = ""; + } + unsigned char r[CC_MD5_DIGEST_LENGTH]; + CC_MD5(str, (CC_LONG)strlen(str), r); + NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%@", + r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], + r[11], r[12], r[13], r[14], r[15], [[key pathExtension] isEqualToString:@""] ? @"" : [NSString stringWithFormat:@".%@", [key pathExtension]]]; + + return filename; +} + +#pragma mark ImageCache + +// Init the disk cache +-(NSString *)makeDiskCachePath:(NSString*)fullNamespace{ + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + return [paths[0] stringByAppendingPathComponent:fullNamespace]; +} + +- (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk { + if (!image || !key) { + return; + } + // if memory cache is enabled + if (self.shouldCacheImagesInMemory) { + NSUInteger cost = SDCacheCostForImage(image); + [self.memCache setObject:image forKey:key cost:cost]; + } + + if (toDisk) { + dispatch_async(self.ioQueue, ^{ + NSData *data = imageData; + + if (image && (recalculate || !data)) { +#if TARGET_OS_IPHONE + // We need to determine if the image is a PNG or a JPEG + // PNGs are easier to detect because they have a unique signature (http://www.w3.org/TR/PNG-Structure.html) + // The first eight bytes of a PNG file always contain the following (decimal) values: + // 137 80 78 71 13 10 26 10 + + // If the imageData is nil (i.e. if trying to save a UIImage directly or the image was transformed on download) + // and the image has an alpha channel, we will consider it PNG to avoid losing the transparency + int alphaInfo = CGImageGetAlphaInfo(image.CGImage); + BOOL hasAlpha = !(alphaInfo == kCGImageAlphaNone || + alphaInfo == kCGImageAlphaNoneSkipFirst || + alphaInfo == kCGImageAlphaNoneSkipLast); + BOOL imageIsPng = hasAlpha; + + // But if we have an image data, we will look at the preffix + if ([imageData length] >= [kPNGSignatureData length]) { + imageIsPng = ImageDataHasPNGPreffix(imageData); + } + + if (imageIsPng) { + data = UIImagePNGRepresentation(image); + } + else { + data = UIImageJPEGRepresentation(image, (CGFloat)1.0); + } +#else + data = [NSBitmapImageRep representationOfImageRepsInArray:image.representations usingType: NSJPEGFileType properties:nil]; +#endif + } + + if (data) { + if (![_fileManager fileExistsAtPath:_diskCachePath]) { + [_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL]; + } + + // get cache Path for image key + NSString *cachePathForKey = [self defaultCachePathForKey:key]; + // transform to NSUrl + NSURL *fileURL = [NSURL fileURLWithPath:cachePathForKey]; + + [_fileManager createFileAtPath:cachePathForKey contents:data attributes:nil]; + + // disable iCloud backup + if (self.shouldDisableiCloud) { + [fileURL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil]; + } + } + }); + } +} + +- (void)storeImage:(UIImage *)image forKey:(NSString *)key { + [self storeImage:image recalculateFromImage:YES imageData:nil forKey:key toDisk:YES]; +} + +- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk { + [self storeImage:image recalculateFromImage:YES imageData:nil forKey:key toDisk:toDisk]; +} + +- (BOOL)diskImageExistsWithKey:(NSString *)key { + BOOL exists = NO; + + // this is an exception to access the filemanager on another queue than ioQueue, but we are using the shared instance + // from apple docs on NSFileManager: The methods of the shared NSFileManager object can be called from multiple threads safely. + exists = [[NSFileManager defaultManager] fileExistsAtPath:[self defaultCachePathForKey:key]]; + + // fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name + // checking the key with and without the extension + if (!exists) { + exists = [[NSFileManager defaultManager] fileExistsAtPath:[[self defaultCachePathForKey:key] stringByDeletingPathExtension]]; + } + + return exists; +} + +- (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock { + dispatch_async(_ioQueue, ^{ + BOOL exists = [_fileManager fileExistsAtPath:[self defaultCachePathForKey:key]]; + + // fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name + // checking the key with and without the extension + if (!exists) { + exists = [_fileManager fileExistsAtPath:[[self defaultCachePathForKey:key] stringByDeletingPathExtension]]; + } + + if (completionBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + completionBlock(exists); + }); + } + }); +} + +- (UIImage *)imageFromMemoryCacheForKey:(NSString *)key { + return [self.memCache objectForKey:key]; +} + +- (UIImage *)imageFromDiskCacheForKey:(NSString *)key { + + // First check the in-memory cache... + UIImage *image = [self imageFromMemoryCacheForKey:key]; + if (image) { + return image; + } + + // Second check the disk cache... + UIImage *diskImage = [self diskImageForKey:key]; + if (diskImage && self.shouldCacheImagesInMemory) { + NSUInteger cost = SDCacheCostForImage(diskImage); + [self.memCache setObject:diskImage forKey:key cost:cost]; + } + + return diskImage; +} + +- (NSData *)diskImageDataBySearchingAllPathsForKey:(NSString *)key { + NSString *defaultPath = [self defaultCachePathForKey:key]; + NSData *data = [NSData dataWithContentsOfFile:defaultPath]; + if (data) { + return data; + } + + // fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name + // checking the key with and without the extension + data = [NSData dataWithContentsOfFile:[defaultPath stringByDeletingPathExtension]]; + if (data) { + return data; + } + + NSArray *customPaths = [self.customPaths copy]; + for (NSString *path in customPaths) { + NSString *filePath = [self cachePathForKey:key inPath:path]; + NSData *imageData = [NSData dataWithContentsOfFile:filePath]; + if (imageData) { + return imageData; + } + + // fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name + // checking the key with and without the extension + imageData = [NSData dataWithContentsOfFile:[filePath stringByDeletingPathExtension]]; + if (imageData) { + return imageData; + } + } + + return nil; +} + +- (UIImage *)diskImageForKey:(NSString *)key { + NSData *data = [self diskImageDataBySearchingAllPathsForKey:key]; + if (data) { + UIImage *image = [UIImage sd_imageWithData:data]; + image = [self scaledImageForKey:key image:image]; + if (self.shouldDecompressImages) { + image = [UIImage decodedImageWithImage:image]; + } + return image; + } + else { + return nil; + } +} + +- (UIImage *)scaledImageForKey:(NSString *)key image:(UIImage *)image { + return SDScaledImageForKey(key, image); +} + +- (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock { + if (!doneBlock) { + return nil; + } + + if (!key) { + doneBlock(nil, SDImageCacheTypeNone); + return nil; + } + + // First check the in-memory cache... + UIImage *image = [self imageFromMemoryCacheForKey:key]; + if (image) { + doneBlock(image, SDImageCacheTypeMemory); + return nil; + } + + NSOperation *operation = [NSOperation new]; + dispatch_async(self.ioQueue, ^{ + if (operation.isCancelled) { + return; + } + + @autoreleasepool { + UIImage *diskImage = [self diskImageForKey:key]; + if (diskImage && self.shouldCacheImagesInMemory) { + NSUInteger cost = SDCacheCostForImage(diskImage); + [self.memCache setObject:diskImage forKey:key cost:cost]; + } + + dispatch_async(dispatch_get_main_queue(), ^{ + doneBlock(diskImage, SDImageCacheTypeDisk); + }); + } + }); + + return operation; +} + +- (void)removeImageForKey:(NSString *)key { + [self removeImageForKey:key withCompletion:nil]; +} + +- (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion { + [self removeImageForKey:key fromDisk:YES withCompletion:completion]; +} + +- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk { + [self removeImageForKey:key fromDisk:fromDisk withCompletion:nil]; +} + +- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion { + + if (key == nil) { + return; + } + + if (self.shouldCacheImagesInMemory) { + [self.memCache removeObjectForKey:key]; + } + + if (fromDisk) { + dispatch_async(self.ioQueue, ^{ + [_fileManager removeItemAtPath:[self defaultCachePathForKey:key] error:nil]; + + if (completion) { + dispatch_async(dispatch_get_main_queue(), ^{ + completion(); + }); + } + }); + } else if (completion){ + completion(); + } + +} + +- (void)setMaxMemoryCost:(NSUInteger)maxMemoryCost { + self.memCache.totalCostLimit = maxMemoryCost; +} + +- (NSUInteger)maxMemoryCost { + return self.memCache.totalCostLimit; +} + +- (NSUInteger)maxMemoryCountLimit { + return self.memCache.countLimit; +} + +- (void)setMaxMemoryCountLimit:(NSUInteger)maxCountLimit { + self.memCache.countLimit = maxCountLimit; +} + +- (void)clearMemory { + [self.memCache removeAllObjects]; +} + +- (void)clearDisk { + [self clearDiskOnCompletion:nil]; +} + +- (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion +{ + dispatch_async(self.ioQueue, ^{ + [_fileManager removeItemAtPath:self.diskCachePath error:nil]; + [_fileManager createDirectoryAtPath:self.diskCachePath + withIntermediateDirectories:YES + attributes:nil + error:NULL]; + + if (completion) { + dispatch_async(dispatch_get_main_queue(), ^{ + completion(); + }); + } + }); +} + +- (void)cleanDisk { + [self cleanDiskWithCompletionBlock:nil]; +} + +- (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock { + dispatch_async(self.ioQueue, ^{ + NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES]; + NSArray *resourceKeys = @[NSURLIsDirectoryKey, NSURLContentModificationDateKey, NSURLTotalFileAllocatedSizeKey]; + + // This enumerator prefetches useful properties for our cache files. + NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtURL:diskCacheURL + includingPropertiesForKeys:resourceKeys + options:NSDirectoryEnumerationSkipsHiddenFiles + errorHandler:NULL]; + + NSDate *expirationDate = [NSDate dateWithTimeIntervalSinceNow:-self.maxCacheAge]; + NSMutableDictionary *cacheFiles = [NSMutableDictionary dictionary]; + NSUInteger currentCacheSize = 0; + + // Enumerate all of the files in the cache directory. This loop has two purposes: + // + // 1. Removing files that are older than the expiration date. + // 2. Storing file attributes for the size-based cleanup pass. + NSMutableArray *urlsToDelete = [[NSMutableArray alloc] init]; + for (NSURL *fileURL in fileEnumerator) { + NSDictionary *resourceValues = [fileURL resourceValuesForKeys:resourceKeys error:NULL]; + + // Skip directories. + if ([resourceValues[NSURLIsDirectoryKey] boolValue]) { + continue; + } + + // Remove files that are older than the expiration date; + NSDate *modificationDate = resourceValues[NSURLContentModificationDateKey]; + if ([[modificationDate laterDate:expirationDate] isEqualToDate:expirationDate]) { + [urlsToDelete addObject:fileURL]; + continue; + } + + // Store a reference to this file and account for its total size. + NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; + currentCacheSize += [totalAllocatedSize unsignedIntegerValue]; + [cacheFiles setObject:resourceValues forKey:fileURL]; + } + + for (NSURL *fileURL in urlsToDelete) { + [_fileManager removeItemAtURL:fileURL error:nil]; + } + + // If our remaining disk cache exceeds a configured maximum size, perform a second + // size-based cleanup pass. We delete the oldest files first. + if (self.maxCacheSize > 0 && currentCacheSize > self.maxCacheSize) { + // Target half of our maximum cache size for this cleanup pass. + const NSUInteger desiredCacheSize = self.maxCacheSize / 2; + + // Sort the remaining cache files by their last modification time (oldest first). + NSArray *sortedFiles = [cacheFiles keysSortedByValueWithOptions:NSSortConcurrent + usingComparator:^NSComparisonResult(id obj1, id obj2) { + return [obj1[NSURLContentModificationDateKey] compare:obj2[NSURLContentModificationDateKey]]; + }]; + + // Delete files until we fall below our desired cache size. + for (NSURL *fileURL in sortedFiles) { + if ([_fileManager removeItemAtURL:fileURL error:nil]) { + NSDictionary *resourceValues = cacheFiles[fileURL]; + NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; + currentCacheSize -= [totalAllocatedSize unsignedIntegerValue]; + + if (currentCacheSize < desiredCacheSize) { + break; + } + } + } + } + if (completionBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + completionBlock(); + }); + } + }); +} + +- (void)backgroundCleanDisk { + Class UIApplicationClass = NSClassFromString(@"UIApplication"); + if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { + return; + } + UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)]; + __block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{ + // Clean up any unfinished task business by marking where you + // stopped or ending the task outright. + [application endBackgroundTask:bgTask]; + bgTask = UIBackgroundTaskInvalid; + }]; + + // Start the long-running task and return immediately. + [self cleanDiskWithCompletionBlock:^{ + [application endBackgroundTask:bgTask]; + bgTask = UIBackgroundTaskInvalid; + }]; +} + +- (NSUInteger)getSize { + __block NSUInteger size = 0; + dispatch_sync(self.ioQueue, ^{ + NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath]; + for (NSString *fileName in fileEnumerator) { + NSString *filePath = [self.diskCachePath stringByAppendingPathComponent:fileName]; + NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil]; + size += [attrs fileSize]; + } + }); + return size; +} + +- (NSUInteger)getDiskCount { + __block NSUInteger count = 0; + dispatch_sync(self.ioQueue, ^{ + NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath]; + count = [[fileEnumerator allObjects] count]; + }); + return count; +} + +- (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock { + NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES]; + + dispatch_async(self.ioQueue, ^{ + NSUInteger fileCount = 0; + NSUInteger totalSize = 0; + + NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtURL:diskCacheURL + includingPropertiesForKeys:@[NSFileSize] + options:NSDirectoryEnumerationSkipsHiddenFiles + errorHandler:NULL]; + + for (NSURL *fileURL in fileEnumerator) { + NSNumber *fileSize; + [fileURL getResourceValue:&fileSize forKey:NSURLFileSizeKey error:NULL]; + totalSize += [fileSize unsignedIntegerValue]; + fileCount += 1; + } + + if (completionBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + completionBlock(fileCount, totalSize); + }); + } + }); +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h new file mode 100644 index 0000000..3c21b41 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h @@ -0,0 +1,72 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * (c) Jamie Pinkham + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import + +#ifdef __OBJC_GC__ +#error SDWebImage does not support Objective-C Garbage Collection +#endif + +#if __IPHONE_OS_VERSION_MIN_REQUIRED != 20000 && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 +#error SDWebImage doesn't support Deployment Target version < 5.0 +#endif + +#if !TARGET_OS_IPHONE +#import +#ifndef UIImage +#define UIImage NSImage +#endif +#ifndef UIImageView +#define UIImageView NSImageView +#endif +#else + +#import + +#endif + +#ifndef NS_ENUM +#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type +#endif + +#ifndef NS_OPTIONS +#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type +#endif + +#if OS_OBJECT_USE_OBJC + #undef SDDispatchQueueRelease + #undef SDDispatchQueueSetterSementics + #define SDDispatchQueueRelease(q) + #define SDDispatchQueueSetterSementics strong +#else +#undef SDDispatchQueueRelease +#undef SDDispatchQueueSetterSementics +#define SDDispatchQueueRelease(q) (dispatch_release(q)) +#define SDDispatchQueueSetterSementics assign +#endif + +extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); + +typedef void(^SDWebImageNoParamsBlock)(); + +extern NSString *const SDWebImageErrorDomain; + +#define dispatch_main_sync_safe(block)\ + if ([NSThread isMainThread]) {\ + block();\ + } else {\ + dispatch_sync(dispatch_get_main_queue(), block);\ + } + +#define dispatch_main_async_safe(block)\ + if ([NSThread isMainThread]) {\ + block();\ + } else {\ + dispatch_async(dispatch_get_main_queue(), block);\ + } diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m new file mode 100644 index 0000000..9a011bc --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m @@ -0,0 +1,51 @@ +// +// SDWebImageCompat.m +// SDWebImage +// +// Created by Olivier Poitrey on 11/12/12. +// Copyright (c) 2012 Dailymotion. All rights reserved. +// + +#import "SDWebImageCompat.h" + +#if !__has_feature(objc_arc) +#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag +#endif + +inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { + if (!image) { + return nil; + } + + if ([image.images count] > 0) { + NSMutableArray *scaledImages = [NSMutableArray array]; + + for (UIImage *tempImage in image.images) { + [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; + } + + return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; + } + else { + if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { + CGFloat scale = [UIScreen mainScreen].scale; + if (key.length >= 8) { + NSRange range = [key rangeOfString:@"@2x."]; + if (range.location != NSNotFound) { + scale = 2.0; + } + + range = [key rangeOfString:@"@3x."]; + if (range.location != NSNotFound) { + scale = 3.0; + } + } + + UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; + image = scaledImage; + } + return image; + } +} + +NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h new file mode 100644 index 0000000..0176a7b --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h @@ -0,0 +1,18 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * Created by james on 9/28/11. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +@interface UIImage (ForceDecode) + ++ (UIImage *)decodedImageWithImage:(UIImage *)image; + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m new file mode 100644 index 0000000..a7c0246 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m @@ -0,0 +1,69 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * Created by james on 9/28/11. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageDecoder.h" + +@implementation UIImage (ForceDecode) + ++ (UIImage *)decodedImageWithImage:(UIImage *)image { + // while downloading huge amount of images + // autorelease the bitmap context + // and all vars to help system to free memory + // when there are memory warning. + // on iOS7, do not forget to call + // [[SDImageCache sharedImageCache] clearMemory]; + @autoreleasepool{ + // do not decode animated images + if (image.images) { return image; } + + CGImageRef imageRef = image.CGImage; + + CGImageAlphaInfo alpha = CGImageGetAlphaInfo(imageRef); + BOOL anyAlpha = (alpha == kCGImageAlphaFirst || + alpha == kCGImageAlphaLast || + alpha == kCGImageAlphaPremultipliedFirst || + alpha == kCGImageAlphaPremultipliedLast); + + if (anyAlpha) { return image; } + + size_t width = CGImageGetWidth(imageRef); + size_t height = CGImageGetHeight(imageRef); + + // current + CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(CGImageGetColorSpace(imageRef)); + CGColorSpaceRef colorspaceRef = CGImageGetColorSpace(imageRef); + + bool unsupportedColorSpace = (imageColorSpaceModel == 0 || imageColorSpaceModel == -1 || imageColorSpaceModel == kCGColorSpaceModelCMYK || imageColorSpaceModel == kCGColorSpaceModelIndexed); + if (unsupportedColorSpace) + colorspaceRef = CGColorSpaceCreateDeviceRGB(); + + CGContextRef context = CGBitmapContextCreate(NULL, width, + height, + CGImageGetBitsPerComponent(imageRef), + 0, + colorspaceRef, + kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); + + // Draw the image into the context and retrieve the new image, which will now have an alpha layer + CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); + CGImageRef imageRefWithAlpha = CGBitmapContextCreateImage(context); + UIImage *imageWithAlpha = [UIImage imageWithCGImage:imageRefWithAlpha scale:image.scale orientation:image.imageOrientation]; + + if (unsupportedColorSpace) + CGColorSpaceRelease(colorspaceRef); + + CGContextRelease(context); + CGImageRelease(imageRefWithAlpha); + + return imageWithAlpha; + } +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h new file mode 100644 index 0000000..b64fb13 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h @@ -0,0 +1,191 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" +#import "SDWebImageOperation.h" + +typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { + SDWebImageDownloaderLowPriority = 1 << 0, + SDWebImageDownloaderProgressiveDownload = 1 << 1, + + /** + * By default, request prevent the of NSURLCache. With this flag, NSURLCache + * is used with default policies. + */ + SDWebImageDownloaderUseNSURLCache = 1 << 2, + + /** + * Call completion block with nil image/imageData if the image was read from NSURLCache + * (to be combined with `SDWebImageDownloaderUseNSURLCache`). + */ + + SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, + /** + * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for + * extra time in background to let the request finish. If the background task expires the operation will be cancelled. + */ + + SDWebImageDownloaderContinueInBackground = 1 << 4, + + /** + * Handles cookies stored in NSHTTPCookieStore by setting + * NSMutableURLRequest.HTTPShouldHandleCookies = YES; + */ + SDWebImageDownloaderHandleCookies = 1 << 5, + + /** + * Enable to allow untrusted SSL certificates. + * Useful for testing purposes. Use with caution in production. + */ + SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6, + + /** + * Put the image in the high priority queue. + */ + SDWebImageDownloaderHighPriority = 1 << 7, +}; + +typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { + /** + * Default value. All download operations will execute in queue style (first-in-first-out). + */ + SDWebImageDownloaderFIFOExecutionOrder, + + /** + * All download operations will execute in stack style (last-in-first-out). + */ + SDWebImageDownloaderLIFOExecutionOrder +}; + +extern NSString *const SDWebImageDownloadStartNotification; +extern NSString *const SDWebImageDownloadStopNotification; + +typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); + +typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); + +typedef NSDictionary *(^SDWebImageDownloaderHeadersFilterBlock)(NSURL *url, NSDictionary *headers); + +/** + * Asynchronous downloader dedicated and optimized for image loading. + */ +@interface SDWebImageDownloader : NSObject + +/** + * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. + * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. + */ +@property (assign, nonatomic) BOOL shouldDecompressImages; + +@property (assign, nonatomic) NSInteger maxConcurrentDownloads; + +/** + * Shows the current amount of downloads that still need to be downloaded + */ +@property (readonly, nonatomic) NSUInteger currentDownloadCount; + + +/** + * The timeout value (in seconds) for the download operation. Default: 15.0. + */ +@property (assign, nonatomic) NSTimeInterval downloadTimeout; + + +/** + * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. + */ +@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; + +/** + * Singleton method, returns the shared instance + * + * @return global shared instance of downloader class + */ ++ (SDWebImageDownloader *)sharedDownloader; + +/** + * Set the default URL credential to be set for request operations. + */ +@property (strong, nonatomic) NSURLCredential *urlCredential; + +/** + * Set username + */ +@property (strong, nonatomic) NSString *username; + +/** + * Set password + */ +@property (strong, nonatomic) NSString *password; + +/** + * Set filter to pick headers for downloading image HTTP request. + * + * This block will be invoked for each downloading image request, returned + * NSDictionary will be used as headers in corresponding HTTP request. + */ +@property (nonatomic, copy) SDWebImageDownloaderHeadersFilterBlock headersFilter; + +/** + * Set a value for a HTTP header to be appended to each download HTTP request. + * + * @param value The value for the header field. Use `nil` value to remove the header. + * @param field The name of the header field to set. + */ +- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field; + +/** + * Returns the value of the specified HTTP header field. + * + * @return The value associated with the header field field, or `nil` if there is no corresponding header field. + */ +- (NSString *)valueForHTTPHeaderField:(NSString *)field; + +/** + * Sets a subclass of `SDWebImageDownloaderOperation` as the default + * `NSOperation` to be used each time SDWebImage constructs a request + * operation to download an image. + * + * @param operationClass The subclass of `SDWebImageDownloaderOperation` to set + * as default. Passing `nil` will revert to `SDWebImageDownloaderOperation`. + */ +- (void)setOperationClass:(Class)operationClass; + +/** + * Creates a SDWebImageDownloader async downloader instance with a given URL + * + * The delegate will be informed when the image is finish downloaded or an error has happen. + * + * @see SDWebImageDownloaderDelegate + * + * @param url The URL to the image to download + * @param options The options to be used for this download + * @param progressBlock A block called repeatedly while the image is downloading + * @param completedBlock A block called once the download is completed. + * If the download succeeded, the image parameter is set, in case of error, + * error parameter is set with the error. The last parameter is always YES + * if SDWebImageDownloaderProgressiveDownload isn't use. With the + * SDWebImageDownloaderProgressiveDownload option, this block is called + * repeatedly with the partial image object and the finished argument set to NO + * before to be called a last time with the full image and finished argument + * set to YES. In case of error, the finished argument is always YES. + * + * @return A cancellable SDWebImageOperation + */ +- (id )downloadImageWithURL:(NSURL *)url + options:(SDWebImageDownloaderOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageDownloaderCompletedBlock)completedBlock; + +/** + * Sets the download queue suspension state + */ +- (void)setSuspended:(BOOL)suspended; + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m new file mode 100644 index 0000000..1fdcfc9 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m @@ -0,0 +1,232 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageDownloader.h" +#import "SDWebImageDownloaderOperation.h" +#import + +static NSString *const kProgressCallbackKey = @"progress"; +static NSString *const kCompletedCallbackKey = @"completed"; + +@interface SDWebImageDownloader () + +@property (strong, nonatomic) NSOperationQueue *downloadQueue; +@property (weak, nonatomic) NSOperation *lastAddedOperation; +@property (assign, nonatomic) Class operationClass; +@property (strong, nonatomic) NSMutableDictionary *URLCallbacks; +@property (strong, nonatomic) NSMutableDictionary *HTTPHeaders; +// This queue is used to serialize the handling of the network responses of all the download operation in a single queue +@property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t barrierQueue; + +@end + +@implementation SDWebImageDownloader + ++ (void)initialize { + // Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator ) + // To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import + if (NSClassFromString(@"SDNetworkActivityIndicator")) { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")]; +#pragma clang diagnostic pop + + // Remove observer in case it was previously added. + [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:activityIndicator + selector:NSSelectorFromString(@"startActivity") + name:SDWebImageDownloadStartNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:activityIndicator + selector:NSSelectorFromString(@"stopActivity") + name:SDWebImageDownloadStopNotification object:nil]; + } +} + ++ (SDWebImageDownloader *)sharedDownloader { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} + +- (id)init { + if ((self = [super init])) { + _operationClass = [SDWebImageDownloaderOperation class]; + _shouldDecompressImages = YES; + _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; + _downloadQueue = [NSOperationQueue new]; + _downloadQueue.maxConcurrentOperationCount = 6; + _URLCallbacks = [NSMutableDictionary new]; +#ifdef SD_WEBP + _HTTPHeaders = [@{@"Accept": @"image/webp,image/*;q=0.8"} mutableCopy]; +#else + _HTTPHeaders = [@{@"Accept": @"image/*;q=0.8"} mutableCopy]; +#endif + _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT); + _downloadTimeout = 15.0; + } + return self; +} + +- (void)dealloc { + [self.downloadQueue cancelAllOperations]; + SDDispatchQueueRelease(_barrierQueue); +} + +- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field { + if (value) { + self.HTTPHeaders[field] = value; + } + else { + [self.HTTPHeaders removeObjectForKey:field]; + } +} + +- (NSString *)valueForHTTPHeaderField:(NSString *)field { + return self.HTTPHeaders[field]; +} + +- (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads { + _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads; +} + +- (NSUInteger)currentDownloadCount { + return _downloadQueue.operationCount; +} + +- (NSInteger)maxConcurrentDownloads { + return _downloadQueue.maxConcurrentOperationCount; +} + +- (void)setOperationClass:(Class)operationClass { + _operationClass = operationClass ?: [SDWebImageDownloaderOperation class]; +} + +- (id )downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock { + __block SDWebImageDownloaderOperation *operation; + __weak __typeof(self)wself = self; + + [self addProgressCallback:progressBlock completedBlock:completedBlock forURL:url createCallback:^{ + NSTimeInterval timeoutInterval = wself.downloadTimeout; + if (timeoutInterval == 0.0) { + timeoutInterval = 15.0; + } + + // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval]; + request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies); + request.HTTPShouldUsePipelining = YES; + if (wself.headersFilter) { + request.allHTTPHeaderFields = wself.headersFilter(url, [wself.HTTPHeaders copy]); + } + else { + request.allHTTPHeaderFields = wself.HTTPHeaders; + } + operation = [[wself.operationClass alloc] initWithRequest:request + options:options + progress:^(NSInteger receivedSize, NSInteger expectedSize) { + SDWebImageDownloader *sself = wself; + if (!sself) return; + __block NSArray *callbacksForURL; + dispatch_sync(sself.barrierQueue, ^{ + callbacksForURL = [sself.URLCallbacks[url] copy]; + }); + for (NSDictionary *callbacks in callbacksForURL) { + dispatch_async(dispatch_get_main_queue(), ^{ + SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey]; + if (callback) callback(receivedSize, expectedSize); + }); + } + } + completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) { + SDWebImageDownloader *sself = wself; + if (!sself) return; + __block NSArray *callbacksForURL; + dispatch_barrier_sync(sself.barrierQueue, ^{ + callbacksForURL = [sself.URLCallbacks[url] copy]; + if (finished) { + [sself.URLCallbacks removeObjectForKey:url]; + } + }); + for (NSDictionary *callbacks in callbacksForURL) { + SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey]; + if (callback) callback(image, data, error, finished); + } + } + cancelled:^{ + SDWebImageDownloader *sself = wself; + if (!sself) return; + dispatch_barrier_async(sself.barrierQueue, ^{ + [sself.URLCallbacks removeObjectForKey:url]; + }); + }]; + operation.shouldDecompressImages = wself.shouldDecompressImages; + + if (wself.urlCredential) { + operation.credential = wself.urlCredential; + } else if (wself.username && wself.password) { + operation.credential = [NSURLCredential credentialWithUser:wself.username password:wself.password persistence:NSURLCredentialPersistenceForSession]; + } + + if (options & SDWebImageDownloaderHighPriority) { + operation.queuePriority = NSOperationQueuePriorityHigh; + } else if (options & SDWebImageDownloaderLowPriority) { + operation.queuePriority = NSOperationQueuePriorityLow; + } + + [wself.downloadQueue addOperation:operation]; + if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) { + // Emulate LIFO execution order by systematically adding new operations as last operation's dependency + [wself.lastAddedOperation addDependency:operation]; + wself.lastAddedOperation = operation; + } + }]; + + return operation; +} + +- (void)addProgressCallback:(SDWebImageDownloaderProgressBlock)progressBlock completedBlock:(SDWebImageDownloaderCompletedBlock)completedBlock forURL:(NSURL *)url createCallback:(SDWebImageNoParamsBlock)createCallback { + // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data. + if (url == nil) { + if (completedBlock != nil) { + completedBlock(nil, nil, nil, NO); + } + return; + } + + dispatch_barrier_sync(self.barrierQueue, ^{ + BOOL first = NO; + if (!self.URLCallbacks[url]) { + self.URLCallbacks[url] = [NSMutableArray new]; + first = YES; + } + + // Handle single download of simultaneous download request for the same URL + NSMutableArray *callbacksForURL = self.URLCallbacks[url]; + NSMutableDictionary *callbacks = [NSMutableDictionary new]; + if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy]; + if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy]; + [callbacksForURL addObject:callbacks]; + self.URLCallbacks[url] = callbacksForURL; + + if (first) { + createCallback(); + } + }); +} + +- (void)setSuspended:(BOOL)suspended { + [self.downloadQueue setSuspended:suspended]; +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h new file mode 100644 index 0000000..dd48b22 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h @@ -0,0 +1,78 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageDownloader.h" +#import "SDWebImageOperation.h" + +extern NSString *const SDWebImageDownloadStartNotification; +extern NSString *const SDWebImageDownloadReceiveResponseNotification; +extern NSString *const SDWebImageDownloadStopNotification; +extern NSString *const SDWebImageDownloadFinishNotification; + +@interface SDWebImageDownloaderOperation : NSOperation + +/** + * The request used by the operation's connection. + */ +@property (strong, nonatomic, readonly) NSURLRequest *request; + + +@property (assign, nonatomic) BOOL shouldDecompressImages; + +/** + * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. + * + * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. + * + * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. + */ +@property (nonatomic, strong) NSURLCredential *credential; + +/** + * The SDWebImageDownloaderOptions for the receiver. + */ +@property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; + +/** + * The expected size of data. + */ +@property (assign, nonatomic) NSInteger expectedSize; + +/** + * The response returned by the operation's connection. + */ +@property (strong, nonatomic) NSURLResponse *response; + +/** + * Initializes a `SDWebImageDownloaderOperation` object + * + * @see SDWebImageDownloaderOperation + * + * @param request the URL request + * @param options downloader options + * @param progressBlock the block executed when a new chunk of data arrives. + * @note the progress block is executed on a background queue + * @param completedBlock the block executed when the download is done. + * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue + * @param cancelBlock the block executed if the download (operation) is cancelled + * + * @return the initialized instance + */ +- (id)initWithRequest:(NSURLRequest *)request + options:(SDWebImageDownloaderOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageDownloaderCompletedBlock)completedBlock + cancelled:(SDWebImageNoParamsBlock)cancelBlock; + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m new file mode 100644 index 0000000..5a8bd11 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m @@ -0,0 +1,466 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageDownloaderOperation.h" +#import "SDWebImageDecoder.h" +#import "UIImage+MultiFormat.h" +#import +#import "SDWebImageManager.h" + +NSString *const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification"; +NSString *const SDWebImageDownloadReceiveResponseNotification = @"SDWebImageDownloadReceiveResponseNotification"; +NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification"; +NSString *const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinishNotification"; + +@interface SDWebImageDownloaderOperation () + +@property (copy, nonatomic) SDWebImageDownloaderProgressBlock progressBlock; +@property (copy, nonatomic) SDWebImageDownloaderCompletedBlock completedBlock; +@property (copy, nonatomic) SDWebImageNoParamsBlock cancelBlock; + +@property (assign, nonatomic, getter = isExecuting) BOOL executing; +@property (assign, nonatomic, getter = isFinished) BOOL finished; +@property (strong, nonatomic) NSMutableData *imageData; +@property (strong, nonatomic) NSURLConnection *connection; +@property (strong, atomic) NSThread *thread; + +#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 +@property (assign, nonatomic) UIBackgroundTaskIdentifier backgroundTaskId; +#endif + +@end + +@implementation SDWebImageDownloaderOperation { + size_t width, height; + UIImageOrientation orientation; + BOOL responseFromCached; +} + +@synthesize executing = _executing; +@synthesize finished = _finished; + +- (id)initWithRequest:(NSURLRequest *)request + options:(SDWebImageDownloaderOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageDownloaderCompletedBlock)completedBlock + cancelled:(SDWebImageNoParamsBlock)cancelBlock { + if ((self = [super init])) { + _request = request; + _shouldDecompressImages = YES; + _shouldUseCredentialStorage = YES; + _options = options; + _progressBlock = [progressBlock copy]; + _completedBlock = [completedBlock copy]; + _cancelBlock = [cancelBlock copy]; + _executing = NO; + _finished = NO; + _expectedSize = 0; + responseFromCached = YES; // Initially wrong until `connection:willCacheResponse:` is called or not called + } + return self; +} + +- (void)start { + @synchronized (self) { + if (self.isCancelled) { + self.finished = YES; + [self reset]; + return; + } + +#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 + Class UIApplicationClass = NSClassFromString(@"UIApplication"); + BOOL hasApplication = UIApplicationClass && [UIApplicationClass respondsToSelector:@selector(sharedApplication)]; + if (hasApplication && [self shouldContinueWhenAppEntersBackground]) { + __weak __typeof__ (self) wself = self; + UIApplication * app = [UIApplicationClass performSelector:@selector(sharedApplication)]; + self.backgroundTaskId = [app beginBackgroundTaskWithExpirationHandler:^{ + __strong __typeof (wself) sself = wself; + + if (sself) { + [sself cancel]; + + [app endBackgroundTask:sself.backgroundTaskId]; + sself.backgroundTaskId = UIBackgroundTaskInvalid; + } + }]; + } +#endif + + self.executing = YES; + self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; + self.thread = [NSThread currentThread]; + } + + [self.connection start]; + + if (self.connection) { + if (self.progressBlock) { + self.progressBlock(0, NSURLResponseUnknownLength); + } + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; + }); + + if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_5_1) { + // Make sure to run the runloop in our background thread so it can process downloaded data + // Note: we use a timeout to work around an issue with NSURLConnection cancel under iOS 5 + // not waking up the runloop, leading to dead threads (see https://github.com/rs/SDWebImage/issues/466) + CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, false); + } + else { + CFRunLoopRun(); + } + + if (!self.isFinished) { + [self.connection cancel]; + [self connection:self.connection didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorTimedOut userInfo:@{NSURLErrorFailingURLErrorKey : self.request.URL}]]; + } + } + else { + if (self.completedBlock) { + self.completedBlock(nil, nil, [NSError errorWithDomain:NSURLErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Connection can't be initialized"}], YES); + } + } + +#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 + Class UIApplicationClass = NSClassFromString(@"UIApplication"); + if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { + return; + } + if (self.backgroundTaskId != UIBackgroundTaskInvalid) { + UIApplication * app = [UIApplication performSelector:@selector(sharedApplication)]; + [app endBackgroundTask:self.backgroundTaskId]; + self.backgroundTaskId = UIBackgroundTaskInvalid; + } +#endif +} + +- (void)cancel { + @synchronized (self) { + if (self.thread) { + [self performSelector:@selector(cancelInternalAndStop) onThread:self.thread withObject:nil waitUntilDone:NO]; + } + else { + [self cancelInternal]; + } + } +} + +- (void)cancelInternalAndStop { + if (self.isFinished) return; + [self cancelInternal]; + CFRunLoopStop(CFRunLoopGetCurrent()); +} + +- (void)cancelInternal { + if (self.isFinished) return; + [super cancel]; + if (self.cancelBlock) self.cancelBlock(); + + if (self.connection) { + [self.connection cancel]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + }); + + // As we cancelled the connection, its callback won't be called and thus won't + // maintain the isFinished and isExecuting flags. + if (self.isExecuting) self.executing = NO; + if (!self.isFinished) self.finished = YES; + } + + [self reset]; +} + +- (void)done { + self.finished = YES; + self.executing = NO; + [self reset]; +} + +- (void)reset { + self.cancelBlock = nil; + self.completedBlock = nil; + self.progressBlock = nil; + self.connection = nil; + self.imageData = nil; + self.thread = nil; +} + +- (void)setFinished:(BOOL)finished { + [self willChangeValueForKey:@"isFinished"]; + _finished = finished; + [self didChangeValueForKey:@"isFinished"]; +} + +- (void)setExecuting:(BOOL)executing { + [self willChangeValueForKey:@"isExecuting"]; + _executing = executing; + [self didChangeValueForKey:@"isExecuting"]; +} + +- (BOOL)isConcurrent { + return YES; +} + +#pragma mark NSURLConnection (delegate) + +- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { + + //'304 Not Modified' is an exceptional one + if (![response respondsToSelector:@selector(statusCode)] || ([((NSHTTPURLResponse *)response) statusCode] < 400 && [((NSHTTPURLResponse *)response) statusCode] != 304)) { + NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0; + self.expectedSize = expected; + if (self.progressBlock) { + self.progressBlock(0, expected); + } + + self.imageData = [[NSMutableData alloc] initWithCapacity:expected]; + self.response = response; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadReceiveResponseNotification object:self]; + }); + } + else { + NSUInteger code = [((NSHTTPURLResponse *)response) statusCode]; + + //This is the case when server returns '304 Not Modified'. It means that remote image is not changed. + //In case of 304 we need just cancel the operation and return cached image from the cache. + if (code == 304) { + [self cancelInternal]; + } else { + [self.connection cancel]; + } + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + }); + + if (self.completedBlock) { + self.completedBlock(nil, nil, [NSError errorWithDomain:NSURLErrorDomain code:[((NSHTTPURLResponse *)response) statusCode] userInfo:nil], YES); + } + CFRunLoopStop(CFRunLoopGetCurrent()); + [self done]; + } +} + +- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { + [self.imageData appendData:data]; + + if ((self.options & SDWebImageDownloaderProgressiveDownload) && self.expectedSize > 0 && self.completedBlock) { + // The following code is from http://www.cocoaintheshell.com/2011/05/progressive-images-download-imageio/ + // Thanks to the author @Nyx0uf + + // Get the total bytes downloaded + const NSInteger totalSize = self.imageData.length; + + // Update the data source, we must pass ALL the data, not just the new bytes + CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)self.imageData, NULL); + + if (width + height == 0) { + CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); + if (properties) { + NSInteger orientationValue = -1; + CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight); + if (val) CFNumberGetValue(val, kCFNumberLongType, &height); + val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth); + if (val) CFNumberGetValue(val, kCFNumberLongType, &width); + val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); + if (val) CFNumberGetValue(val, kCFNumberNSIntegerType, &orientationValue); + CFRelease(properties); + + // When we draw to Core Graphics, we lose orientation information, + // which means the image below born of initWithCGIImage will be + // oriented incorrectly sometimes. (Unlike the image born of initWithData + // in connectionDidFinishLoading.) So save it here and pass it on later. + orientation = [[self class] orientationFromPropertyValue:(orientationValue == -1 ? 1 : orientationValue)]; + } + + } + + if (width + height > 0 && totalSize < self.expectedSize) { + // Create the image + CGImageRef partialImageRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL); + +#ifdef TARGET_OS_IPHONE + // Workaround for iOS anamorphic image + if (partialImageRef) { + const size_t partialHeight = CGImageGetHeight(partialImageRef); + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGContextRef bmContext = CGBitmapContextCreate(NULL, width, height, 8, width * 4, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); + CGColorSpaceRelease(colorSpace); + if (bmContext) { + CGContextDrawImage(bmContext, (CGRect){.origin.x = 0.0f, .origin.y = 0.0f, .size.width = width, .size.height = partialHeight}, partialImageRef); + CGImageRelease(partialImageRef); + partialImageRef = CGBitmapContextCreateImage(bmContext); + CGContextRelease(bmContext); + } + else { + CGImageRelease(partialImageRef); + partialImageRef = nil; + } + } +#endif + + if (partialImageRef) { + UIImage *image = [UIImage imageWithCGImage:partialImageRef scale:1 orientation:orientation]; + NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL]; + UIImage *scaledImage = [self scaledImageForKey:key image:image]; + if (self.shouldDecompressImages) { + image = [UIImage decodedImageWithImage:scaledImage]; + } + else { + image = scaledImage; + } + CGImageRelease(partialImageRef); + dispatch_main_sync_safe(^{ + if (self.completedBlock) { + self.completedBlock(image, nil, nil, NO); + } + }); + } + } + + CFRelease(imageSource); + } + + if (self.progressBlock) { + self.progressBlock(self.imageData.length, self.expectedSize); + } +} + ++ (UIImageOrientation)orientationFromPropertyValue:(NSInteger)value { + switch (value) { + case 1: + return UIImageOrientationUp; + case 3: + return UIImageOrientationDown; + case 8: + return UIImageOrientationLeft; + case 6: + return UIImageOrientationRight; + case 2: + return UIImageOrientationUpMirrored; + case 4: + return UIImageOrientationDownMirrored; + case 5: + return UIImageOrientationLeftMirrored; + case 7: + return UIImageOrientationRightMirrored; + default: + return UIImageOrientationUp; + } +} + +- (UIImage *)scaledImageForKey:(NSString *)key image:(UIImage *)image { + return SDScaledImageForKey(key, image); +} + +- (void)connectionDidFinishLoading:(NSURLConnection *)aConnection { + SDWebImageDownloaderCompletedBlock completionBlock = self.completedBlock; + @synchronized(self) { + CFRunLoopStop(CFRunLoopGetCurrent()); + self.thread = nil; + self.connection = nil; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadFinishNotification object:self]; + }); + } + + if (![[NSURLCache sharedURLCache] cachedResponseForRequest:_request]) { + responseFromCached = NO; + } + + if (completionBlock) { + if (self.options & SDWebImageDownloaderIgnoreCachedResponse && responseFromCached) { + completionBlock(nil, nil, nil, YES); + } else if (self.imageData) { + UIImage *image = [UIImage sd_imageWithData:self.imageData]; + NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL]; + image = [self scaledImageForKey:key image:image]; + + // Do not force decoding animated GIFs + if (!image.images) { + if (self.shouldDecompressImages) { + image = [UIImage decodedImageWithImage:image]; + } + } + if (CGSizeEqualToSize(image.size, CGSizeZero)) { + completionBlock(nil, nil, [NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Downloaded image has 0 pixels"}], YES); + } + else { + completionBlock(image, self.imageData, nil, YES); + } + } else { + completionBlock(nil, nil, [NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Image data is nil"}], YES); + } + } + self.completionBlock = nil; + [self done]; +} + +- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { + @synchronized(self) { + CFRunLoopStop(CFRunLoopGetCurrent()); + self.thread = nil; + self.connection = nil; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + }); + } + + if (self.completedBlock) { + self.completedBlock(nil, nil, error, YES); + } + self.completionBlock = nil; + [self done]; +} + +- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse { + responseFromCached = NO; // If this method is called, it means the response wasn't read from cache + if (self.request.cachePolicy == NSURLRequestReloadIgnoringLocalCacheData) { + // Prevents caching of responses + return nil; + } + else { + return cachedResponse; + } +} + +- (BOOL)shouldContinueWhenAppEntersBackground { + return self.options & SDWebImageDownloaderContinueInBackground; +} + +- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { + return self.shouldUseCredentialStorage; +} + +- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{ + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if (!(self.options & SDWebImageDownloaderAllowInvalidSSLCertificates) && + [challenge.sender respondsToSelector:@selector(performDefaultHandlingForAuthenticationChallenge:)]) { + [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge]; + } else { + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } + } else { + if ([challenge previousFailureCount] == 0) { + if (self.credential) { + [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageManager.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageManager.h new file mode 100644 index 0000000..18e578a --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageManager.h @@ -0,0 +1,299 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "SDWebImageOperation.h" +#import "SDWebImageDownloader.h" +#import "SDImageCache.h" + +typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { + /** + * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. + * This flag disable this blacklisting. + */ + SDWebImageRetryFailed = 1 << 0, + + /** + * By default, image downloads are started during UI interactions, this flags disable this feature, + * leading to delayed download on UIScrollView deceleration for instance. + */ + SDWebImageLowPriority = 1 << 1, + + /** + * This flag disables on-disk caching + */ + SDWebImageCacheMemoryOnly = 1 << 2, + + /** + * This flag enables progressive download, the image is displayed progressively during download as a browser would do. + * By default, the image is only displayed once completely downloaded. + */ + SDWebImageProgressiveDownload = 1 << 3, + + /** + * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. + * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. + * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. + * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. + * + * Use this flag only if you can't make your URLs static with embedded cache busting parameter. + */ + SDWebImageRefreshCached = 1 << 4, + + /** + * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for + * extra time in background to let the request finish. If the background task expires the operation will be cancelled. + */ + SDWebImageContinueInBackground = 1 << 5, + + /** + * Handles cookies stored in NSHTTPCookieStore by setting + * NSMutableURLRequest.HTTPShouldHandleCookies = YES; + */ + SDWebImageHandleCookies = 1 << 6, + + /** + * Enable to allow untrusted SSL certificates. + * Useful for testing purposes. Use with caution in production. + */ + SDWebImageAllowInvalidSSLCertificates = 1 << 7, + + /** + * By default, image are loaded in the order they were queued. This flag move them to + * the front of the queue and is loaded immediately instead of waiting for the current queue to be loaded (which + * could take a while). + */ + SDWebImageHighPriority = 1 << 8, + + /** + * By default, placeholder images are loaded while the image is loading. This flag will delay the loading + * of the placeholder image until after the image has finished loading. + */ + SDWebImageDelayPlaceholder = 1 << 9, + + /** + * We usually don't call transformDownloadedImage delegate method on animated images, + * as most transformation code would mangle it. + * Use this flag to transform them anyway. + */ + SDWebImageTransformAnimatedImage = 1 << 10, + + /** + * By default, image is added to the imageView after download. But in some cases, we want to + * have the hand before setting the image (apply a filter or add it with cross-fade animation for instance) + * Use this flag if you want to manually set the image in the completion when success + */ + SDWebImageAvoidAutoSetImage = 1 << 11 +}; + +typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL); + +typedef void(^SDWebImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL); + +typedef NSString *(^SDWebImageCacheKeyFilterBlock)(NSURL *url); + + +@class SDWebImageManager; + +@protocol SDWebImageManagerDelegate + +@optional + +/** + * Controls which image should be downloaded when the image is not found in the cache. + * + * @param imageManager The current `SDWebImageManager` + * @param imageURL The url of the image to be downloaded + * + * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied. + */ +- (BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL; + +/** + * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory. + * NOTE: This method is called from a global queue in order to not to block the main thread. + * + * @param imageManager The current `SDWebImageManager` + * @param image The image to transform + * @param imageURL The url of the image to transform + * + * @return The transformed image object. + */ +- (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL; + +@end + +/** + * The SDWebImageManager is the class behind the UIImageView+WebCache category and likes. + * It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache). + * You can use this class directly to benefit from web image downloading with caching in another context than + * a UIView. + * + * Here is a simple example of how to use SDWebImageManager: + * + * @code + +SDWebImageManager *manager = [SDWebImageManager sharedManager]; +[manager downloadImageWithURL:imageURL + options:0 + progress:nil + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (image) { + // do something with image + } + }]; + + * @endcode + */ +@interface SDWebImageManager : NSObject + +@property (weak, nonatomic) id delegate; + +@property (strong, nonatomic, readonly) SDImageCache *imageCache; +@property (strong, nonatomic, readonly) SDWebImageDownloader *imageDownloader; + +/** + * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can + * be used to remove dynamic part of an image URL. + * + * The following example sets a filter in the application delegate that will remove any query-string from the + * URL before to use it as a cache key: + * + * @code + +[[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) { + url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; + return [url absoluteString]; +}]; + + * @endcode + */ +@property (nonatomic, copy) SDWebImageCacheKeyFilterBlock cacheKeyFilter; + +/** + * Returns global SDWebImageManager instance. + * + * @return SDWebImageManager shared instance + */ ++ (SDWebImageManager *)sharedManager; + +/** + * Downloads the image at the given URL if not present in cache or return the cached version otherwise. + * + * @param url The URL to the image + * @param options A mask to specify options to use for this request + * @param progressBlock A block called while image is downloading + * @param completedBlock A block called when operation has been completed. + * + * This parameter is required. + * + * This block has no return value and takes the requested UIImage as first parameter. + * In case of error the image parameter is nil and the second parameter may contain an NSError. + * + * The third parameter is an `SDImageCacheType` enum indicating if the image was retrieved from the local cache + * or from the memory cache or from the network. + * + * The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is + * downloading. This block is thus called repeatedly with a partial image. When image is fully downloaded, the + * block is called a last time with the full image and the last parameter set to YES. + * + * @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation + */ +- (id )downloadImageWithURL:(NSURL *)url + options:(SDWebImageOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageCompletionWithFinishedBlock)completedBlock; + +/** + * Saves image to cache for given URL + * + * @param image The image to cache + * @param url The URL to the image + * + */ + +- (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url; + +/** + * Cancel all current operations + */ +- (void)cancelAll; + +/** + * Check one or more operations running + */ +- (BOOL)isRunning; + +/** + * Check if image has already been cached + * + * @param url image url + * + * @return if the image was already cached + */ +- (BOOL)cachedImageExistsForURL:(NSURL *)url; + +/** + * Check if image has already been cached on disk only + * + * @param url image url + * + * @return if the image was already cached (disk only) + */ +- (BOOL)diskImageExistsForURL:(NSURL *)url; + +/** + * Async check if image has already been cached + * + * @param url image url + * @param completionBlock the block to be executed when the check is finished + * + * @note the completion block is always executed on the main queue + */ +- (void)cachedImageExistsForURL:(NSURL *)url + completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; + +/** + * Async check if image has already been cached on disk only + * + * @param url image url + * @param completionBlock the block to be executed when the check is finished + * + * @note the completion block is always executed on the main queue + */ +- (void)diskImageExistsForURL:(NSURL *)url + completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; + + +/** + *Return the cache key for a given URL + */ +- (NSString *)cacheKeyForURL:(NSURL *)url; + +@end + + +#pragma mark - Deprecated + +typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionBlock`"); +typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionWithFinishedBlock`"); + + +@interface SDWebImageManager (Deprecated) + +/** + * Downloads the image at the given URL if not present in cache or return the cached version otherwise. + * + * @deprecated This method has been deprecated. Use `downloadImageWithURL:options:progress:completed:` + */ +- (id )downloadWithURL:(NSURL *)url + options:(SDWebImageOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageCompletedWithFinishedBlock)completedBlock __deprecated_msg("Method deprecated. Use `downloadImageWithURL:options:progress:completed:`"); + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageManager.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageManager.m new file mode 100644 index 0000000..c804ee9 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageManager.m @@ -0,0 +1,370 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageManager.h" +#import + +@interface SDWebImageCombinedOperation : NSObject + +@property (assign, nonatomic, getter = isCancelled) BOOL cancelled; +@property (copy, nonatomic) SDWebImageNoParamsBlock cancelBlock; +@property (strong, nonatomic) NSOperation *cacheOperation; + +@end + +@interface SDWebImageManager () + +@property (strong, nonatomic, readwrite) SDImageCache *imageCache; +@property (strong, nonatomic, readwrite) SDWebImageDownloader *imageDownloader; +@property (strong, nonatomic) NSMutableSet *failedURLs; +@property (strong, nonatomic) NSMutableArray *runningOperations; + +@end + +@implementation SDWebImageManager + ++ (id)sharedManager { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} + +- (id)init { + if ((self = [super init])) { + _imageCache = [self createCache]; + _imageDownloader = [SDWebImageDownloader sharedDownloader]; + _failedURLs = [NSMutableSet new]; + _runningOperations = [NSMutableArray new]; + } + return self; +} + +- (SDImageCache *)createCache { + return [SDImageCache sharedImageCache]; +} + +- (NSString *)cacheKeyForURL:(NSURL *)url { + if (self.cacheKeyFilter) { + return self.cacheKeyFilter(url); + } + else { + return [url absoluteString]; + } +} + +- (BOOL)cachedImageExistsForURL:(NSURL *)url { + NSString *key = [self cacheKeyForURL:url]; + if ([self.imageCache imageFromMemoryCacheForKey:key] != nil) return YES; + return [self.imageCache diskImageExistsWithKey:key]; +} + +- (BOOL)diskImageExistsForURL:(NSURL *)url { + NSString *key = [self cacheKeyForURL:url]; + return [self.imageCache diskImageExistsWithKey:key]; +} + +- (void)cachedImageExistsForURL:(NSURL *)url + completion:(SDWebImageCheckCacheCompletionBlock)completionBlock { + NSString *key = [self cacheKeyForURL:url]; + + BOOL isInMemoryCache = ([self.imageCache imageFromMemoryCacheForKey:key] != nil); + + if (isInMemoryCache) { + // making sure we call the completion block on the main queue + dispatch_async(dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(YES); + } + }); + return; + } + + [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { + // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch + if (completionBlock) { + completionBlock(isInDiskCache); + } + }]; +} + +- (void)diskImageExistsForURL:(NSURL *)url + completion:(SDWebImageCheckCacheCompletionBlock)completionBlock { + NSString *key = [self cacheKeyForURL:url]; + + [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { + // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch + if (completionBlock) { + completionBlock(isInDiskCache); + } + }]; +} + +- (id )downloadImageWithURL:(NSURL *)url + options:(SDWebImageOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageCompletionWithFinishedBlock)completedBlock { + // Invoking this method without a completedBlock is pointless + NSAssert(completedBlock != nil, @"If you mean to prefetch the image, use -[SDWebImagePrefetcher prefetchURLs] instead"); + + // Very common mistake is to send the URL using NSString object instead of NSURL. For some strange reason, XCode won't + // throw any warning for this type mismatch. Here we failsafe this error by allowing URLs to be passed as NSString. + if ([url isKindOfClass:NSString.class]) { + url = [NSURL URLWithString:(NSString *)url]; + } + + // Prevents app crashing on argument type error like sending NSNull instead of NSURL + if (![url isKindOfClass:NSURL.class]) { + url = nil; + } + + __block SDWebImageCombinedOperation *operation = [SDWebImageCombinedOperation new]; + __weak SDWebImageCombinedOperation *weakOperation = operation; + + BOOL isFailedUrl = NO; + @synchronized (self.failedURLs) { + isFailedUrl = [self.failedURLs containsObject:url]; + } + + if (url.absoluteString.length == 0 || (!(options & SDWebImageRetryFailed) && isFailedUrl)) { + dispatch_main_sync_safe(^{ + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]; + completedBlock(nil, error, SDImageCacheTypeNone, YES, url); + }); + return operation; + } + + @synchronized (self.runningOperations) { + [self.runningOperations addObject:operation]; + } + NSString *key = [self cacheKeyForURL:url]; + + operation.cacheOperation = [self.imageCache queryDiskCacheForKey:key done:^(UIImage *image, SDImageCacheType cacheType) { + if (operation.isCancelled) { + @synchronized (self.runningOperations) { + [self.runningOperations removeObject:operation]; + } + + return; + } + + if ((!image || options & SDWebImageRefreshCached) && (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url])) { + if (image && options & SDWebImageRefreshCached) { + dispatch_main_sync_safe(^{ + // If image was found in the cache but SDWebImageRefreshCached is provided, notify about the cached image + // AND try to re-download it in order to let a chance to NSURLCache to refresh it from server. + completedBlock(image, nil, cacheType, YES, url); + }); + } + + // download if no image or requested to refresh anyway, and download allowed by delegate + SDWebImageDownloaderOptions downloaderOptions = 0; + if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority; + if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload; + if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache; + if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground; + if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies; + if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates; + if (options & SDWebImageHighPriority) downloaderOptions |= SDWebImageDownloaderHighPriority; + if (image && options & SDWebImageRefreshCached) { + // force progressive off if image already cached but forced refreshing + downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload; + // ignore image read from NSURLCache if image if cached but force refreshing + downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse; + } + id subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished) { + __strong __typeof(weakOperation) strongOperation = weakOperation; + if (!strongOperation || strongOperation.isCancelled) { + // Do nothing if the operation was cancelled + // See #699 for more details + // if we would call the completedBlock, there could be a race condition between this block and another completedBlock for the same object, so if this one is called second, we will overwrite the new data + } + else if (error) { + dispatch_main_sync_safe(^{ + if (strongOperation && !strongOperation.isCancelled) { + completedBlock(nil, error, SDImageCacheTypeNone, finished, url); + } + }); + + if ( error.code != NSURLErrorNotConnectedToInternet + && error.code != NSURLErrorCancelled + && error.code != NSURLErrorTimedOut + && error.code != NSURLErrorInternationalRoamingOff + && error.code != NSURLErrorDataNotAllowed + && error.code != NSURLErrorCannotFindHost + && error.code != NSURLErrorCannotConnectToHost) { + @synchronized (self.failedURLs) { + [self.failedURLs addObject:url]; + } + } + } + else { + if ((options & SDWebImageRetryFailed)) { + @synchronized (self.failedURLs) { + [self.failedURLs removeObject:url]; + } + } + + BOOL cacheOnDisk = !(options & SDWebImageCacheMemoryOnly); + + if (options & SDWebImageRefreshCached && image && !downloadedImage) { + // Image refresh hit the NSURLCache cache, do not call the completion block + } + else if (downloadedImage && (!downloadedImage.images || (options & SDWebImageTransformAnimatedImage)) && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)]) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url]; + + if (transformedImage && finished) { + BOOL imageWasTransformed = ![transformedImage isEqual:downloadedImage]; + [self.imageCache storeImage:transformedImage recalculateFromImage:imageWasTransformed imageData:(imageWasTransformed ? nil : data) forKey:key toDisk:cacheOnDisk]; + } + + dispatch_main_sync_safe(^{ + if (strongOperation && !strongOperation.isCancelled) { + completedBlock(transformedImage, nil, SDImageCacheTypeNone, finished, url); + } + }); + }); + } + else { + if (downloadedImage && finished) { + [self.imageCache storeImage:downloadedImage recalculateFromImage:NO imageData:data forKey:key toDisk:cacheOnDisk]; + } + + dispatch_main_sync_safe(^{ + if (strongOperation && !strongOperation.isCancelled) { + completedBlock(downloadedImage, nil, SDImageCacheTypeNone, finished, url); + } + }); + } + } + + if (finished) { + @synchronized (self.runningOperations) { + if (strongOperation) { + [self.runningOperations removeObject:strongOperation]; + } + } + } + }]; + operation.cancelBlock = ^{ + [subOperation cancel]; + + @synchronized (self.runningOperations) { + __strong __typeof(weakOperation) strongOperation = weakOperation; + if (strongOperation) { + [self.runningOperations removeObject:strongOperation]; + } + } + }; + } + else if (image) { + dispatch_main_sync_safe(^{ + __strong __typeof(weakOperation) strongOperation = weakOperation; + if (strongOperation && !strongOperation.isCancelled) { + completedBlock(image, nil, cacheType, YES, url); + } + }); + @synchronized (self.runningOperations) { + [self.runningOperations removeObject:operation]; + } + } + else { + // Image not in cache and download disallowed by delegate + dispatch_main_sync_safe(^{ + __strong __typeof(weakOperation) strongOperation = weakOperation; + if (strongOperation && !weakOperation.isCancelled) { + completedBlock(nil, nil, SDImageCacheTypeNone, YES, url); + } + }); + @synchronized (self.runningOperations) { + [self.runningOperations removeObject:operation]; + } + } + }]; + + return operation; +} + +- (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url { + if (image && url) { + NSString *key = [self cacheKeyForURL:url]; + [self.imageCache storeImage:image forKey:key toDisk:YES]; + } +} + +- (void)cancelAll { + @synchronized (self.runningOperations) { + NSArray *copiedOperations = [self.runningOperations copy]; + [copiedOperations makeObjectsPerformSelector:@selector(cancel)]; + [self.runningOperations removeObjectsInArray:copiedOperations]; + } +} + +- (BOOL)isRunning { + BOOL isRunning = NO; + @synchronized(self.runningOperations) { + isRunning = (self.runningOperations.count > 0); + } + return isRunning; +} + +@end + + +@implementation SDWebImageCombinedOperation + +- (void)setCancelBlock:(SDWebImageNoParamsBlock)cancelBlock { + // check if the operation is already cancelled, then we just call the cancelBlock + if (self.isCancelled) { + if (cancelBlock) { + cancelBlock(); + } + _cancelBlock = nil; // don't forget to nil the cancelBlock, otherwise we will get crashes + } else { + _cancelBlock = [cancelBlock copy]; + } +} + +- (void)cancel { + self.cancelled = YES; + if (self.cacheOperation) { + [self.cacheOperation cancel]; + self.cacheOperation = nil; + } + if (self.cancelBlock) { + self.cancelBlock(); + + // TODO: this is a temporary fix to #809. + // Until we can figure the exact cause of the crash, going with the ivar instead of the setter +// self.cancelBlock = nil; + _cancelBlock = nil; + } +} + +@end + + +@implementation SDWebImageManager (Deprecated) + +// deprecated method, uses the non deprecated method +// adapter for the completion block +- (id )downloadWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedWithFinishedBlock)completedBlock { + return [self downloadImageWithURL:url + options:options + progress:progressBlock + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType, finished); + } + }]; +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h new file mode 100644 index 0000000..71094ee --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h @@ -0,0 +1,15 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import + +@protocol SDWebImageOperation + +- (void)cancel; + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h new file mode 100644 index 0000000..6c31b15 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h @@ -0,0 +1,108 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageManager.h" + +@class SDWebImagePrefetcher; + +@protocol SDWebImagePrefetcherDelegate + +@optional + +/** + * Called when an image was prefetched. + * + * @param imagePrefetcher The current image prefetcher + * @param imageURL The image url that was prefetched + * @param finishedCount The total number of images that were prefetched (successful or not) + * @param totalCount The total number of images that were to be prefetched + */ +- (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; + +/** + * Called when all images are prefetched. + * @param imagePrefetcher The current image prefetcher + * @param totalCount The total number of images that were prefetched (whether successful or not) + * @param skippedCount The total number of images that were skipped + */ +- (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; + +@end + +typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls); +typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls); + +/** + * Prefetch some URLs in the cache for future use. Images are downloaded in low priority. + */ +@interface SDWebImagePrefetcher : NSObject + +/** + * The web image manager + */ +@property (strong, nonatomic, readonly) SDWebImageManager *manager; + +/** + * Maximum number of URLs to prefetch at the same time. Defaults to 3. + */ +@property (nonatomic, assign) NSUInteger maxConcurrentDownloads; + +/** + * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. + */ +@property (nonatomic, assign) SDWebImageOptions options; + +/** + * Queue options for Prefetcher. Defaults to Main Queue. + */ +@property (nonatomic, assign) dispatch_queue_t prefetcherQueue; + +@property (weak, nonatomic) id delegate; + +/** + * Return the global image prefetcher instance. + */ ++ (SDWebImagePrefetcher *)sharedImagePrefetcher; + +/** + * Allows you to instantiate a prefetcher with any arbitrary image manager. + */ +- (id)initWithImageManager:(SDWebImageManager *)manager; + +/** + * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, + * currently one image is downloaded at a time, + * and skips images for failed downloads and proceed to the next image in the list + * + * @param urls list of URLs to prefetch + */ +- (void)prefetchURLs:(NSArray *)urls; + +/** + * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, + * currently one image is downloaded at a time, + * and skips images for failed downloads and proceed to the next image in the list + * + * @param urls list of URLs to prefetch + * @param progressBlock block to be called when progress updates; + * first parameter is the number of completed (successful or not) requests, + * second parameter is the total number of images originally requested to be prefetched + * @param completionBlock block to be called when prefetching is completed + * first param is the number of completed (successful or not) requests, + * second parameter is the number of skipped requests + */ +- (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock; + +/** + * Remove and cancel queued list + */ +- (void)cancelPrefetching; + + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m new file mode 100644 index 0000000..f518d44 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m @@ -0,0 +1,140 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImagePrefetcher.h" + +@interface SDWebImagePrefetcher () + +@property (strong, nonatomic) SDWebImageManager *manager; +@property (strong, nonatomic) NSArray *prefetchURLs; +@property (assign, nonatomic) NSUInteger requestedCount; +@property (assign, nonatomic) NSUInteger skippedCount; +@property (assign, nonatomic) NSUInteger finishedCount; +@property (assign, nonatomic) NSTimeInterval startedTime; +@property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock; +@property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock; + +@end + +@implementation SDWebImagePrefetcher + ++ (SDWebImagePrefetcher *)sharedImagePrefetcher { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} + +- (id)init { + return [self initWithImageManager:[SDWebImageManager new]]; +} + +- (id)initWithImageManager:(SDWebImageManager *)manager { + if ((self = [super init])) { + _manager = manager; + _options = SDWebImageLowPriority; + _prefetcherQueue = dispatch_get_main_queue(); + self.maxConcurrentDownloads = 3; + } + return self; +} + +- (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { + self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; +} + +- (NSUInteger)maxConcurrentDownloads { + return self.manager.imageDownloader.maxConcurrentDownloads; +} + +- (void)startPrefetchingAtIndex:(NSUInteger)index { + if (index >= self.prefetchURLs.count) return; + self.requestedCount++; + [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!finished) return; + self.finishedCount++; + + if (image) { + if (self.progressBlock) { + self.progressBlock(self.finishedCount,[self.prefetchURLs count]); + } + } + else { + if (self.progressBlock) { + self.progressBlock(self.finishedCount,[self.prefetchURLs count]); + } + // Add last failed + self.skippedCount++; + } + if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { + [self.delegate imagePrefetcher:self + didPrefetchURL:self.prefetchURLs[index] + finishedCount:self.finishedCount + totalCount:self.prefetchURLs.count + ]; + } + if (self.prefetchURLs.count > self.requestedCount) { + dispatch_async(self.prefetcherQueue, ^{ + [self startPrefetchingAtIndex:self.requestedCount]; + }); + } else if (self.finishedCount == self.requestedCount) { + [self reportStatus]; + if (self.completionBlock) { + self.completionBlock(self.finishedCount, self.skippedCount); + self.completionBlock = nil; + } + self.progressBlock = nil; + } + }]; +} + +- (void)reportStatus { + NSUInteger total = [self.prefetchURLs count]; + if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { + [self.delegate imagePrefetcher:self + didFinishWithTotalCount:(total - self.skippedCount) + skippedCount:self.skippedCount + ]; + } +} + +- (void)prefetchURLs:(NSArray *)urls { + [self prefetchURLs:urls progress:nil completed:nil]; +} + +- (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock { + [self cancelPrefetching]; // Prevent duplicate prefetch request + self.startedTime = CFAbsoluteTimeGetCurrent(); + self.prefetchURLs = urls; + self.completionBlock = completionBlock; + self.progressBlock = progressBlock; + + if (urls.count == 0) { + if (completionBlock) { + completionBlock(0,0); + } + } else { + // Starts prefetching from the very first image on the list with the max allowed concurrency + NSUInteger listCount = self.prefetchURLs.count; + for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { + [self startPrefetchingAtIndex:i]; + } + } +} + +- (void)cancelPrefetching { + self.prefetchURLs = nil; + self.skippedCount = 0; + self.requestedCount = 0; + self.finishedCount = 0; + [self.manager cancelAll]; +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h new file mode 100644 index 0000000..ecf5ced --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h @@ -0,0 +1,229 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "SDWebImageManager.h" + +/** + * Integrates SDWebImage async downloading and caching of remote images with UIButtonView. + */ +@interface UIButton (WebCache) + +/** + * Get the current image URL. + */ +- (NSURL *)sd_currentImageURL; + +/** + * Get the image URL for a control state. + * + * @param state Which state you want to know the URL for. The values are described in UIControlState. + */ +- (NSURL *)sd_imageURLForState:(UIControlState)state; + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state; + +/** + * Set the imageView `image` with an `url` and a placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @see sd_setImageWithURL:placeholderImage:options: + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the backgroundImageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state; + +/** + * Set the backgroundImageView `image` with an `url` and a placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @see sd_setImageWithURL:placeholderImage:options: + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; + +/** + * Set the backgroundImageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; + +/** + * Set the backgroundImageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the backgroundImageView `image` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the backgroundImageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Cancel the current image download + */ +- (void)sd_cancelImageLoadForState:(UIControlState)state; + +/** + * Cancel the current backgroundImage download + */ +- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state; + +@end + + +@interface UIButton (WebCacheDeprecated) + +- (NSURL *)currentImageURL __deprecated_msg("Use `sd_currentImageURL`"); +- (NSURL *)imageURLForState:(UIControlState)state __deprecated_msg("Use `sd_imageURLForState:`"); + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`"); +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`"); +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:`"); + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:completed:`"); +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:completed:`"); +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:completed:`"); + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:`"); +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:`"); +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:`"); + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:completed:`"); +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`"); +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:`"); + +- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelImageLoadForState:`"); +- (void)cancelBackgroundImageLoadForState:(UIControlState)state __deprecated_msg("Use `sd_cancelBackgroundImageLoadForState:`"); + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m new file mode 100644 index 0000000..ce2175d --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m @@ -0,0 +1,270 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIButton+WebCache.h" +#import "objc/runtime.h" +#import "UIView+WebCacheOperation.h" + +static char imageURLStorageKey; + +@implementation UIButton (WebCache) + +- (NSURL *)sd_currentImageURL { + NSURL *url = self.imageURLStorage[@(self.state)]; + + if (!url) { + url = self.imageURLStorage[@(UIControlStateNormal)]; + } + + return url; +} + +- (NSURL *)sd_imageURLForState:(UIControlState)state { + return self.imageURLStorage[@(state)]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state { + [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { + + [self setImage:placeholder forState:state]; + [self sd_cancelImageLoadForState:state]; + + if (!url) { + [self.imageURLStorage removeObjectForKey:@(state)]; + + dispatch_main_async_safe(^{ + if (completedBlock) { + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; + completedBlock(nil, error, SDImageCacheTypeNone, url); + } + }); + + return; + } + + self.imageURLStorage[@(state)] = url; + + __weak __typeof(self)wself = self; + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!wself) return; + dispatch_main_sync_safe(^{ + __strong UIButton *sself = wself; + if (!sself) return; + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) + { + completedBlock(image, error, cacheType, url); + return; + } + else if (image) { + [sself setImage:image forState:state]; + } + if (completedBlock && finished) { + completedBlock(image, error, cacheType, url); + } + }); + }]; + [self sd_setImageLoadOperation:operation forState:state]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_cancelBackgroundImageLoadForState:state]; + + [self setBackgroundImage:placeholder forState:state]; + + if (url) { + __weak __typeof(self)wself = self; + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!wself) return; + dispatch_main_sync_safe(^{ + __strong UIButton *sself = wself; + if (!sself) return; + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) + { + completedBlock(image, error, cacheType, url); + return; + } + else if (image) { + [sself setBackgroundImage:image forState:state]; + } + if (completedBlock && finished) { + completedBlock(image, error, cacheType, url); + } + }); + }]; + [self sd_setBackgroundImageLoadOperation:operation forState:state]; + } else { + dispatch_main_async_safe(^{ + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; + if (completedBlock) { + completedBlock(nil, error, SDImageCacheTypeNone, url); + } + }); + } +} + +- (void)sd_setImageLoadOperation:(id)operation forState:(UIControlState)state { + [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; +} + +- (void)sd_cancelImageLoadForState:(UIControlState)state { + [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; +} + +- (void)sd_setBackgroundImageLoadOperation:(id)operation forState:(UIControlState)state { + [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; +} + +- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state { + [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; +} + +- (NSMutableDictionary *)imageURLStorage { + NSMutableDictionary *storage = objc_getAssociatedObject(self, &imageURLStorageKey); + if (!storage) + { + storage = [NSMutableDictionary dictionary]; + objc_setAssociatedObject(self, &imageURLStorageKey, storage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + + return storage; +} + +@end + + +@implementation UIButton (WebCacheDeprecated) + +- (NSURL *)currentImageURL { + return [self sd_currentImageURL]; +} + +- (NSURL *)imageURLForState:(UIControlState)state { + return [self sd_imageURLForState:state]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state { + [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)cancelCurrentImageLoad { + // in a backwards compatible manner, cancel for current state + [self sd_cancelImageLoadForState:self.state]; +} + +- (void)cancelBackgroundImageLoadForState:(UIControlState)state { + [self sd_cancelBackgroundImageLoadForState:state]; +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+GIF.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+GIF.h new file mode 100755 index 0000000..084f424 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+GIF.h @@ -0,0 +1,19 @@ +// +// UIImage+GIF.h +// LBGIFImage +// +// Created by Laurin Brandner on 06.01.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +@interface UIImage (GIF) + ++ (UIImage *)sd_animatedGIFNamed:(NSString *)name; + ++ (UIImage *)sd_animatedGIFWithData:(NSData *)data; + +- (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size; + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+GIF.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+GIF.m new file mode 100755 index 0000000..e1ded2a --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+GIF.m @@ -0,0 +1,158 @@ +// +// UIImage+GIF.m +// LBGIFImage +// +// Created by Laurin Brandner on 06.01.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "UIImage+GIF.h" +#import + +@implementation UIImage (GIF) + ++ (UIImage *)sd_animatedGIFWithData:(NSData *)data { + if (!data) { + return nil; + } + + CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); + + size_t count = CGImageSourceGetCount(source); + + UIImage *animatedImage; + + if (count <= 1) { + animatedImage = [[UIImage alloc] initWithData:data]; + } + else { + NSMutableArray *images = [NSMutableArray array]; + + NSTimeInterval duration = 0.0f; + + for (size_t i = 0; i < count; i++) { + CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); + + duration += [self sd_frameDurationAtIndex:i source:source]; + + [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; + + CGImageRelease(image); + } + + if (!duration) { + duration = (1.0f / 10.0f) * count; + } + + animatedImage = [UIImage animatedImageWithImages:images duration:duration]; + } + + CFRelease(source); + + return animatedImage; +} + ++ (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { + float frameDuration = 0.1f; + CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); + NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; + NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; + + NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; + if (delayTimeUnclampedProp) { + frameDuration = [delayTimeUnclampedProp floatValue]; + } + else { + + NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; + if (delayTimeProp) { + frameDuration = [delayTimeProp floatValue]; + } + } + + // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. + // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify + // a duration of <= 10 ms. See and + // for more information. + + if (frameDuration < 0.011f) { + frameDuration = 0.100f; + } + + CFRelease(cfFrameProperties); + return frameDuration; +} + ++ (UIImage *)sd_animatedGIFNamed:(NSString *)name { + CGFloat scale = [UIScreen mainScreen].scale; + + if (scale > 1.0f) { + NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"]; + + NSData *data = [NSData dataWithContentsOfFile:retinaPath]; + + if (data) { + return [UIImage sd_animatedGIFWithData:data]; + } + + NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; + + data = [NSData dataWithContentsOfFile:path]; + + if (data) { + return [UIImage sd_animatedGIFWithData:data]; + } + + return [UIImage imageNamed:name]; + } + else { + NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; + + NSData *data = [NSData dataWithContentsOfFile:path]; + + if (data) { + return [UIImage sd_animatedGIFWithData:data]; + } + + return [UIImage imageNamed:name]; + } +} + +- (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size { + if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) { + return self; + } + + CGSize scaledSize = size; + CGPoint thumbnailPoint = CGPointZero; + + CGFloat widthFactor = size.width / self.size.width; + CGFloat heightFactor = size.height / self.size.height; + CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor; + scaledSize.width = self.size.width * scaleFactor; + scaledSize.height = self.size.height * scaleFactor; + + if (widthFactor > heightFactor) { + thumbnailPoint.y = (size.height - scaledSize.height) * 0.5; + } + else if (widthFactor < heightFactor) { + thumbnailPoint.x = (size.width - scaledSize.width) * 0.5; + } + + NSMutableArray *scaledImages = [NSMutableArray array]; + + for (UIImage *image in self.images) { + UIGraphicsBeginImageContextWithOptions(size, NO, 0.0); + + [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)]; + UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); + + [scaledImages addObject:newImage]; + + UIGraphicsEndImageContext(); + } + + return [UIImage animatedImageWithImages:scaledImages duration:self.duration]; +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h new file mode 100644 index 0000000..186ebc0 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h @@ -0,0 +1,15 @@ +// +// UIImage+MultiFormat.h +// SDWebImage +// +// Created by Olivier Poitrey on 07/06/13. +// Copyright (c) 2013 Dailymotion. All rights reserved. +// + +#import + +@interface UIImage (MultiFormat) + ++ (UIImage *)sd_imageWithData:(NSData *)data; + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m new file mode 100644 index 0000000..a830754 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m @@ -0,0 +1,118 @@ +// +// UIImage+MultiFormat.m +// SDWebImage +// +// Created by Olivier Poitrey on 07/06/13. +// Copyright (c) 2013 Dailymotion. All rights reserved. +// + +#import "UIImage+MultiFormat.h" +#import "UIImage+GIF.h" +#import "NSData+ImageContentType.h" +#import + +#ifdef SD_WEBP +#import "UIImage+WebP.h" +#endif + +@implementation UIImage (MultiFormat) + ++ (UIImage *)sd_imageWithData:(NSData *)data { + if (!data) { + return nil; + } + + UIImage *image; + NSString *imageContentType = [NSData sd_contentTypeForImageData:data]; + if ([imageContentType isEqualToString:@"image/gif"]) { + image = [UIImage sd_animatedGIFWithData:data]; + } +#ifdef SD_WEBP + else if ([imageContentType isEqualToString:@"image/webp"]) + { + image = [UIImage sd_imageWithWebPData:data]; + } +#endif + else { + image = [[UIImage alloc] initWithData:data]; + UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; + if (orientation != UIImageOrientationUp) { + image = [UIImage imageWithCGImage:image.CGImage + scale:image.scale + orientation:orientation]; + } + } + + + return image; +} + + ++(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData { + UIImageOrientation result = UIImageOrientationUp; + CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); + if (imageSource) { + CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); + if (properties) { + CFTypeRef val; + int exifOrientation; + val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); + if (val) { + CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); + result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; + } // else - if it's not set it remains at up + CFRelease((CFTypeRef) properties); + } else { + //NSLog(@"NO PROPERTIES, FAIL"); + } + CFRelease(imageSource); + } + return result; +} + +#pragma mark EXIF orientation tag converter +// Convert an EXIF image orientation to an iOS one. +// reference see here: http://sylvana.net/jpegcrop/exif_orientation.html ++ (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { + UIImageOrientation orientation = UIImageOrientationUp; + switch (exifOrientation) { + case 1: + orientation = UIImageOrientationUp; + break; + + case 3: + orientation = UIImageOrientationDown; + break; + + case 8: + orientation = UIImageOrientationLeft; + break; + + case 6: + orientation = UIImageOrientationRight; + break; + + case 2: + orientation = UIImageOrientationUpMirrored; + break; + + case 4: + orientation = UIImageOrientationDownMirrored; + break; + + case 5: + orientation = UIImageOrientationLeftMirrored; + break; + + case 7: + orientation = UIImageOrientationRightMirrored; + break; + default: + break; + } + return orientation; +} + + + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h new file mode 100644 index 0000000..c1d8fea --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h @@ -0,0 +1,100 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" +#import "SDWebImageManager.h" + +/** + * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. + */ +@interface UIImageView (HighlightedWebCache) + +/** + * Set the imageView `highlightedImage` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url; + +/** + * Set the imageView `highlightedImage` with an `url` and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options; + +/** + * Set the imageView `highlightedImage` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `highlightedImage` with an `url` and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `highlightedImage` with an `url` and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Cancel the current download + */ +- (void)sd_cancelCurrentHighlightedImageLoad; + +@end + + +@interface UIImageView (HighlightedWebCacheDeprecated) + +- (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`"); +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`"); +- (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`"); +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); + +- (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`"); + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m new file mode 100644 index 0000000..921134e --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m @@ -0,0 +1,112 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIImageView+HighlightedWebCache.h" +#import "UIView+WebCacheOperation.h" + +#define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage" + +@implementation UIImageView (HighlightedWebCache) + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url { + [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; +} + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { + [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; +} + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; +} + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_cancelCurrentHighlightedImageLoad]; + + if (url) { + __weak __typeof(self)wself = self; + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!wself) return; + dispatch_main_sync_safe (^ + { + if (!wself) return; + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) + { + completedBlock(image, error, cacheType, url); + return; + } + else if (image) { + wself.highlightedImage = image; + [wself setNeedsLayout]; + } + if (completedBlock && finished) { + completedBlock(image, error, cacheType, url); + } + }); + }]; + [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; + } else { + dispatch_main_async_safe(^{ + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; + if (completedBlock) { + completedBlock(nil, error, SDImageCacheTypeNone, url); + } + }); + } +} + +- (void)sd_cancelCurrentHighlightedImageLoad { + [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; +} + +@end + + +@implementation UIImageView (HighlightedWebCacheDeprecated) + +- (void)setHighlightedImageWithURL:(NSURL *)url { + [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; +} + +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { + [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; +} + +- (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)cancelCurrentHighlightedImageLoad { + [self sd_cancelCurrentHighlightedImageLoad]; +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h new file mode 100644 index 0000000..eeb7460 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h @@ -0,0 +1,213 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "SDWebImageManager.h" + +/** + * Integrates SDWebImage async downloading and caching of remote images with UIImageView. + * + * Usage with a UITableViewCell sub-class: + * + * @code + +#import + +... + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *MyIdentifier = @"MyIdentifier"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; + + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] + autorelease]; + } + + // Here we use the provided sd_setImageWithURL: method to load the web image + // Ensure you use a placeholder image otherwise cells will be initialized with no image + [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] + placeholderImage:[UIImage imageNamed:@"placeholder"]]; + + cell.textLabel.text = @"My Text"; + return cell; +} + + * @endcode + */ +@interface UIImageView (WebCache) + +/** + * Get the current image URL. + * + * Note that because of the limitations of categories this property can get out of sync + * if you use sd_setImage: directly. + */ +- (NSURL *)sd_imageURL; + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + */ +- (void)sd_setImageWithURL:(NSURL *)url; + +/** + * Set the imageView `image` with an `url` and a placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @see sd_setImageWithURL:placeholderImage:options: + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url` and optionally a placeholder image. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Download an array of images and starts them in an animation loop + * + * @param arrayOfURLs An array of NSURL + */ +- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; + +/** + * Cancel the current download + */ +- (void)sd_cancelCurrentImageLoad; + +- (void)sd_cancelCurrentAnimationImagesLoad; + +/** + * Show activity UIActivityIndicatorView + */ +- (void)setShowActivityIndicatorView:(BOOL)show; + +/** + * set desired UIActivityIndicatorViewStyle + * + * @param style The style of the UIActivityIndicatorView + */ +- (void)setIndicatorStyle:(UIActivityIndicatorViewStyle)style; + +@end + + +@interface UIImageView (WebCacheDeprecated) + +- (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); + +- (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`"); + +- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`"); + +- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`"); + +- (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`"); + +- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m new file mode 100644 index 0000000..14f425c --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m @@ -0,0 +1,277 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIImageView+WebCache.h" +#import "objc/runtime.h" +#import "UIView+WebCacheOperation.h" + +static char imageURLKey; +static char TAG_ACTIVITY_INDICATOR; +static char TAG_ACTIVITY_STYLE; +static char TAG_ACTIVITY_SHOW; + +@implementation UIImageView (WebCache) + +- (void)sd_setImageWithURL:(NSURL *)url { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_cancelCurrentImageLoad]; + objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + + if (!(options & SDWebImageDelayPlaceholder)) { + dispatch_main_async_safe(^{ + self.image = placeholder; + }); + } + + if (url) { + + // check if activityView is enabled or not + if ([self showActivityIndicatorView]) { + [self addActivityIndicator]; + } + + __weak __typeof(self)wself = self; + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + [wself removeActivityIndicator]; + if (!wself) return; + dispatch_main_sync_safe(^{ + if (!wself) return; + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) + { + completedBlock(image, error, cacheType, url); + return; + } + else if (image) { + wself.image = image; + [wself setNeedsLayout]; + } else { + if ((options & SDWebImageDelayPlaceholder)) { + wself.image = placeholder; + [wself setNeedsLayout]; + } + } + if (completedBlock && finished) { + completedBlock(image, error, cacheType, url); + } + }); + }]; + [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"]; + } else { + dispatch_main_async_safe(^{ + [self removeActivityIndicator]; + if (completedBlock) { + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; + completedBlock(nil, error, SDImageCacheTypeNone, url); + } + }); + } +} + +- (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { + NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url]; + UIImage *lastPreviousCachedImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:key]; + + [self sd_setImageWithURL:url placeholderImage:lastPreviousCachedImage ?: placeholder options:options progress:progressBlock completed:completedBlock]; +} + +- (NSURL *)sd_imageURL { + return objc_getAssociatedObject(self, &imageURLKey); +} + +- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { + [self sd_cancelCurrentAnimationImagesLoad]; + __weak __typeof(self)wself = self; + + NSMutableArray *operationsArray = [[NSMutableArray alloc] init]; + + for (NSURL *logoImageURL in arrayOfURLs) { + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!wself) return; + dispatch_main_sync_safe(^{ + __strong UIImageView *sself = wself; + [sself stopAnimating]; + if (sself && image) { + NSMutableArray *currentImages = [[sself animationImages] mutableCopy]; + if (!currentImages) { + currentImages = [[NSMutableArray alloc] init]; + } + [currentImages addObject:image]; + + sself.animationImages = currentImages; + [sself setNeedsLayout]; + } + [sself startAnimating]; + }); + }]; + [operationsArray addObject:operation]; + } + + [self sd_setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"]; +} + +- (void)sd_cancelCurrentImageLoad { + [self sd_cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"]; +} + +- (void)sd_cancelCurrentAnimationImagesLoad { + [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"]; +} + + +#pragma mark - +- (UIActivityIndicatorView *)activityIndicator { + return (UIActivityIndicatorView *)objc_getAssociatedObject(self, &TAG_ACTIVITY_INDICATOR); +} + +- (void)setActivityIndicator:(UIActivityIndicatorView *)activityIndicator { + objc_setAssociatedObject(self, &TAG_ACTIVITY_INDICATOR, activityIndicator, OBJC_ASSOCIATION_RETAIN); +} + +- (void)setShowActivityIndicatorView:(BOOL)show{ + objc_setAssociatedObject(self, &TAG_ACTIVITY_SHOW, [NSNumber numberWithBool:show], OBJC_ASSOCIATION_RETAIN); +} + +- (BOOL)showActivityIndicatorView{ + return [objc_getAssociatedObject(self, &TAG_ACTIVITY_SHOW) boolValue]; +} + +- (void)setIndicatorStyle:(UIActivityIndicatorViewStyle)style{ + objc_setAssociatedObject(self, &TAG_ACTIVITY_STYLE, [NSNumber numberWithInt:style], OBJC_ASSOCIATION_RETAIN); +} + +- (int)getIndicatorStyle{ + return [objc_getAssociatedObject(self, &TAG_ACTIVITY_STYLE) intValue]; +} + +- (void)addActivityIndicator { + if (!self.activityIndicator) { + self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:[self getIndicatorStyle]]; + self.activityIndicator.translatesAutoresizingMaskIntoConstraints = NO; + + dispatch_main_async_safe(^{ + [self addSubview:self.activityIndicator]; + + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.activityIndicator + attribute:NSLayoutAttributeCenterX + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeCenterX + multiplier:1.0 + constant:0.0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.activityIndicator + attribute:NSLayoutAttributeCenterY + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeCenterY + multiplier:1.0 + constant:0.0]]; + }); + } + + dispatch_main_async_safe(^{ + [self.activityIndicator startAnimating]; + }); + +} + +- (void)removeActivityIndicator { + if (self.activityIndicator) { + [self.activityIndicator removeFromSuperview]; + self.activityIndicator = nil; + } +} + +@end + + +@implementation UIImageView (WebCacheDeprecated) + +- (NSURL *)imageURL { + return [self sd_imageURL]; +} + +- (void)setImageWithURL:(NSURL *)url { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)cancelCurrentArrayLoad { + [self sd_cancelCurrentAnimationImagesLoad]; +} + +- (void)cancelCurrentImageLoad { + [self sd_cancelCurrentImageLoad]; +} + +- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { + [self sd_setAnimationImagesWithURLs:arrayOfURLs]; +} + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h new file mode 100644 index 0000000..6719036 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h @@ -0,0 +1,36 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageManager.h" + +@interface UIView (WebCacheOperation) + +/** + * Set the image load operation (storage in a UIView based dictionary) + * + * @param operation the operation + * @param key key for storing the operation + */ +- (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key; + +/** + * Cancel all operations for the current UIView and key + * + * @param key key for identifying the operations + */ +- (void)sd_cancelImageLoadOperationWithKey:(NSString *)key; + +/** + * Just remove the operations corresponding to the current UIView and key without cancelling them + * + * @param key key for identifying the operations + */ +- (void)sd_removeImageLoadOperationWithKey:(NSString *)key; + +@end diff --git a/HeadsUpper/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m new file mode 100644 index 0000000..9219478 --- /dev/null +++ b/HeadsUpper/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m @@ -0,0 +1,55 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIView+WebCacheOperation.h" +#import "objc/runtime.h" + +static char loadOperationKey; + +@implementation UIView (WebCacheOperation) + +- (NSMutableDictionary *)operationDictionary { + NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); + if (operations) { + return operations; + } + operations = [NSMutableDictionary dictionary]; + objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + return operations; +} + +- (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key { + [self sd_cancelImageLoadOperationWithKey:key]; + NSMutableDictionary *operationDictionary = [self operationDictionary]; + [operationDictionary setObject:operation forKey:key]; +} + +- (void)sd_cancelImageLoadOperationWithKey:(NSString *)key { + // Cancel in progress downloader from queue + NSMutableDictionary *operationDictionary = [self operationDictionary]; + id operations = [operationDictionary objectForKey:key]; + if (operations) { + if ([operations isKindOfClass:[NSArray class]]) { + for (id operation in operations) { + if (operation) { + [operation cancel]; + } + } + } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ + [(id) operations cancel]; + } + [operationDictionary removeObjectForKey:key]; + } +} + +- (void)sd_removeImageLoadOperationWithKey:(NSString *)key { + NSMutableDictionary *operationDictionary = [self operationDictionary]; + [operationDictionary removeObjectForKey:key]; +} + +@end diff --git a/HeadsUpper/Pods/SIAlertView/LICENSE.md b/HeadsUpper/Pods/SIAlertView/LICENSE.md new file mode 100644 index 0000000..38678c8 --- /dev/null +++ b/HeadsUpper/Pods/SIAlertView/LICENSE.md @@ -0,0 +1,7 @@ +Copyright (c) 2013 Sumi Interactive + +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. \ No newline at end of file diff --git a/HeadsUpper/Pods/SIAlertView/README.md b/HeadsUpper/Pods/SIAlertView/README.md new file mode 100644 index 0000000..0447b1b --- /dev/null +++ b/HeadsUpper/Pods/SIAlertView/README.md @@ -0,0 +1,87 @@ +SIAlertView +============= + +An UIAlertView replacement with block syntax and fancy transition styles. As seen in [Grid Diary](http://griddiaryapp.com/). + +[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=Sumi-Interactive&url=https://github.com/Sumi-Interactive/SIAlertView&title=SIAlertView&tags=github&category=software) + +## Preview + +![SIAlertView Screenshot](https://github.com/Sumi-Interactive/SIAlertView/raw/master/screenshot.png) + +## Features + +- use window to present +- happy with rotation +- block syntax +- styled transitions +- queue support +- UIAppearance support + +## Installation + +### Cocoapods(Recommended) + +1. Add `pod 'SIAlertView'` to your Podfile. +2. Run `pod install` + +### Manual + +1. Add all files under `SIAlertView/SIAlertView` to your project +2. Add `QuartzCore.framework` to your project + +## Requirements + +- iOS 5.0 and greater +- ARC + +(If you are having any problems, just select your project -> Build Phases -> Compile Sources, double-click the SIAlertView and add `-fobjc-arc`) + +## Examples + +**Code:** + +```objc +SIAlertView *alertView = [[SIAlertView alloc] initWithTitle:@"SIAlertView" andMessage:@"Sumi Interactive"]; + +[alertView addButtonWithTitle:@"Button1" + type:SIAlertViewButtonTypeDefault + handler:^(SIAlertView *alert) { + NSLog(@"Button1 Clicked"); + }]; +[alertView addButtonWithTitle:@"Button2" + type:SIAlertViewButtonTypeDestructive + handler:^(SIAlertView *alert) { + NSLog(@"Button2 Clicked"); + }]; +[alertView addButtonWithTitle:@"Button3" + type:SIAlertViewButtonTypeCancel + handler:^(SIAlertView *alert) { + NSLog(@"Button3 Clicked"); + }]; + +alertView.willShowHandler = ^(SIAlertView *alertView) { + NSLog(@"%@, willShowHandler", alertView); +}; +alertView.didShowHandler = ^(SIAlertView *alertView) { + NSLog(@"%@, didShowHandler", alertView); +}; +alertView.willDismissHandler = ^(SIAlertView *alertView) { + NSLog(@"%@, willDismissHandler", alertView); +}; +alertView.didDismissHandler = ^(SIAlertView *alertView) { + NSLog(@"%@, didDismissHandler", alertView); +}; + +alertView.transitionStyle = SIAlertViewTransitionStyleBounce; + +[alertView show]; +``` + +## Credits + +SIAlertView was created by [Sumi Interactive](https://github.com/Sumi-Interactive) in the development of [Grid Diary](http://griddiaryapp.com/). + +## License + +SIAlertView is available under the MIT license. See the LICENSE file for more info. diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel-d.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel-d.png new file mode 100644 index 0000000..fa432a5 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel-d.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel-d@2x.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel-d@2x.png new file mode 100644 index 0000000..8f359b8 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel-d@2x.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel.png new file mode 100644 index 0000000..88d1564 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel@2x.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel@2x.png new file mode 100644 index 0000000..0ac483b Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-cancel@2x.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default-d.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default-d.png new file mode 100644 index 0000000..47f5163 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default-d.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default-d@2x.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default-d@2x.png new file mode 100644 index 0000000..6d21603 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default-d@2x.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default.png new file mode 100644 index 0000000..17eab59 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default@2x.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default@2x.png new file mode 100644 index 0000000..d5f08e6 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-default@2x.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive-d.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive-d.png new file mode 100644 index 0000000..0a53150 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive-d.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive-d@2x.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive-d@2x.png new file mode 100644 index 0000000..e614faf Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive-d@2x.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive.png new file mode 100644 index 0000000..28f3264 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive@2x.png b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive@2x.png new file mode 100644 index 0000000..1a82328 Binary files /dev/null and b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.bundle/button-destructive@2x.png differ diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.h b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.h new file mode 100644 index 0000000..6d0dfd1 --- /dev/null +++ b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.h @@ -0,0 +1,81 @@ +// +// SIAlertView.h +// SIAlertView +// +// Created by Kevin Cao on 13-4-29. +// Copyright (c) 2013年 Sumi Interactive. All rights reserved. +// + +#import + +extern NSString *const SIAlertViewWillShowNotification; +extern NSString *const SIAlertViewDidShowNotification; +extern NSString *const SIAlertViewWillDismissNotification; +extern NSString *const SIAlertViewDidDismissNotification; + +typedef NS_ENUM(NSInteger, SIAlertViewButtonType) { + SIAlertViewButtonTypeDefault = 0, + SIAlertViewButtonTypeDestructive, + SIAlertViewButtonTypeCancel +}; + +typedef NS_ENUM(NSInteger, SIAlertViewBackgroundStyle) { + SIAlertViewBackgroundStyleGradient = 0, + SIAlertViewBackgroundStyleSolid, +}; + +typedef NS_ENUM(NSInteger, SIAlertViewButtonsListStyle) { + SIAlertViewButtonsListStyleNormal = 0, + SIAlertViewButtonsListStyleRows +}; + +typedef NS_ENUM(NSInteger, SIAlertViewTransitionStyle) { + SIAlertViewTransitionStyleSlideFromBottom = 0, + SIAlertViewTransitionStyleSlideFromTop, + SIAlertViewTransitionStyleFade, + SIAlertViewTransitionStyleBounce, + SIAlertViewTransitionStyleDropDown +}; + +@class SIAlertView; +typedef void(^SIAlertViewHandler)(SIAlertView *alertView); + +@interface SIAlertView : UIView + +@property (nonatomic, copy) NSString *title; +@property (nonatomic, copy) NSString *message; + +@property (nonatomic, assign) SIAlertViewTransitionStyle transitionStyle; // default is SIAlertViewTransitionStyleSlideFromBottom +@property (nonatomic, assign) SIAlertViewBackgroundStyle backgroundStyle; // default is SIAlertViewButtonTypeGradient +@property (nonatomic, assign) SIAlertViewButtonsListStyle buttonsListStyle; // default is SIAlertViewButtonsListStyleNormal + +@property (nonatomic, copy) SIAlertViewHandler willShowHandler; +@property (nonatomic, copy) SIAlertViewHandler didShowHandler; +@property (nonatomic, copy) SIAlertViewHandler willDismissHandler; +@property (nonatomic, copy) SIAlertViewHandler didDismissHandler; + +@property (nonatomic, readonly, getter = isVisible) BOOL visible; + +@property (nonatomic, strong) UIColor *viewBackgroundColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +@property (nonatomic, strong) UIColor *titleColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +@property (nonatomic, strong) UIColor *messageColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +@property (nonatomic, strong) UIFont *titleFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +@property (nonatomic, strong) UIFont *messageFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +@property (nonatomic, strong) UIFont *buttonFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +@property (nonatomic, strong) UIColor *buttonColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +@property (nonatomic, strong) UIColor *cancelButtonColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +@property (nonatomic, strong) UIColor *destructiveButtonColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +@property (nonatomic, assign) CGFloat cornerRadius NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; // default is 2.0 +@property (nonatomic, assign) CGFloat shadowRadius NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; // default is 8.0 + +- (void)setDefaultButtonImage:(UIImage *)defaultButtonImage forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +- (void)setCancelButtonImage:(UIImage *)cancelButtonImage forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; +- (void)setDestructiveButtonImage:(UIImage *)destructiveButtonImage forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; + +- (id)initWithTitle:(NSString *)title andMessage:(NSString *)message; +- (void)addButtonWithTitle:(NSString *)title type:(SIAlertViewButtonType)type handler:(SIAlertViewHandler)handler; + +- (void)show; +- (void)dismissAnimated:(BOOL)animated; + +@end diff --git a/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.m b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.m new file mode 100644 index 0000000..bde3337 --- /dev/null +++ b/HeadsUpper/Pods/SIAlertView/SIAlertView/SIAlertView.m @@ -0,0 +1,1185 @@ +// +// SIAlertView.m +// SIAlertView +// +// Created by Kevin Cao on 13-4-29. +// Copyright (c) 2013年 Sumi Interactive. All rights reserved. +// + +#import "SIAlertView.h" +#import + +NSString *const SIAlertViewWillShowNotification = @"SIAlertViewWillShowNotification"; +NSString *const SIAlertViewDidShowNotification = @"SIAlertViewDidShowNotification"; +NSString *const SIAlertViewWillDismissNotification = @"SIAlertViewWillDismissNotification"; +NSString *const SIAlertViewDidDismissNotification = @"SIAlertViewDidDismissNotification"; + +#define DEBUG_LAYOUT 0 + +#define MESSAGE_MIN_LINE_COUNT 3 +#define MESSAGE_MAX_LINE_COUNT 5 +#define GAP 10 +#define CANCEL_BUTTON_PADDING_TOP 5 +#define CONTENT_PADDING_LEFT 10 +#define CONTENT_PADDING_TOP 12 +#define CONTENT_PADDING_BOTTOM 10 +#define BUTTON_HEIGHT 44 +#define CONTAINER_WIDTH 300 + +const UIWindowLevel UIWindowLevelSIAlert = 1999.0; // don't overlap system's alert +const UIWindowLevel UIWindowLevelSIAlertBackground = 1998.0; // below the alert window + +@class SIAlertBackgroundWindow; + +static NSMutableArray *__si_alert_queue; +static BOOL __si_alert_animating; +static SIAlertBackgroundWindow *__si_alert_background_window; +static SIAlertView *__si_alert_current_view; + +@interface UIWindow (SIAlert_Utils) + +- (UIViewController *)currentViewController; + +@end + +@implementation UIWindow (SIAlert_Utils) + +- (UIViewController *)currentViewController +{ + UIViewController *viewController = self.rootViewController; + while (viewController.presentedViewController) { + viewController = viewController.presentedViewController; + } + return viewController; +} + +@end + +#ifdef __IPHONE_7_0 +@interface UIWindow (SIAlert_StatusBarUtils) + +- (UIViewController *)viewControllerForStatusBarStyle; +- (UIViewController *)viewControllerForStatusBarHidden; + +@end + +@implementation UIWindow (SIAlert_StatusBarUtils) + +- (UIViewController *)viewControllerForStatusBarStyle +{ + UIViewController *currentViewController = [self currentViewController]; + + if ([currentViewController childViewControllerForStatusBarStyle]) { + return [currentViewController childViewControllerForStatusBarStyle]; + } else { + return currentViewController; + } +} + +- (UIViewController *)viewControllerForStatusBarHidden +{ + UIViewController *currentViewController = [self currentViewController]; + + if ([currentViewController childViewControllerForStatusBarHidden]) { + return [currentViewController childViewControllerForStatusBarHidden]; + } else { + return currentViewController; + } +} + +@end +#endif + + +@interface SIAlertView () + +@property (nonatomic, strong) NSMutableArray *items; +@property (nonatomic, weak) UIWindow *oldKeyWindow; +@property (nonatomic, strong) UIWindow *alertWindow; +#ifdef __IPHONE_7_0 +@property (nonatomic, assign) UIViewTintAdjustmentMode oldTintAdjustmentMode; +#endif +@property (nonatomic, assign, getter = isVisible) BOOL visible; + +@property (nonatomic, strong) UILabel *titleLabel; +@property (nonatomic, strong) UILabel *messageLabel; +@property (nonatomic, strong) UIView *containerView; +@property (nonatomic, strong) NSMutableArray *buttons; + +@property (nonatomic, assign, getter = isLayoutDirty) BOOL layoutDirty; + ++ (NSMutableArray *)sharedQueue; ++ (SIAlertView *)currentAlertView; + ++ (BOOL)isAnimating; ++ (void)setAnimating:(BOOL)animating; + ++ (void)showBackground; ++ (void)hideBackgroundAnimated:(BOOL)animated; + +- (void)setup; +- (void)invalidateLayout; +- (void)resetTransition; + +@end + +#pragma mark - SIBackgroundWindow + +@interface SIAlertBackgroundWindow : UIWindow + +@end + +@interface SIAlertBackgroundWindow () + +@property (nonatomic, assign) SIAlertViewBackgroundStyle style; + +@end + +@implementation SIAlertBackgroundWindow + +- (id)initWithFrame:(CGRect)frame andStyle:(SIAlertViewBackgroundStyle)style +{ + self = [super initWithFrame:frame]; + if (self) { + self.style = style; + self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.opaque = NO; + self.windowLevel = UIWindowLevelSIAlertBackground; + } + return self; +} + +- (void)drawRect:(CGRect)rect +{ + CGContextRef context = UIGraphicsGetCurrentContext(); + switch (self.style) { + case SIAlertViewBackgroundStyleGradient: + { + size_t locationsCount = 2; + CGFloat locations[2] = {0.0f, 1.0f}; + CGFloat colors[8] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.75f}; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, colors, locations, locationsCount); + CGColorSpaceRelease(colorSpace); + + CGPoint center = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2); + CGFloat radius = MIN(self.bounds.size.width, self.bounds.size.height) ; + CGContextDrawRadialGradient (context, gradient, center, 0, center, radius, kCGGradientDrawsAfterEndLocation); + CGGradientRelease(gradient); + break; + } + case SIAlertViewBackgroundStyleSolid: + { + [[UIColor colorWithWhite:0 alpha:0.5] set]; + CGContextFillRect(context, self.bounds); + break; + } + } +} + +@end + +#pragma mark - SIAlertItem + +@interface SIAlertItem : NSObject + +@property (nonatomic, copy) NSString *title; +@property (nonatomic, assign) SIAlertViewButtonType type; +@property (nonatomic, copy) SIAlertViewHandler action; + +@end + +@implementation SIAlertItem + +@end + +#pragma mark - SIAlertViewController + +@interface SIAlertViewController : UIViewController + +@property (nonatomic, strong) SIAlertView *alertView; + +@end + +@implementation SIAlertViewController + +#pragma mark - View life cycle + +- (void)loadView +{ + self.view = self.alertView; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + [self.alertView setup]; +} + +- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration +{ + [self.alertView resetTransition]; + [self.alertView invalidateLayout]; +} + +#ifdef __IPHONE_7_0 +- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration +{ + if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { + [self setNeedsStatusBarAppearanceUpdate]; + } +} +#endif + +- (NSUInteger)supportedInterfaceOrientations +{ + UIViewController *viewController = [self.alertView.oldKeyWindow currentViewController]; + if (viewController) { + return [viewController supportedInterfaceOrientations]; + } + return UIInterfaceOrientationMaskAll; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation +{ + UIViewController *viewController = [self.alertView.oldKeyWindow currentViewController]; + if (viewController) { + return [viewController shouldAutorotateToInterfaceOrientation:toInterfaceOrientation]; + } + return YES; +} + +- (BOOL)shouldAutorotate +{ + UIViewController *viewController = [self.alertView.oldKeyWindow currentViewController]; + if (viewController) { + return [viewController shouldAutorotate]; + } + return YES; +} + +#ifdef __IPHONE_7_0 +- (UIStatusBarStyle)preferredStatusBarStyle +{ + UIWindow *window = self.alertView.oldKeyWindow; + if (!window) { + window = [UIApplication sharedApplication].windows[0]; + } + return [[window viewControllerForStatusBarStyle] preferredStatusBarStyle]; +} + +- (BOOL)prefersStatusBarHidden +{ + UIWindow *window = self.alertView.oldKeyWindow; + if (!window) { + window = [UIApplication sharedApplication].windows[0]; + } + return [[window viewControllerForStatusBarHidden] prefersStatusBarHidden]; +} +#endif + +@end + +#pragma mark - SIAlert + +@implementation SIAlertView + ++ (void)initialize +{ + if (self != [SIAlertView class]) + return; + + SIAlertView *appearance = [self appearance]; + appearance.viewBackgroundColor = [UIColor whiteColor]; + appearance.titleColor = [UIColor blackColor]; + appearance.messageColor = [UIColor darkGrayColor]; + appearance.titleFont = [UIFont boldSystemFontOfSize:20]; + appearance.messageFont = [UIFont systemFontOfSize:16]; + appearance.buttonFont = [UIFont systemFontOfSize:[UIFont buttonFontSize]]; + appearance.buttonColor = [UIColor colorWithWhite:0.4 alpha:1]; + appearance.cancelButtonColor = [UIColor colorWithWhite:0.3 alpha:1]; + appearance.destructiveButtonColor = [UIColor whiteColor]; + appearance.cornerRadius = 2; + appearance.shadowRadius = 8; +} + +- (id)init +{ + return [self initWithTitle:nil andMessage:nil]; +} + +- (id)initWithTitle:(NSString *)title andMessage:(NSString *)message +{ + self = [super init]; + if (self) { + _title = title; + _message = message; + self.items = [[NSMutableArray alloc] init]; + } + return self; +} + +#pragma mark - Class methods + ++ (NSMutableArray *)sharedQueue +{ + if (!__si_alert_queue) { + __si_alert_queue = [NSMutableArray array]; + } + return __si_alert_queue; +} + ++ (SIAlertView *)currentAlertView +{ + return __si_alert_current_view; +} + ++ (void)setCurrentAlertView:(SIAlertView *)alertView +{ + __si_alert_current_view = alertView; +} + ++ (BOOL)isAnimating +{ + return __si_alert_animating; +} + ++ (void)setAnimating:(BOOL)animating +{ + __si_alert_animating = animating; +} + ++ (void)showBackground +{ + if (!__si_alert_background_window) { + __si_alert_background_window = [[SIAlertBackgroundWindow alloc] initWithFrame:[UIScreen mainScreen].bounds + andStyle:[SIAlertView currentAlertView].backgroundStyle]; + [__si_alert_background_window makeKeyAndVisible]; + __si_alert_background_window.alpha = 0; + [UIView animateWithDuration:0.3 + animations:^{ + __si_alert_background_window.alpha = 1; + }]; + } +} + ++ (void)hideBackgroundAnimated:(BOOL)animated +{ + if (!animated) { + [__si_alert_background_window removeFromSuperview]; + __si_alert_background_window = nil; + return; + } + [UIView animateWithDuration:0.3 + animations:^{ + __si_alert_background_window.alpha = 0; + } + completion:^(BOOL finished) { + [__si_alert_background_window removeFromSuperview]; + __si_alert_background_window = nil; + }]; +} + +#pragma mark - Setters + +- (void)setTitle:(NSString *)title +{ + _title = title; + [self invalidateLayout]; +} + +- (void)setMessage:(NSString *)message +{ + _message = message; + [self invalidateLayout]; +} + +#pragma mark - Public + +- (void)addButtonWithTitle:(NSString *)title type:(SIAlertViewButtonType)type handler:(SIAlertViewHandler)handler +{ + SIAlertItem *item = [[SIAlertItem alloc] init]; + item.title = title; + item.type = type; + item.action = handler; + [self.items addObject:item]; +} + +- (void)show +{ + if (self.isVisible) { + return; + } + + self.oldKeyWindow = [[UIApplication sharedApplication] keyWindow]; +#ifdef __IPHONE_7_0 + if ([self.oldKeyWindow respondsToSelector:@selector(setTintAdjustmentMode:)]) { // for iOS 7 + self.oldTintAdjustmentMode = self.oldKeyWindow.tintAdjustmentMode; + self.oldKeyWindow.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed; + } +#endif + + if (![[SIAlertView sharedQueue] containsObject:self]) { + [[SIAlertView sharedQueue] addObject:self]; + } + + if ([SIAlertView isAnimating]) { + return; // wait for next turn + } + + if ([SIAlertView currentAlertView].isVisible) { + SIAlertView *alert = [SIAlertView currentAlertView]; + [alert dismissAnimated:YES cleanup:NO]; + return; + } + + if (self.willShowHandler) { + self.willShowHandler(self); + } + [[NSNotificationCenter defaultCenter] postNotificationName:SIAlertViewWillShowNotification object:self userInfo:nil]; + + self.visible = YES; + + [SIAlertView setAnimating:YES]; + [SIAlertView setCurrentAlertView:self]; + + // transition background + [SIAlertView showBackground]; + + SIAlertViewController *viewController = [[SIAlertViewController alloc] initWithNibName:nil bundle:nil]; + viewController.alertView = self; + + if (!self.alertWindow) { + UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + window.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + window.opaque = NO; + window.windowLevel = UIWindowLevelSIAlert; + window.rootViewController = viewController; + self.alertWindow = window; + } + [self.alertWindow makeKeyAndVisible]; + + [self validateLayout]; + + [self transitionInCompletion:^{ + if (self.didShowHandler) { + self.didShowHandler(self); + } + [[NSNotificationCenter defaultCenter] postNotificationName:SIAlertViewDidShowNotification object:self userInfo:nil]; + + [SIAlertView setAnimating:NO]; + + NSInteger index = [[SIAlertView sharedQueue] indexOfObject:self]; + if (index < [SIAlertView sharedQueue].count - 1) { + [self dismissAnimated:YES cleanup:NO]; // dismiss to show next alert view + } + }]; +} + +- (void)dismissAnimated:(BOOL)animated +{ + [self dismissAnimated:animated cleanup:YES]; +} + +- (void)dismissAnimated:(BOOL)animated cleanup:(BOOL)cleanup +{ + BOOL isVisible = self.isVisible; + + if (isVisible) { + if (self.willDismissHandler) { + self.willDismissHandler(self); + } + [[NSNotificationCenter defaultCenter] postNotificationName:SIAlertViewWillDismissNotification object:self userInfo:nil]; + } + + void (^dismissComplete)(void) = ^{ + self.visible = NO; + + [self teardown]; + + [SIAlertView setCurrentAlertView:nil]; + + SIAlertView *nextAlertView; + NSInteger index = [[SIAlertView sharedQueue] indexOfObject:self]; + if (index != NSNotFound && index < [SIAlertView sharedQueue].count - 1) { + nextAlertView = [SIAlertView sharedQueue][index + 1]; + } + + if (cleanup) { + [[SIAlertView sharedQueue] removeObject:self]; + } + + [SIAlertView setAnimating:NO]; + + if (isVisible) { + if (self.didDismissHandler) { + self.didDismissHandler(self); + } + [[NSNotificationCenter defaultCenter] postNotificationName:SIAlertViewDidDismissNotification object:self userInfo:nil]; + } + + // check if we should show next alert + if (!isVisible) { + return; + } + + if (nextAlertView) { + [nextAlertView show]; + } else { + // show last alert view + if ([SIAlertView sharedQueue].count > 0) { + SIAlertView *alert = [[SIAlertView sharedQueue] lastObject]; + [alert show]; + } + } + }; + + if (animated && isVisible) { + [SIAlertView setAnimating:YES]; + [self transitionOutCompletion:dismissComplete]; + + if ([SIAlertView sharedQueue].count == 1) { + [SIAlertView hideBackgroundAnimated:YES]; + } + + } else { + dismissComplete(); + + if ([SIAlertView sharedQueue].count == 0) { + [SIAlertView hideBackgroundAnimated:YES]; + } + } + + UIWindow *window = self.oldKeyWindow; +#ifdef __IPHONE_7_0 + if ([window respondsToSelector:@selector(setTintAdjustmentMode:)]) { + window.tintAdjustmentMode = self.oldTintAdjustmentMode; + } +#endif + if (!window) { + window = [UIApplication sharedApplication].windows[0]; + } + [window makeKeyWindow]; + window.hidden = NO; +} + +#pragma mark - Transitions + +- (void)transitionInCompletion:(void(^)(void))completion +{ + switch (self.transitionStyle) { + case SIAlertViewTransitionStyleSlideFromBottom: + { + CGRect rect = self.containerView.frame; + CGRect originalRect = rect; + rect.origin.y = self.bounds.size.height; + self.containerView.frame = rect; + [UIView animateWithDuration:0.3 + animations:^{ + self.containerView.frame = originalRect; + } + completion:^(BOOL finished) { + if (completion) { + completion(); + } + }]; + } + break; + case SIAlertViewTransitionStyleSlideFromTop: + { + CGRect rect = self.containerView.frame; + CGRect originalRect = rect; + rect.origin.y = -rect.size.height; + self.containerView.frame = rect; + [UIView animateWithDuration:0.3 + animations:^{ + self.containerView.frame = originalRect; + } + completion:^(BOOL finished) { + if (completion) { + completion(); + } + }]; + } + break; + case SIAlertViewTransitionStyleFade: + { + self.containerView.alpha = 0; + [UIView animateWithDuration:0.3 + animations:^{ + self.containerView.alpha = 1; + } + completion:^(BOOL finished) { + if (completion) { + completion(); + } + }]; + } + break; + case SIAlertViewTransitionStyleBounce: + { + CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; + animation.values = @[@(0.01), @(1.2), @(0.9), @(1)]; + animation.keyTimes = @[@(0), @(0.4), @(0.6), @(1)]; + animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; + animation.duration = 0.5; + animation.delegate = self; + [animation setValue:completion forKey:@"handler"]; + [self.containerView.layer addAnimation:animation forKey:@"bouce"]; + } + break; + case SIAlertViewTransitionStyleDropDown: + { + CGFloat y = self.containerView.center.y; + CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.y"]; + animation.values = @[@(y - self.bounds.size.height), @(y + 20), @(y - 10), @(y)]; + animation.keyTimes = @[@(0), @(0.5), @(0.75), @(1)]; + animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; + animation.duration = 0.4; + animation.delegate = self; + [animation setValue:completion forKey:@"handler"]; + [self.containerView.layer addAnimation:animation forKey:@"dropdown"]; + } + break; + default: + break; + } +} + +- (void)transitionOutCompletion:(void(^)(void))completion +{ + switch (self.transitionStyle) { + case SIAlertViewTransitionStyleSlideFromBottom: + { + CGRect rect = self.containerView.frame; + rect.origin.y = self.bounds.size.height; + [UIView animateWithDuration:0.3 + delay:0 + options:UIViewAnimationOptionCurveEaseIn + animations:^{ + self.containerView.frame = rect; + } + completion:^(BOOL finished) { + if (completion) { + completion(); + } + }]; + } + break; + case SIAlertViewTransitionStyleSlideFromTop: + { + CGRect rect = self.containerView.frame; + rect.origin.y = -rect.size.height; + [UIView animateWithDuration:0.3 + delay:0 + options:UIViewAnimationOptionCurveEaseIn + animations:^{ + self.containerView.frame = rect; + } + completion:^(BOOL finished) { + if (completion) { + completion(); + } + }]; + } + break; + case SIAlertViewTransitionStyleFade: + { + [UIView animateWithDuration:0.25 + animations:^{ + self.containerView.alpha = 0; + } + completion:^(BOOL finished) { + if (completion) { + completion(); + } + }]; + } + break; + case SIAlertViewTransitionStyleBounce: + { + CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; + animation.values = @[@(1), @(1.2), @(0.01)]; + animation.keyTimes = @[@(0), @(0.4), @(1)]; + animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; + animation.duration = 0.35; + animation.delegate = self; + [animation setValue:completion forKey:@"handler"]; + [self.containerView.layer addAnimation:animation forKey:@"bounce"]; + + self.containerView.transform = CGAffineTransformMakeScale(0.01, 0.01); + } + break; + case SIAlertViewTransitionStyleDropDown: + { + CGPoint point = self.containerView.center; + point.y += self.bounds.size.height; + [UIView animateWithDuration:0.3 + delay:0 + options:UIViewAnimationOptionCurveEaseIn + animations:^{ + self.containerView.center = point; + CGFloat angle = ((CGFloat)arc4random_uniform(100) - 50.f) / 100.f; + self.containerView.transform = CGAffineTransformMakeRotation(angle); + } + completion:^(BOOL finished) { + if (completion) { + completion(); + } + }]; + } + break; + default: + break; + } +} + +- (void)resetTransition +{ + [self.containerView.layer removeAllAnimations]; +} + +#pragma mark - Layout + +- (void)layoutSubviews +{ + [super layoutSubviews]; + [self validateLayout]; +} + +- (void)invalidateLayout +{ + self.layoutDirty = YES; + [self setNeedsLayout]; +} + +- (void)validateLayout +{ + if (!self.isLayoutDirty) { + return; + } + self.layoutDirty = NO; +#if DEBUG_LAYOUT + NSLog(@"%@, %@", self, NSStringFromSelector(_cmd)); +#endif + + CGFloat height = [self preferredHeight]; + CGFloat left = (self.bounds.size.width - CONTAINER_WIDTH) * 0.5; + CGFloat top = (self.bounds.size.height - height) * 0.5; + self.containerView.transform = CGAffineTransformIdentity; + self.containerView.frame = CGRectMake(left, top, CONTAINER_WIDTH, height); + self.containerView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.containerView.bounds cornerRadius:self.containerView.layer.cornerRadius].CGPath; + + CGFloat y = CONTENT_PADDING_TOP; + if (self.titleLabel) { + self.titleLabel.text = self.title; + CGFloat height = [self heightForTitleLabel]; + self.titleLabel.frame = CGRectMake(CONTENT_PADDING_LEFT, y, self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2, height); + y += height; + } + if (self.messageLabel) { + if (y > CONTENT_PADDING_TOP) { + y += GAP; + } + self.messageLabel.text = self.message; + CGFloat height = [self heightForMessageLabel]; + self.messageLabel.frame = CGRectMake(CONTENT_PADDING_LEFT, y, self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2, height); + y += height; + } + if (self.items.count > 0) { + if (y > CONTENT_PADDING_TOP) { + y += GAP; + } + if (self.items.count == 2 && self.buttonsListStyle == SIAlertViewButtonsListStyleNormal) { + CGFloat width = (self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2 - GAP) * 0.5; + UIButton *button = self.buttons[0]; + button.frame = CGRectMake(CONTENT_PADDING_LEFT, y, width, BUTTON_HEIGHT); + button = self.buttons[1]; + button.frame = CGRectMake(CONTENT_PADDING_LEFT + width + GAP, y, width, BUTTON_HEIGHT); + } else { + for (NSUInteger i = 0; i < self.buttons.count; i++) { + UIButton *button = self.buttons[i]; + button.frame = CGRectMake(CONTENT_PADDING_LEFT, y, self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2, BUTTON_HEIGHT); + if (self.buttons.count > 1) { + if (i == self.buttons.count - 1 && ((SIAlertItem *)self.items[i]).type == SIAlertViewButtonTypeCancel) { + CGRect rect = button.frame; + rect.origin.y += CANCEL_BUTTON_PADDING_TOP; + button.frame = rect; + } + y += BUTTON_HEIGHT + GAP; + } + } + } + } +} + +- (CGFloat)preferredHeight +{ + CGFloat height = CONTENT_PADDING_TOP; + if (self.title) { + height += [self heightForTitleLabel]; + } + if (self.message) { + if (height > CONTENT_PADDING_TOP) { + height += GAP; + } + height += [self heightForMessageLabel]; + } + if (self.items.count > 0) { + if (height > CONTENT_PADDING_TOP) { + height += GAP; + } + if (self.items.count <= 2 && self.buttonsListStyle == SIAlertViewButtonsListStyleNormal) { + height += BUTTON_HEIGHT; + } else { + height += (BUTTON_HEIGHT + GAP) * self.items.count - GAP; + if (self.buttons.count > 2 && ((SIAlertItem *)[self.items lastObject]).type == SIAlertViewButtonTypeCancel) { + height += CANCEL_BUTTON_PADDING_TOP; + } + } + } + height += CONTENT_PADDING_BOTTOM; + return height; +} + +- (CGFloat)heightForTitleLabel +{ + if (self.titleLabel) { + CGSize size = [self.title sizeWithFont:self.titleLabel.font + minFontSize: +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0 + self.titleLabel.font.pointSize * self.titleLabel.minimumScaleFactor +#else + self.titleLabel.minimumFontSize +#endif + actualFontSize:nil + forWidth:CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2 + lineBreakMode:self.titleLabel.lineBreakMode]; + return size.height; + } + return 0; +} + +- (CGFloat)heightForMessageLabel +{ + CGFloat minHeight = MESSAGE_MIN_LINE_COUNT * self.messageLabel.font.lineHeight; + if (self.messageLabel) { + CGFloat maxHeight = MESSAGE_MAX_LINE_COUNT * self.messageLabel.font.lineHeight; + CGSize size = [self.message sizeWithFont:self.messageLabel.font + constrainedToSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, maxHeight) + lineBreakMode:self.messageLabel.lineBreakMode]; + return MAX(minHeight, size.height); + } + return minHeight; +} + +#pragma mark - Setup + +- (void)setup +{ + [self setupContainerView]; + [self updateTitleLabel]; + [self updateMessageLabel]; + [self setupButtons]; + [self invalidateLayout]; +} + +- (void)teardown +{ + [self.containerView removeFromSuperview]; + self.containerView = nil; + self.titleLabel = nil; + self.messageLabel = nil; + [self.buttons removeAllObjects]; + [self.alertWindow removeFromSuperview]; + self.alertWindow = nil; + self.layoutDirty = NO; +} + +- (void)setupContainerView +{ + self.containerView = [[UIView alloc] initWithFrame:self.bounds]; + self.containerView.backgroundColor = _viewBackgroundColor ? _viewBackgroundColor : [UIColor whiteColor]; + self.containerView.layer.cornerRadius = self.cornerRadius; + self.containerView.layer.shadowOffset = CGSizeZero; + self.containerView.layer.shadowRadius = self.shadowRadius; + self.containerView.layer.shadowOpacity = 0.5; + [self addSubview:self.containerView]; +} + +- (void)updateTitleLabel +{ + if (self.title) { + if (!self.titleLabel) { + self.titleLabel = [[UILabel alloc] initWithFrame:self.bounds]; + self.titleLabel.textAlignment = NSTextAlignmentCenter; + self.titleLabel.backgroundColor = [UIColor clearColor]; + self.titleLabel.font = self.titleFont; + self.titleLabel.textColor = self.titleColor; + self.titleLabel.adjustsFontSizeToFitWidth = YES; +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0 + self.titleLabel.minimumScaleFactor = 0.75; +#else + self.titleLabel.minimumFontSize = self.titleLabel.font.pointSize * 0.75; +#endif + [self.containerView addSubview:self.titleLabel]; +#if DEBUG_LAYOUT + self.titleLabel.backgroundColor = [UIColor redColor]; +#endif + } + self.titleLabel.text = self.title; + } else { + [self.titleLabel removeFromSuperview]; + self.titleLabel = nil; + } + [self invalidateLayout]; +} + +- (void)updateMessageLabel +{ + if (self.message) { + if (!self.messageLabel) { + self.messageLabel = [[UILabel alloc] initWithFrame:self.bounds]; + self.messageLabel.textAlignment = NSTextAlignmentCenter; + self.messageLabel.backgroundColor = [UIColor clearColor]; + self.messageLabel.font = self.messageFont; + self.messageLabel.textColor = self.messageColor; + self.messageLabel.numberOfLines = MESSAGE_MAX_LINE_COUNT; + [self.containerView addSubview:self.messageLabel]; +#if DEBUG_LAYOUT + self.messageLabel.backgroundColor = [UIColor redColor]; +#endif + } + self.messageLabel.text = self.message; + } else { + [self.messageLabel removeFromSuperview]; + self.messageLabel = nil; + } + [self invalidateLayout]; +} + +- (void)setupButtons +{ + self.buttons = [[NSMutableArray alloc] initWithCapacity:self.items.count]; + for (NSUInteger i = 0; i < self.items.count; i++) { + UIButton *button = [self buttonForItemIndex:i]; + [self.buttons addObject:button]; + [self.containerView addSubview:button]; + } +} + +- (UIButton *)buttonForItemIndex:(NSUInteger)index +{ + SIAlertItem *item = self.items[index]; + UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; + button.tag = index; + button.autoresizingMask = UIViewAutoresizingFlexibleWidth; + button.titleLabel.font = self.buttonFont; + [button setTitle:item.title forState:UIControlStateNormal]; + UIImage *normalImage = nil; + UIImage *highlightedImage = nil; + switch (item.type) { + case SIAlertViewButtonTypeCancel: + normalImage = [UIImage imageNamed:@"SIAlertView.bundle/button-cancel"]; + highlightedImage = [UIImage imageNamed:@"SIAlertView.bundle/button-cancel-d"]; + [button setTitleColor:self.cancelButtonColor forState:UIControlStateNormal]; + [button setTitleColor:[self.cancelButtonColor colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; + break; + case SIAlertViewButtonTypeDestructive: + normalImage = [UIImage imageNamed:@"SIAlertView.bundle/button-destructive"]; + highlightedImage = [UIImage imageNamed:@"SIAlertView.bundle/button-destructive-d"]; + [button setTitleColor:self.destructiveButtonColor forState:UIControlStateNormal]; + [button setTitleColor:[self.destructiveButtonColor colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; + break; + case SIAlertViewButtonTypeDefault: + default: + normalImage = [UIImage imageNamed:@"SIAlertView.bundle/button-default"]; + highlightedImage = [UIImage imageNamed:@"SIAlertView.bundle/button-default-d"]; + [button setTitleColor:self.buttonColor forState:UIControlStateNormal]; + [button setTitleColor:[self.buttonColor colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; + break; + } + CGFloat hInset = floorf(normalImage.size.width / 2); + CGFloat vInset = floorf(normalImage.size.height / 2); + UIEdgeInsets insets = UIEdgeInsetsMake(vInset, hInset, vInset, hInset); + normalImage = [normalImage resizableImageWithCapInsets:insets]; + highlightedImage = [highlightedImage resizableImageWithCapInsets:insets]; + [button setBackgroundImage:normalImage forState:UIControlStateNormal]; + [button setBackgroundImage:highlightedImage forState:UIControlStateHighlighted]; + [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; + + return button; +} + +#pragma mark - Actions + +- (void)buttonAction:(UIButton *)button +{ + [SIAlertView setAnimating:YES]; // set this flag to YES in order to prevent showing another alert in action block + SIAlertItem *item = self.items[button.tag]; + if (item.action) { + item.action(self); + } + [self dismissAnimated:YES]; +} + +#pragma mark - CAAnimation delegate + +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag +{ + void(^completion)(void) = [anim valueForKey:@"handler"]; + if (completion) { + completion(); + } +} + +#pragma mark - UIAppearance setters + +- (void)setViewBackgroundColor:(UIColor *)viewBackgroundColor +{ + if (_viewBackgroundColor == viewBackgroundColor) { + return; + } + _viewBackgroundColor = viewBackgroundColor; + self.containerView.backgroundColor = viewBackgroundColor; +} + +- (void)setTitleFont:(UIFont *)titleFont +{ + if (_titleFont == titleFont) { + return; + } + _titleFont = titleFont; + self.titleLabel.font = titleFont; + [self invalidateLayout]; +} + +- (void)setMessageFont:(UIFont *)messageFont +{ + if (_messageFont == messageFont) { + return; + } + _messageFont = messageFont; + self.messageLabel.font = messageFont; + [self invalidateLayout]; +} + +- (void)setTitleColor:(UIColor *)titleColor +{ + if (_titleColor == titleColor) { + return; + } + _titleColor = titleColor; + self.titleLabel.textColor = titleColor; +} + +- (void)setMessageColor:(UIColor *)messageColor +{ + if (_messageColor == messageColor) { + return; + } + _messageColor = messageColor; + self.messageLabel.textColor = messageColor; +} + +- (void)setButtonFont:(UIFont *)buttonFont +{ + if (_buttonFont == buttonFont) { + return; + } + _buttonFont = buttonFont; + for (UIButton *button in self.buttons) { + button.titleLabel.font = buttonFont; + } +} + +- (void)setCornerRadius:(CGFloat)cornerRadius +{ + if (_cornerRadius == cornerRadius) { + return; + } + _cornerRadius = cornerRadius; + self.containerView.layer.cornerRadius = cornerRadius; +} + +- (void)setShadowRadius:(CGFloat)shadowRadius +{ + if (_shadowRadius == shadowRadius) { + return; + } + _shadowRadius = shadowRadius; + self.containerView.layer.shadowRadius = shadowRadius; +} + +- (void)setButtonColor:(UIColor *)buttonColor +{ + if (_buttonColor == buttonColor) { + return; + } + _buttonColor = buttonColor; + [self setColor:buttonColor toButtonsOfType:SIAlertViewButtonTypeDefault]; +} + +- (void)setCancelButtonColor:(UIColor *)buttonColor +{ + if (_cancelButtonColor == buttonColor) { + return; + } + _cancelButtonColor = buttonColor; + [self setColor:buttonColor toButtonsOfType:SIAlertViewButtonTypeCancel]; +} + +- (void)setDestructiveButtonColor:(UIColor *)buttonColor +{ + if (_destructiveButtonColor == buttonColor) { + return; + } + _destructiveButtonColor = buttonColor; + [self setColor:buttonColor toButtonsOfType:SIAlertViewButtonTypeDestructive]; +} + + +- (void)setDefaultButtonImage:(UIImage *)defaultButtonImage forState:(UIControlState)state +{ + [self setButtonImage:defaultButtonImage forState:state andButtonType:SIAlertViewButtonTypeDefault]; +} + + +- (void)setCancelButtonImage:(UIImage *)cancelButtonImage forState:(UIControlState)state +{ + [self setButtonImage:cancelButtonImage forState:state andButtonType:SIAlertViewButtonTypeCancel]; +} + + +- (void)setDestructiveButtonImage:(UIImage *)destructiveButtonImage forState:(UIControlState)state +{ + [self setButtonImage:destructiveButtonImage forState:state andButtonType:SIAlertViewButtonTypeDestructive]; +} + + +- (void)setButtonImage:(UIImage *)image forState:(UIControlState)state andButtonType:(SIAlertViewButtonType)type +{ + for (NSUInteger i = 0; i < self.items.count; i++) + { + SIAlertItem *item = self.items[i]; + if(item.type == type) + { + UIButton *button = self.buttons[i]; + [button setBackgroundImage:image forState:state]; + } + } +} + + +-(void)setColor:(UIColor *)color toButtonsOfType:(SIAlertViewButtonType)type { + for (NSUInteger i = 0; i < self.items.count; i++) { + SIAlertItem *item = self.items[i]; + if(item.type == type) { + UIButton *button = self.buttons[i]; + [button setTitleColor:color forState:UIControlStateNormal]; + [button setTitleColor:[color colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; + } + } +} + +@end diff --git a/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m new file mode 100644 index 0000000..6a29cf8 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_AFNetworking : NSObject +@end +@implementation PodsDummy_AFNetworking +@end diff --git a/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch new file mode 100644 index 0000000..b52cf0d --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch @@ -0,0 +1,15 @@ +#ifdef __OBJC__ +#import +#endif + +#ifndef TARGET_OS_IOS + #define TARGET_OS_IOS TARGET_OS_IPHONE +#endif + +#ifndef TARGET_OS_WATCH + #define TARGET_OS_WATCH 0 +#endif + +#ifndef TARGET_OS_TV + #define TARGET_OS_TV 0 +#endif diff --git a/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h new file mode 100644 index 0000000..a0f6f34 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h @@ -0,0 +1,24 @@ +#import + +#import "AFNetworking.h" +#import "AFHTTPSessionManager.h" +#import "AFURLSessionManager.h" +#import "AFNetworkReachabilityManager.h" +#import "AFSecurityPolicy.h" +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" +#import "AFAutoPurgingImageCache.h" +#import "AFImageDownloader.h" +#import "AFNetworkActivityIndicatorManager.h" +#import "UIActivityIndicatorView+AFNetworking.h" +#import "UIButton+AFNetworking.h" +#import "UIImage+AFNetworking.h" +#import "UIImageView+AFNetworking.h" +#import "UIKit+AFNetworking.h" +#import "UIProgressView+AFNetworking.h" +#import "UIRefreshControl+AFNetworking.h" +#import "UIWebView+AFNetworking.h" + +FOUNDATION_EXPORT double AFNetworkingVersionNumber; +FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[]; + diff --git a/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking.modulemap b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking.modulemap new file mode 100644 index 0000000..5892cd3 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking.modulemap @@ -0,0 +1,6 @@ +framework module AFNetworking { + umbrella header "AFNetworking-umbrella.h" + + export * + module * { export * } +} diff --git a/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig new file mode 100644 index 0000000..95fce75 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" +OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/HeadsUpper/Pods/Target Support Files/AFNetworking/Info.plist b/HeadsUpper/Pods/Target Support Files/AFNetworking/Info.plist new file mode 100644 index 0000000..c8db180 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/AFNetworking/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.0.4 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework-dummy.m b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework-dummy.m new file mode 100644 index 0000000..1fd1a46 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_ChameleonFramework : NSObject +@end +@implementation PodsDummy_ChameleonFramework +@end diff --git a/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework-prefix.pch b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework-umbrella.h b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework-umbrella.h new file mode 100644 index 0000000..45275dd --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework-umbrella.h @@ -0,0 +1,36 @@ +#import + +#import "Chameleon.h" +#import "Chameleon_.h" +#import "ChameleonConstants.h" +#import "ChameleonEnums.h" +#import "ChameleonMacros.h" +#import "NSArray+Chameleon.h" +#import "UIAppearance+Swift.h" +#import "UIButton+Chameleon.h" +#import "UIColor+Chameleon.h" +#import "UIColor+ChameleonPrivate.h" +#import "UIImage+ChameleonPrivate.h" +#import "UILabel+Chameleon.h" +#import "UINavigationController+Chameleon.h" +#import "UIView+ChameleonPrivate.h" +#import "UIViewController+Chameleon.h" +#import "Chameleon.h" +#import "Chameleon_.h" +#import "ChameleonConstants.h" +#import "ChameleonEnums.h" +#import "ChameleonMacros.h" +#import "NSArray+Chameleon.h" +#import "UIAppearance+Swift.h" +#import "UIButton+Chameleon.h" +#import "UIColor+Chameleon.h" +#import "UIColor+ChameleonPrivate.h" +#import "UIImage+ChameleonPrivate.h" +#import "UILabel+Chameleon.h" +#import "UINavigationController+Chameleon.h" +#import "UIView+ChameleonPrivate.h" +#import "UIViewController+Chameleon.h" + +FOUNDATION_EXPORT double ChameleonFrameworkVersionNumber; +FOUNDATION_EXPORT const unsigned char ChameleonFrameworkVersionString[]; + diff --git a/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework.modulemap b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework.modulemap new file mode 100644 index 0000000..d60f497 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework.modulemap @@ -0,0 +1,6 @@ +framework module ChameleonFramework { + umbrella header "ChameleonFramework-umbrella.h" + + export * + module * { export * } +} diff --git a/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework.xcconfig b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework.xcconfig new file mode 100644 index 0000000..bf6bd2b --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/ChameleonFramework.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/ChameleonFramework" "${PODS_ROOT}/Headers/Public" +OTHER_LDFLAGS = -framework "CoreGraphics" -framework "QuartzCore" -framework "UIKit" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/HeadsUpper/Pods/Target Support Files/ChameleonFramework/Info.plist b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/Info.plist new file mode 100644 index 0000000..7ecddcc --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/ChameleonFramework/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 + 2.1.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/HeadsUpper/Pods/Target Support Files/Pods/Info.plist b/HeadsUpper/Pods/Target Support Files/Pods/Info.plist new file mode 100644 index 0000000..6974542 --- /dev/null +++ b/HeadsUpper/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/HeadsUpper/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown b/HeadsUpper/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown new file mode 100644 index 0000000..53df0ea --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown @@ -0,0 +1,85 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## AFNetworking + +Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) + +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. + + +## ChameleonFramework + +##The MIT License (MIT) + +> Copyright (c) 2014-2015 Vicc Alexander + +> 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. + + +## SDWebImage + +Copyright (c) 2009 Olivier Poitrey + +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. + + + +## SIAlertView + +Copyright (c) 2013 Sumi Interactive + +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. +Generated by CocoaPods - http://cocoapods.org diff --git a/HeadsUpper/Pods/Target Support Files/Pods/Pods-acknowledgements.plist b/HeadsUpper/Pods/Target Support Files/Pods/Pods-acknowledgements.plist new file mode 100644 index 0000000..32c39e4 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/Pods/Pods-acknowledgements.plist @@ -0,0 +1,127 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) + +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. + + Title + AFNetworking + Type + PSGroupSpecifier + + + FooterText + ##The MIT License (MIT) + +> Copyright (c) 2014-2015 Vicc Alexander + +> 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. + + Title + ChameleonFramework + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2009 Olivier Poitrey <rs@dailymotion.com> + +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. + + + Title + SDWebImage + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2013 Sumi Interactive + +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. + Title + SIAlertView + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - http://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/HeadsUpper/Pods/Target Support Files/Pods/Pods-dummy.m b/HeadsUpper/Pods/Target Support Files/Pods/Pods-dummy.m new file mode 100644 index 0000000..ade64bd --- /dev/null +++ b/HeadsUpper/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/HeadsUpper/Pods/Target Support Files/Pods/Pods-frameworks.sh b/HeadsUpper/Pods/Target Support Files/Pods/Pods-frameworks.sh new file mode 100755 index 0000000..88c948b --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/Pods/Pods-frameworks.sh @@ -0,0 +1,97 @@ +#!/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/AFNetworking.framework" + install_framework "Pods/ChameleonFramework.framework" + install_framework "Pods/SDWebImage.framework" + install_framework "Pods/SIAlertView.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "Pods/AFNetworking.framework" + install_framework "Pods/ChameleonFramework.framework" + install_framework "Pods/SDWebImage.framework" + install_framework "Pods/SIAlertView.framework" +fi diff --git a/HeadsUpper/Pods/Target Support Files/Pods/Pods-resources.sh b/HeadsUpper/Pods/Target Support Files/Pods/Pods-resources.sh new file mode 100755 index 0000000..16774fb --- /dev/null +++ b/HeadsUpper/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/HeadsUpper/Pods/Target Support Files/Pods/Pods-umbrella.h b/HeadsUpper/Pods/Target Support Files/Pods/Pods-umbrella.h new file mode 100644 index 0000000..21dcfd2 --- /dev/null +++ b/HeadsUpper/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/HeadsUpper/Pods/Target Support Files/Pods/Pods.debug.xcconfig b/HeadsUpper/Pods/Target Support Files/Pods/Pods.debug.xcconfig new file mode 100644 index 0000000..c64fc47 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/Pods/Pods.debug.xcconfig @@ -0,0 +1,6 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/AFNetworking.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/ChameleonFramework.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/SDWebImage.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/SIAlertView.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "ChameleonFramework" -framework "SDWebImage" -framework "SIAlertView" +PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/HeadsUpper/Pods/Target Support Files/Pods/Pods.modulemap b/HeadsUpper/Pods/Target Support Files/Pods/Pods.modulemap new file mode 100644 index 0000000..8413413 --- /dev/null +++ b/HeadsUpper/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/HeadsUpper/Pods/Target Support Files/Pods/Pods.release.xcconfig b/HeadsUpper/Pods/Target Support Files/Pods/Pods.release.xcconfig new file mode 100644 index 0000000..c64fc47 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/Pods/Pods.release.xcconfig @@ -0,0 +1,6 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/AFNetworking.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/ChameleonFramework.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/SDWebImage.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/SIAlertView.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "ChameleonFramework" -framework "SDWebImage" -framework "SIAlertView" +PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/HeadsUpper/Pods/Target Support Files/SDWebImage/Info.plist b/HeadsUpper/Pods/Target Support Files/SDWebImage/Info.plist new file mode 100644 index 0000000..b4f3b3b --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SDWebImage/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.7.5 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m new file mode 100644 index 0000000..86d2b5f --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_SDWebImage : NSObject +@end +@implementation PodsDummy_SDWebImage +@end diff --git a/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h new file mode 100644 index 0000000..5a051dd --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h @@ -0,0 +1,21 @@ +#import + +#import "NSData+ImageContentType.h" +#import "SDImageCache.h" +#import "SDWebImageCompat.h" +#import "SDWebImageDecoder.h" +#import "SDWebImageDownloader.h" +#import "SDWebImageDownloaderOperation.h" +#import "SDWebImageManager.h" +#import "SDWebImageOperation.h" +#import "SDWebImagePrefetcher.h" +#import "UIButton+WebCache.h" +#import "UIImage+GIF.h" +#import "UIImage+MultiFormat.h" +#import "UIImageView+HighlightedWebCache.h" +#import "UIImageView+WebCache.h" +#import "UIView+WebCacheOperation.h" + +FOUNDATION_EXPORT double SDWebImageVersionNumber; +FOUNDATION_EXPORT const unsigned char SDWebImageVersionString[]; + diff --git a/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage.modulemap b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage.modulemap new file mode 100644 index 0000000..91545be --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage.modulemap @@ -0,0 +1,6 @@ +framework module SDWebImage { + umbrella header "SDWebImage-umbrella.h" + + export * + module * { export * } +} diff --git a/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig new file mode 100644 index 0000000..5e7aea2 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SDWebImage" "${PODS_ROOT}/Headers/Public" +OTHER_LDFLAGS = -framework "ImageIO" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/HeadsUpper/Pods/Target Support Files/SIAlertView/Info.plist b/HeadsUpper/Pods/Target Support Files/SIAlertView/Info.plist new file mode 100644 index 0000000..e39a666 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SIAlertView/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.3 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView-dummy.m b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView-dummy.m new file mode 100644 index 0000000..d010881 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_SIAlertView : NSObject +@end +@implementation PodsDummy_SIAlertView +@end diff --git a/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView-prefix.pch b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView-umbrella.h b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView-umbrella.h new file mode 100644 index 0000000..ce1683b --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView-umbrella.h @@ -0,0 +1,7 @@ +#import + +#import "SIAlertView.h" + +FOUNDATION_EXPORT double SIAlertViewVersionNumber; +FOUNDATION_EXPORT const unsigned char SIAlertViewVersionString[]; + diff --git a/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView.modulemap b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView.modulemap new file mode 100644 index 0000000..2e0cf6c --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView.modulemap @@ -0,0 +1,6 @@ +framework module SIAlertView { + umbrella header "SIAlertView-umbrella.h" + + export * + module * { export * } +} diff --git a/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView.xcconfig b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView.xcconfig new file mode 100644 index 0000000..e6f7882 --- /dev/null +++ b/HeadsUpper/Pods/Target Support Files/SIAlertView/SIAlertView.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SIAlertView" "${PODS_ROOT}/Headers/Public" +OTHER_LDFLAGS = -framework "QuartzCore" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file