├── Example ├── en.lproj │ ├── InfoPlist.strings │ └── ViewController.xib ├── Default.png ├── Default@2x.png ├── Default-568h@2x.png ├── img-placeholder.png ├── main.m ├── AFProgressiveImageDownload-Prefix.pch ├── AFAppDelegate.h ├── ViewController.h ├── AFProgressiveImageDownload-Info.plist ├── AFAppDelegate.m └── ViewController.m ├── Pods ├── Headers │ └── AFNetworking │ │ ├── AFHTTPClient.h │ │ ├── AFNetworking.h │ │ ├── AFHTTPRequestOperation.h │ │ ├── AFImageRequestOperation.h │ │ ├── AFJSONRequestOperation.h │ │ ├── AFXMLRequestOperation.h │ │ ├── AFURLConnectionOperation.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── AFPropertyListRequestOperation.h │ │ └── AFNetworkActivityIndicatorManager.h ├── BuildHeaders │ └── AFNetworking │ │ ├── AFHTTPClient.h │ │ ├── AFNetworking.h │ │ ├── AFHTTPRequestOperation.h │ │ ├── AFImageRequestOperation.h │ │ ├── AFJSONRequestOperation.h │ │ ├── AFXMLRequestOperation.h │ │ ├── AFURLConnectionOperation.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── AFPropertyListRequestOperation.h │ │ └── AFNetworkActivityIndicatorManager.h ├── Pods-dummy.m ├── Manifest.lock ├── Pods-environment.h ├── Pods-prefix.pch ├── Pods.xcconfig ├── AFNetworking │ ├── LICENSE │ ├── AFNetworking │ │ ├── AFNetworking.h │ │ ├── AFPropertyListRequestOperation.h │ │ ├── AFJSONRequestOperation.h │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFXMLRequestOperation.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── AFPropertyListRequestOperation.m │ │ ├── AFNetworkActivityIndicatorManager.m │ │ ├── AFImageRequestOperation.h │ │ ├── AFHTTPRequestOperation.h │ │ ├── AFJSONRequestOperation.m │ │ ├── AFXMLRequestOperation.m │ │ ├── UIImageView+AFNetworking.m │ │ ├── AFImageRequestOperation.m │ │ ├── AFHTTPRequestOperation.m │ │ └── AFURLConnectionOperation.h │ └── README.md ├── Pods-acknowledgements.markdown ├── Pods-resources.sh └── Pods-acknowledgements.plist ├── Podfile ├── Podfile.lock ├── .gitignore ├── AFProgressiveImageDownload.xcworkspace └── contents.xcworkspacedata ├── AFProgressiveImageDownload ├── UIImageView+AFProgressiveImageDownload.h └── UIImageView+AFProgressiveImageDownload.m ├── AFProgressiveImageDownload.podspec ├── LICENSE ├── README.md └── AFProgressiveImageDownload.xcodeproj └── project.pbxproj /Example/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFHTTPClient.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPClient.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFHTTPClient.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPClient.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '6.0' 2 | target 'AFProgressiveImageDownload' do 3 | pod 'AFNetworking' 4 | end 5 | -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFImageRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFImageRequestOperation.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFJSONRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFJSONRequestOperation.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFXMLRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFXMLRequestOperation.h -------------------------------------------------------------------------------- /Example/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subdigital/AFProgressiveImageDownload/HEAD/Example/Default.png -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFImageRequestOperation.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFJSONRequestOperation.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFXMLRequestOperation.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFURLConnectionOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLConnectionOperation.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Example/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subdigital/AFProgressiveImageDownload/HEAD/Example/Default@2x.png -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLConnectionOperation.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFPropertyListRequestOperation.h -------------------------------------------------------------------------------- /Example/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subdigital/AFProgressiveImageDownload/HEAD/Example/Default-568h@2x.png -------------------------------------------------------------------------------- /Example/img-placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subdigital/AFProgressiveImageDownload/HEAD/Example/img-placeholder.png -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFPropertyListRequestOperation.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/Pods-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods : NSObject 3 | @end 4 | @implementation PodsDummy_Pods 5 | @end 6 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (1.3.1) 3 | 4 | DEPENDENCIES: 5 | - AFNetworking 6 | 7 | SPEC CHECKSUMS: 8 | AFNetworking: 9ec8aafb9269236a7630bd8d9838ce2ba30fa2a0 9 | 10 | COCOAPODS: 0.20.2 11 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (1.3.1) 3 | 4 | DEPENDENCIES: 5 | - AFNetworking 6 | 7 | SPEC CHECKSUMS: 8 | AFNetworking: 9ec8aafb9269236a7630bd8d9838ce2ba30fa2a0 9 | 10 | COCOAPODS: 0.20.2 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *~ 4 | *~.nib 5 | *.orig 6 | build/ 7 | 8 | *.pbxuser 9 | *.perspective 10 | *.perspectivev3 11 | *.mode1v3 12 | *.mode2v3 13 | xcuserdata 14 | project.xcworkspace 15 | .idea 16 | pkg 17 | build.output 18 | -------------------------------------------------------------------------------- /AFProgressiveImageDownload.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Example/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AFProgressImageDownload 4 | // 5 | // Created by ben on 6/29/13. 6 | // Copyright (c) 2013 Fickle Bits. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AFAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AFAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/AFProgressiveImageDownload-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'AFProgressImageDownload' target in the 'AFProgressImageDownload' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /Example/AFAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFAppDelegate.h 3 | // AFProgressImageDownload 4 | // 5 | // Created by ben on 6/29/13. 6 | // Copyright (c) 2013 Fickle Bits. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ViewController; 12 | 13 | @interface AFAppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | @property (strong, nonatomic) ViewController *viewController; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Example/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFViewController.h 3 | // AFProgressImageDownload 4 | // 5 | // Created by ben on 6/29/13. 6 | // Copyright (c) 2013 Fickle Bits. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property (weak, nonatomic) IBOutlet UIImageView *imageView; 14 | @property (weak, nonatomic) IBOutlet UILabel *statusLabel; 15 | 16 | - (IBAction)startDownload:(id)sender; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Pods/Pods-environment.h: -------------------------------------------------------------------------------- 1 | 2 | // To check if a library is compiled with CocoaPods you 3 | // can use the `COCOAPODS` macro definition which is 4 | // defined in the xcconfigs so it is available in 5 | // headers also when they are imported in the client 6 | // project. 7 | 8 | 9 | // AFNetworking 10 | #define COCOAPODS_POD_AVAILABLE_AFNetworking 11 | #define COCOAPODS_VERSION_MAJOR_AFNetworking 1 12 | #define COCOAPODS_VERSION_MINOR_AFNetworking 3 13 | #define COCOAPODS_VERSION_PATCH_AFNetworking 1 14 | 15 | -------------------------------------------------------------------------------- /Pods/Pods-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-environment.h" 6 | #import 7 | 8 | #define _AFNETWORKING_PIN_SSL_CERTIFICATES_ 9 | 10 | #if __IPHONE_OS_VERSION_MIN_REQUIRED 11 | #import 12 | #import 13 | #import 14 | #else 15 | #import 16 | #import 17 | #import 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /Pods/Pods.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_SEARCH_USER_PATHS = YES 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = ${PODS_HEADERS_SEARCH_PATHS} 4 | OTHER_LDFLAGS = -ObjC -framework CoreGraphics -framework MobileCoreServices -framework Security -framework SystemConfiguration 5 | PODS_BUILD_HEADERS_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/AFNetworking" 6 | PODS_HEADERS_SEARCH_PATHS = ${PODS_PUBLIC_HEADERS_SEARCH_PATHS} 7 | PODS_PUBLIC_HEADERS_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" 8 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /AFProgressiveImageDownload/UIImageView+AFProgressiveImageDownload.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+AFProgressiveImageDownload.h 3 | // AFProgressiveImageDownload 4 | // 5 | // Created by ben on 6/29/13. 6 | // Copyright (c) 2013 Fickle Bits. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void (^AFProgressiveImageDownloadCompletionBlock)(NSURL *imageURL, BOOL success, NSError *error, BOOL completed); 12 | 13 | @interface UIImageView (AFProgressiveImageDownload) 14 | 15 | - (void)setImageProgressivelyWithImageURLs:(NSArray *)imageURLs 16 | placeholderImage:(UIImage *)placeholderImage 17 | completion:(AFProgressiveImageDownloadCompletionBlock)completionBlock; 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /AFProgressiveImageDownload.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "AFProgressiveImageDownload" 3 | s.version = "0.1" 4 | s.summary = "A category on UIView that allows you to progressively download images providing seamless enhancement." 5 | s.homepage = "http://github.com/subdigital/AFProgressiveImageDownload" 6 | s.license = { :type => 'MIT', :file => 'LICENSE' } 7 | 8 | s.author = { "Ben Scheirman" => "ben@scheirman.com" } 9 | s.source = { :git => "https://github.com/subdigital/AFProgressiveImageDownload.git", :tag => "0.1" } 10 | 11 | s.platform = :ios, '5.0' 12 | s.source_files = 'AFProgressiveImageDownload/**/*.{h,m}' 13 | 14 | s.requires_arc = true 15 | s.dependency 'AFNetworking', '~> 1.0' 16 | end 17 | -------------------------------------------------------------------------------- /Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Gowalla (http://gowalla.com/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Ben Scheirman. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | 24 | -------------------------------------------------------------------------------- /Pods/Pods-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2011 Gowalla (http://gowalla.com/) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | Generated by CocoaPods - http://cocoapods.org 27 | -------------------------------------------------------------------------------- /Example/AFProgressiveImageDownload-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.ficklebits.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | Progressive Image Sample 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | 26 | #ifndef _AFNETWORKING_ 27 | #define _AFNETWORKING_ 28 | 29 | #import "AFURLConnectionOperation.h" 30 | 31 | #import "AFHTTPRequestOperation.h" 32 | #import "AFJSONRequestOperation.h" 33 | #import "AFXMLRequestOperation.h" 34 | #import "AFPropertyListRequestOperation.h" 35 | #import "AFHTTPClient.h" 36 | 37 | #import "AFImageRequestOperation.h" 38 | 39 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 40 | #import "AFNetworkActivityIndicatorManager.h" 41 | #import "UIImageView+AFNetworking.h" 42 | #endif 43 | #endif /* _AFNETWORKING_ */ 44 | -------------------------------------------------------------------------------- /Pods/Pods-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy.txt 4 | touch "$RESOURCES_TO_COPY" 5 | 6 | install_resource() 7 | { 8 | case $1 in 9 | *.storyboard) 10 | 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}" 11 | 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}" 12 | ;; 13 | *.xib) 14 | 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}" 15 | 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}" 16 | ;; 17 | *.framework) 18 | echo "rsync -rp ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 19 | rsync -rp "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | ;; 21 | *.xcdatamodeld) 22 | echo "xcrun momc ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename $1 .xcdatamodeld`.momd" 23 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename $1 .xcdatamodeld`.momd" 24 | ;; 25 | *) 26 | echo "${PODS_ROOT}/$1" 27 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 28 | ;; 29 | esac 30 | } 31 | 32 | rsync -avr --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 33 | rm "$RESOURCES_TO_COPY" 34 | -------------------------------------------------------------------------------- /Pods/Pods-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011 Gowalla (http://gowalla.com/) 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | Title 38 | AFNetworking 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | Generated by CocoaPods - http://cocoapods.org 45 | Title 46 | 47 | Type 48 | PSGroupSpecifier 49 | 50 | 51 | StringsTable 52 | Acknowledgements 53 | Title 54 | Acknowledgements 55 | 56 | 57 | -------------------------------------------------------------------------------- /Example/AFAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFAppDelegate.m 3 | // AFProgressImageDownload 4 | // 5 | // Created by ben on 6/29/13. 6 | // Copyright (c) 2013 Fickle Bits. All rights reserved. 7 | // 8 | 9 | #import "AFAppDelegate.h" 10 | 11 | #import "ViewController.h" 12 | 13 | @implementation AFAppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | // Override point for customization after application launch. 19 | self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 20 | self.window.rootViewController = self.viewController; 21 | [self.window makeKeyAndVisible]; 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application 26 | { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 29 | } 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application 32 | { 33 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 40 | } 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application 43 | { 44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application 48 | { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /AFProgressiveImageDownload/UIImageView+AFProgressiveImageDownload.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+AFProgressiveImageDownload.m 3 | // AFProgressiveImageDownload 4 | // 5 | // Created by ben on 6/29/13. 6 | // Copyright (c) 2013 Fickle Bits. All rights reserved. 7 | // 8 | 9 | #import "UIImageView+AFProgressiveImageDownload.h" 10 | #import "UIImageView+AFNetworking.h" 11 | 12 | @implementation UIImageView (AFProgressiveImageDownload) 13 | 14 | - (void)setImageProgressivelyWithImageURLs:(NSArray *)imageURLs 15 | placeholderImage:(UIImage *)placeholderImage 16 | completion:(AFProgressiveImageDownloadCompletionBlock)completionBlock { 17 | if (placeholderImage) { 18 | [self setImage:placeholderImage]; 19 | } 20 | 21 | [self fetchNextImage:imageURLs withCompletion:completionBlock]; 22 | } 23 | 24 | - (void)fetchNextImage:(NSArray *)urls withCompletion:(AFProgressiveImageDownloadCompletionBlock)completionBlock { 25 | NSMutableArray *remainingUrls = [urls mutableCopy]; 26 | if ([remainingUrls count] == 0) { 27 | return; 28 | } 29 | 30 | NSURL *imageUrl = remainingUrls[0]; 31 | [remainingUrls removeObjectAtIndex:0]; 32 | 33 | NSMutableURLRequest *imageRequest = [NSMutableURLRequest requestWithURL:imageUrl]; 34 | [imageRequest addValue:@"image/*" forHTTPHeaderField:@"Accept"]; 35 | 36 | __weak typeof(self) weakSelf = self; 37 | [self setImageWithURLRequest:imageRequest placeholderImage:self.image success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) { 38 | __strong typeof(weakSelf) strongSelf = weakSelf; 39 | if (!strongSelf) { 40 | return; 41 | } 42 | 43 | strongSelf.image = image; 44 | 45 | if (completionBlock) { 46 | dispatch_async(dispatch_get_main_queue(), ^{ 47 | completionBlock(imageUrl, YES, nil, [remainingUrls count] == 0); 48 | }); 49 | } 50 | 51 | [strongSelf fetchNextImage:remainingUrls withCompletion:completionBlock]; 52 | } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) { 53 | if (completionBlock) { 54 | dispatch_async(dispatch_get_main_queue(), ^{ 55 | completionBlock(imageUrl, NO, error, [remainingUrls count] == 0); 56 | }); 57 | } 58 | 59 | [weakSelf fetchNextImage:remainingUrls withCompletion:completionBlock]; 60 | }]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AFProgressiveImageDownload 2 | 3 | A category on UIView that allows you to progressively download images. Leverages AFNetworking's image cache to make seamless image enhancements really easy. 4 | 5 | ## Why is this useful? 6 | 7 | It is common to download smaller images for use as thumbnails when rendering many records in a table view. When you visit the detail for a given page, you'd like to download a higher resolution image, but use the one we've already downloaded as a starting point, so the user doesn't get a flash of no content when the detail view controller loads. 8 | 9 | This leverages AFNetworking's image cache, so all you need is a set of progressively enhanced URLs. It supports any number of requests, but you'll probably only use 2 (small/large). 10 | 11 | ## Requirements 12 | 13 | - iOS 6.0 14 | - AFNetworking 15 | 16 | ## Installation 17 | 18 | Install via [CocoaPods](http://cocoapods.org). Here's a sample `Podfile`: 19 | 20 | ````ruby 21 | platform :ios, '6.0' 22 | 23 | pod 'AFNetworking' 24 | pod 'AFProgressiveImageDownload' 25 | ```` 26 | 27 | Then run `pod install` to integrate it with your Xcode project. 28 | 29 | ## Usage 30 | 31 | Import the header: 32 | 33 | ````objc 34 | #import "UIImageView+AFProgressiveDownload.h" 35 | ```` 36 | 37 | Prepare a list of URLs: 38 | 39 | ````objc 40 | NSArray *urls = @[ smallUrl, largeUrl ]; 41 | ```` 42 | 43 | Load it on the image view: 44 | 45 | ````objc 46 | [self.imageView setImageProgressivelyWithImageURLs:progressiveURLS 47 | placeholderImage:self.placeholderImage 48 | completion:^(NSURL *imageURL, BOOL success, NSError *error, BOOL completed) { 49 | NSLog(@"Completed %@", imageURL); 50 | 51 | // just to make the effect more obvious 52 | sleep(1); 53 | }]; 54 | ```` 55 | 56 | ## Demo 57 | 58 | Check out the provided sample project for a live demo. Here's what it looks like: 59 | 60 | ![Loading the first image](https://benpublic.s3.amazonaws.com/afprogressivedownload-1.png) ![Loading the second image](https://benpublic.s3.amazonaws.com/afprogressivedownload-2.png) 61 | 62 | It's hard to see with scaled down images, but the one on the right is retina resolution. 63 | 64 | ## License 65 | 66 | AFProgressiveImageDownload is provided under the MIT license. See LICENSE for specifics. 67 | 68 | ## Attribution 69 | 70 | This library is made possible by [AFNetworking](http://afnetworking.com), which is doing all of the heavy lifting here. The demo project uses Creative Commons licensed images. Credits to Eugene Kukulka and WPZOOM. 71 | 72 | Created as part of the Objective-C Hackathon on June 29th, 2013. 73 | -------------------------------------------------------------------------------- /Example/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFViewController.m 3 | // AFProgressImageDownload 4 | // 5 | // Created by ben on 6/29/13. 6 | // Copyright (c) 2013 Fickle Bits. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIImageView+AFProgressiveImageDownload.h" 11 | 12 | // These images are Creative Commons licensed. Copyright Eugene Kukulka 13 | // http://www.flickr.com/photos/eugene-kukulka/ 14 | #define SMALL_PHOTO_URL @"http://farm8.staticflickr.com/7205/6909138889_154a903bcb_n.jpg" 15 | #define LARGE_PHOTO_URL @"http://farm8.staticflickr.com/7205/6909138889_154a903bcb_z.jpg" 16 | 17 | @interface ViewController () 18 | 19 | @property (nonatomic, strong) UIImage *placeholderImage; 20 | 21 | @end 22 | 23 | @implementation ViewController 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | 28 | // This placeholder image is based on an icon from WPZOOM - http://www.wpzoom.com 29 | self.placeholderImage = [UIImage imageNamed:@"img-placeholder.png"]; 30 | } 31 | 32 | - (IBAction)startDownload:(id)sender { 33 | self.statusLabel.text = @""; 34 | NSArray *progressiveURLS = @[[NSURL URLWithString:SMALL_PHOTO_URL], 35 | [NSURL URLWithString:LARGE_PHOTO_URL]]; 36 | 37 | [self.imageView setImageProgressivelyWithImageURLs:progressiveURLS 38 | placeholderImage:self.placeholderImage 39 | completion:^(NSURL *imageURL, BOOL success, NSError *error, BOOL completed) { 40 | NSInteger index = [progressiveURLS indexOfObject:imageURL]; 41 | NSString *status = nil; 42 | if (success) { 43 | status = [NSString stringWithFormat:@"Finished with URL: %d", 44 | index]; 45 | } else { 46 | status = [NSString stringWithFormat:@"ERROR: %@", error]; 47 | } 48 | 49 | if (completed) { 50 | status = [status stringByAppendingString:@"\n\nDone!"]; 51 | } 52 | 53 | NSLog(@"%@", status); 54 | NSString *text = self.statusLabel.text; 55 | text = [text stringByAppendingFormat:@"\n%@", status]; 56 | self.statusLabel.text = text; 57 | 58 | // just to make the effect more obvious 59 | sleep(1); 60 | }]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFPropertyListRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFHTTPRequestOperation.h" 25 | 26 | /** 27 | `AFPropertyListRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and deserializing objects with property list (plist) response data. 28 | 29 | ## Acceptable Content Types 30 | 31 | By default, `AFPropertyListRequestOperation` accepts the following MIME types: 32 | 33 | - `application/x-plist` 34 | */ 35 | @interface AFPropertyListRequestOperation : AFHTTPRequestOperation 36 | 37 | ///---------------------------- 38 | /// @name Getting Response Data 39 | ///---------------------------- 40 | 41 | /** 42 | An object deserialized from a plist constructed using the response data. 43 | */ 44 | @property (readonly, nonatomic) id responsePropertyList; 45 | 46 | ///-------------------------------------- 47 | /// @name Managing Property List Behavior 48 | ///-------------------------------------- 49 | 50 | /** 51 | One of the `NSPropertyListMutabilityOptions` options, specifying the mutability of objects deserialized from the property list. By default, this is `NSPropertyListImmutable`. 52 | */ 53 | @property (nonatomic, assign) NSPropertyListReadOptions propertyListReadOptions; 54 | 55 | /** 56 | Creates and returns an `AFPropertyListRequestOperation` object and sets the specified success and failure callbacks. 57 | 58 | @param urlRequest The request object to be loaded asynchronously during execution of the operation 59 | @param success A block object to be executed when the operation 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 object deserialized from a plist constructed using the response data. 60 | @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while deserializing the object from a property list. 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 describing the network or parsing error that occurred. 61 | 62 | @return A new property list request operation 63 | */ 64 | + (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)urlRequest 65 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success 66 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFJSONRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFHTTPRequestOperation.h" 25 | 26 | /** 27 | `AFJSONRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and working with JSON response data. 28 | 29 | ## Acceptable Content Types 30 | 31 | By default, `AFJSONRequestOperation` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: 32 | 33 | - `application/json` 34 | - `text/json` 35 | 36 | @warning JSON parsing will use the built-in `NSJSONSerialization` class. 37 | */ 38 | @interface AFJSONRequestOperation : AFHTTPRequestOperation 39 | 40 | ///---------------------------- 41 | /// @name Getting Response Data 42 | ///---------------------------- 43 | 44 | /** 45 | A JSON object constructed from the response data. If an error occurs while parsing, `nil` will be returned, and the `error` property will be set to the error. 46 | */ 47 | @property (readonly, nonatomic, strong) id responseJSON; 48 | 49 | /** 50 | Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". 51 | */ 52 | @property (nonatomic, assign) NSJSONReadingOptions JSONReadingOptions; 53 | 54 | ///---------------------------------- 55 | /// @name Creating Request Operations 56 | ///---------------------------------- 57 | 58 | /** 59 | Creates and returns an `AFJSONRequestOperation` object and sets the specified success and failure callbacks. 60 | 61 | @param urlRequest The request object to be loaded asynchronously during execution of the operation 62 | @param success A block object to be executed when the operation 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 JSON object created from the response data of request. 63 | @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data as JSON. 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 describing the network or parsing error that occurred. 64 | 65 | @return A new JSON request operation 66 | */ 67 | + (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest 68 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success 69 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | #import 29 | 30 | /** 31 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation 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. 32 | 33 | 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: 34 | 35 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 36 | 37 | By setting `isNetworkActivityIndicatorVisible` 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. 38 | 39 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 40 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 41 | */ 42 | @interface AFNetworkActivityIndicatorManager : NSObject 43 | 44 | /** 45 | A Boolean value indicating whether the manager is enabled. 46 | 47 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 48 | */ 49 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 50 | 51 | /** 52 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. 53 | */ 54 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; 55 | 56 | /** 57 | Returns the shared network activity indicator manager object for the system. 58 | 59 | @return The systemwide network activity indicator manager. 60 | */ 61 | + (instancetype)sharedManager; 62 | 63 | /** 64 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 65 | */ 66 | - (void)incrementActivityCount; 67 | 68 | /** 69 | Decrements the number of active network requests. If this number becomes zero before decrementing, this will stop animating the status bar network activity indicator. 70 | */ 71 | - (void)decrementActivityCount; 72 | 73 | @end 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFXMLRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFHTTPRequestOperation.h" 25 | 26 | #import 27 | 28 | /** 29 | `AFXMLRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and working with XML response data. 30 | 31 | ## Acceptable Content Types 32 | 33 | By default, `AFXMLRequestOperation` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: 34 | 35 | - `application/xml` 36 | - `text/xml` 37 | 38 | ## Use With AFHTTPClient 39 | 40 | When `AFXMLRequestOperation` is registered with `AFHTTPClient`, the response object in the success callback of `HTTPRequestOperationWithRequest:success:failure:` will be an instance of `NSXMLParser`. On platforms that support `NSXMLDocument`, you have the option to ignore the response object, and simply use the `responseXMLDocument` property of the operation argument of the callback. 41 | */ 42 | @interface AFXMLRequestOperation : AFHTTPRequestOperation 43 | 44 | ///---------------------------- 45 | /// @name Getting Response Data 46 | ///---------------------------- 47 | 48 | /** 49 | An `NSXMLParser` object constructed from the response data. 50 | */ 51 | @property (readonly, nonatomic, strong) NSXMLParser *responseXMLParser; 52 | 53 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 54 | /** 55 | An `NSXMLDocument` object constructed from the response data. If an error occurs while parsing, `nil` will be returned, and the `error` property will be set to the error. 56 | */ 57 | @property (readonly, nonatomic, strong) NSXMLDocument *responseXMLDocument; 58 | #endif 59 | 60 | /** 61 | Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks. 62 | 63 | @param urlRequest The request object to be loaded asynchronously during execution of the operation 64 | @param success A block object to be executed when the operation 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 XML parser constructed with the response data of request. 65 | @param failure A block object to be executed when the operation finishes unsuccessfully. 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 describing the network error that occurred. 66 | 67 | @return A new XML request operation 68 | */ 69 | + (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest 70 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success 71 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure; 72 | 73 | 74 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 75 | /** 76 | Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks. 77 | 78 | @param urlRequest The request object to be loaded asynchronously during execution of the operation 79 | @param success A block object to be executed when the operation 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 XML document created from the response data of request. 80 | @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data as XML. 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 describing the network or parsing error that occurred. 81 | 82 | @return A new XML request operation 83 | */ 84 | + (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest 85 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success 86 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure; 87 | #endif 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFImageRequestOperation.h" 25 | 26 | #import 27 | 28 | #if __IPHONE_OS_VERSION_MIN_REQUIRED 29 | #import 30 | 31 | /** 32 | 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. 33 | */ 34 | @interface UIImageView (AFNetworking) 35 | 36 | /** 37 | Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL, and sets it 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. 38 | 39 | By default, URL requests have 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:` 40 | 41 | @param url The URL used for the image request. 42 | */ 43 | - (void)setImageWithURL:(NSURL *)url; 44 | 45 | /** 46 | Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL. 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. 47 | 48 | By default, URL requests have 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:` 49 | 50 | @param url The URL used for the image request. 51 | @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. 52 | */ 53 | - (void)setImageWithURL:(NSURL *)url 54 | placeholderImage:(UIImage *)placeholderImage; 55 | 56 | /** 57 | Creates and enqueues an image request operation, which asynchronously downloads the image with the specified URL request object. 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. 58 | 59 | 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 executed. 60 | 61 | @param urlRequest The URL request used for the image request. 62 | @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. 63 | @param success A block to be executed when the image request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). 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 request and response parameters will be `nil`. 64 | @param failure A block object to be executed when the image request operation 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. 65 | */ 66 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 67 | placeholderImage:(UIImage *)placeholderImage 68 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 69 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; 70 | 71 | /** 72 | Cancels any executing image request operation for the receiver, if one exists. 73 | */ 74 | - (void)cancelImageRequestOperation; 75 | 76 | @end 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m: -------------------------------------------------------------------------------- 1 | // AFPropertyListRequestOperation.m 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "AFPropertyListRequestOperation.h" 24 | 25 | static dispatch_queue_t property_list_request_operation_processing_queue() { 26 | static dispatch_queue_t af_property_list_request_operation_processing_queue; 27 | static dispatch_once_t onceToken; 28 | dispatch_once(&onceToken, ^{ 29 | af_property_list_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.property-list-request.processing", DISPATCH_QUEUE_CONCURRENT); 30 | }); 31 | 32 | return af_property_list_request_operation_processing_queue; 33 | } 34 | 35 | @interface AFPropertyListRequestOperation () 36 | @property (readwrite, nonatomic) id responsePropertyList; 37 | @property (readwrite, nonatomic, assign) NSPropertyListFormat propertyListFormat; 38 | @property (readwrite, nonatomic) NSError *propertyListError; 39 | @end 40 | 41 | @implementation AFPropertyListRequestOperation 42 | @synthesize responsePropertyList = _responsePropertyList; 43 | @synthesize propertyListReadOptions = _propertyListReadOptions; 44 | @synthesize propertyListFormat = _propertyListFormat; 45 | @synthesize propertyListError = _propertyListError; 46 | 47 | + (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)request 48 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success 49 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure 50 | { 51 | AFPropertyListRequestOperation *requestOperation = [(AFPropertyListRequestOperation *)[self alloc] initWithRequest:request]; 52 | [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 53 | if (success) { 54 | success(operation.request, operation.response, responseObject); 55 | } 56 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 57 | if (failure) { 58 | failure(operation.request, operation.response, error, [(AFPropertyListRequestOperation *)operation responsePropertyList]); 59 | } 60 | }]; 61 | 62 | return requestOperation; 63 | } 64 | 65 | - (id)initWithRequest:(NSURLRequest *)urlRequest { 66 | self = [super initWithRequest:urlRequest]; 67 | if (!self) { 68 | return nil; 69 | } 70 | 71 | self.propertyListReadOptions = NSPropertyListImmutable; 72 | 73 | return self; 74 | } 75 | 76 | 77 | - (id)responsePropertyList { 78 | if (!_responsePropertyList && [self.responseData length] > 0 && [self isFinished]) { 79 | NSPropertyListFormat format; 80 | NSError *error = nil; 81 | self.responsePropertyList = [NSPropertyListSerialization propertyListWithData:self.responseData options:self.propertyListReadOptions format:&format error:&error]; 82 | self.propertyListFormat = format; 83 | self.propertyListError = error; 84 | } 85 | 86 | return _responsePropertyList; 87 | } 88 | 89 | - (NSError *)error { 90 | if (_propertyListError) { 91 | return _propertyListError; 92 | } else { 93 | return [super error]; 94 | } 95 | } 96 | 97 | #pragma mark - AFHTTPRequestOperation 98 | 99 | + (NSSet *)acceptableContentTypes { 100 | return [NSSet setWithObjects:@"application/x-plist", nil]; 101 | } 102 | 103 | + (BOOL)canProcessRequest:(NSURLRequest *)request { 104 | return [[[request URL] pathExtension] isEqualToString:@"plist"] || [super canProcessRequest:request]; 105 | } 106 | 107 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 108 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 109 | { 110 | #pragma clang diagnostic push 111 | #pragma clang diagnostic ignored "-Warc-retain-cycles" 112 | #pragma clang diagnostic ignored "-Wgnu" 113 | self.completionBlock = ^ { 114 | if (self.error) { 115 | if (failure) { 116 | dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ 117 | failure(self, self.error); 118 | }); 119 | } 120 | } else { 121 | dispatch_async(property_list_request_operation_processing_queue(), ^(void) { 122 | id propertyList = self.responsePropertyList; 123 | 124 | if (self.propertyListError) { 125 | if (failure) { 126 | dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ 127 | failure(self, self.error); 128 | }); 129 | } 130 | } else { 131 | if (success) { 132 | dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ 133 | success(self, propertyList); 134 | }); 135 | } 136 | } 137 | }); 138 | } 139 | }; 140 | #pragma clang diagnostic pop 141 | } 142 | 143 | @end 144 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.m 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "AFNetworkActivityIndicatorManager.h" 24 | 25 | #import "AFHTTPRequestOperation.h" 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; 29 | 30 | @interface AFNetworkActivityIndicatorManager () 31 | @property (readwrite, nonatomic, assign) NSInteger activityCount; 32 | @property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer; 33 | @property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 34 | 35 | - (void)updateNetworkActivityIndicatorVisibility; 36 | - (void)updateNetworkActivityIndicatorVisibilityDelayed; 37 | @end 38 | 39 | @implementation AFNetworkActivityIndicatorManager 40 | @synthesize activityCount = _activityCount; 41 | @synthesize activityIndicatorVisibilityTimer = _activityIndicatorVisibilityTimer; 42 | @synthesize enabled = _enabled; 43 | @dynamic networkActivityIndicatorVisible; 44 | 45 | + (instancetype)sharedManager { 46 | static AFNetworkActivityIndicatorManager *_sharedManager = nil; 47 | static dispatch_once_t oncePredicate; 48 | dispatch_once(&oncePredicate, ^{ 49 | _sharedManager = [[self alloc] init]; 50 | }); 51 | 52 | return _sharedManager; 53 | } 54 | 55 | + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { 56 | return [NSSet setWithObject:@"activityCount"]; 57 | } 58 | 59 | - (id)init { 60 | self = [super init]; 61 | if (!self) { 62 | return nil; 63 | } 64 | 65 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkingOperationDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; 66 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkingOperationDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; 67 | 68 | return self; 69 | } 70 | 71 | - (void)dealloc { 72 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 73 | 74 | [_activityIndicatorVisibilityTimer invalidate]; 75 | 76 | } 77 | 78 | - (void)updateNetworkActivityIndicatorVisibilityDelayed { 79 | if (self.enabled) { 80 | // Delay hiding of activity indicator for a short interval, to avoid flickering 81 | if (![self isNetworkActivityIndicatorVisible]) { 82 | [self.activityIndicatorVisibilityTimer invalidate]; 83 | self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO]; 84 | [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes]; 85 | } else { 86 | [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:[NSArray arrayWithObject:NSRunLoopCommonModes]]; 87 | } 88 | } 89 | } 90 | 91 | - (BOOL)isNetworkActivityIndicatorVisible { 92 | return _activityCount > 0; 93 | } 94 | 95 | - (void)updateNetworkActivityIndicatorVisibility { 96 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; 97 | } 98 | 99 | // Not exposed, but used if activityCount is set via KVC. 100 | - (NSInteger)activityCount { 101 | return _activityCount; 102 | } 103 | 104 | - (void)setActivityCount:(NSInteger)activityCount { 105 | @synchronized(self) { 106 | _activityCount = activityCount; 107 | } 108 | 109 | dispatch_async(dispatch_get_main_queue(), ^{ 110 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 111 | }); 112 | } 113 | 114 | - (void)incrementActivityCount { 115 | [self willChangeValueForKey:@"activityCount"]; 116 | @synchronized(self) { 117 | _activityCount++; 118 | } 119 | [self didChangeValueForKey:@"activityCount"]; 120 | 121 | dispatch_async(dispatch_get_main_queue(), ^{ 122 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 123 | }); 124 | } 125 | 126 | - (void)decrementActivityCount { 127 | [self willChangeValueForKey:@"activityCount"]; 128 | @synchronized(self) { 129 | #pragma clang diagnostic push 130 | #pragma clang diagnostic ignored "-Wgnu" 131 | _activityCount = MAX(_activityCount - 1, 0); 132 | #pragma clang diagnostic pop 133 | } 134 | [self didChangeValueForKey:@"activityCount"]; 135 | 136 | dispatch_async(dispatch_get_main_queue(), ^{ 137 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 138 | }); 139 | } 140 | 141 | - (void)networkingOperationDidStart:(NSNotification *)notification { 142 | AFURLConnectionOperation *connectionOperation = [notification object]; 143 | if (connectionOperation.request.URL) { 144 | [self incrementActivityCount]; 145 | } 146 | } 147 | 148 | - (void)networkingOperationDidFinish:(NSNotification *)notification { 149 | AFURLConnectionOperation *connectionOperation = [notification object]; 150 | if (connectionOperation.request.URL) { 151 | [self decrementActivityCount]; 152 | } 153 | } 154 | 155 | @end 156 | 157 | #endif 158 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFImageRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFHTTPRequestOperation.h" 25 | 26 | #import 27 | 28 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 29 | #import 30 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 31 | #import 32 | #endif 33 | 34 | /** 35 | `AFImageRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and processing images. 36 | 37 | ## Acceptable Content Types 38 | 39 | By default, `AFImageRequestOperation` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: 40 | 41 | - `image/tiff` 42 | - `image/jpeg` 43 | - `image/gif` 44 | - `image/png` 45 | - `image/ico` 46 | - `image/x-icon` 47 | - `image/bmp` 48 | - `image/x-bmp` 49 | - `image/x-xbitmap` 50 | - `image/x-win-bitmap` 51 | */ 52 | @interface AFImageRequestOperation : AFHTTPRequestOperation 53 | 54 | /** 55 | An image constructed from the response data. If an error occurs during the request, `nil` will be returned, and the `error` property will be set to the error. 56 | */ 57 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 58 | @property (readonly, nonatomic, strong) UIImage *responseImage; 59 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 60 | @property (readonly, nonatomic, strong) NSImage *responseImage; 61 | #endif 62 | 63 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 64 | /** 65 | 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. 66 | */ 67 | @property (nonatomic, assign) CGFloat imageScale; 68 | 69 | /** 70 | 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. 71 | */ 72 | @property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; 73 | #endif 74 | 75 | /** 76 | Creates and returns an `AFImageRequestOperation` object and sets the specified success callback. 77 | 78 | @param urlRequest The request object to be loaded asynchronously during execution of the operation. 79 | @param success A block object to be executed when the request finishes successfully. This block has no return value and takes a single argument, the image created from the response data of the request. 80 | 81 | @return A new image request operation 82 | */ 83 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 84 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 85 | success:(void (^)(UIImage *image))success; 86 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 87 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 88 | success:(void (^)(NSImage *image))success; 89 | #endif 90 | 91 | /** 92 | Creates and returns an `AFImageRequestOperation` object and sets the specified success callback. 93 | 94 | @param urlRequest The request object to be loaded asynchronously during execution of the operation. 95 | @param imageProcessingBlock A block object to be executed after the image request finishes successfully, but before the image is returned in the `success` block. This block takes a single argument, the image loaded from the response body, and returns the processed image. 96 | @param success A block object to be executed when the request finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the image created from the response data. 97 | @param failure A block object to be executed when the request finishes unsuccessfully. This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the error associated with the cause for the unsuccessful operation. 98 | 99 | @return A new image request operation 100 | */ 101 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 102 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 103 | imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock 104 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 105 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; 106 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 107 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 108 | imageProcessingBlock:(NSImage *(^)(NSImage *image))imageProcessingBlock 109 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success 110 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; 111 | #endif 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFURLConnectionOperation.h" 25 | 26 | /** 27 | `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. 28 | */ 29 | @interface AFHTTPRequestOperation : AFURLConnectionOperation 30 | 31 | ///---------------------------------------------- 32 | /// @name Getting HTTP URL Connection Information 33 | ///---------------------------------------------- 34 | 35 | /** 36 | The last HTTP response received by the operation's connection. 37 | */ 38 | @property (readonly, nonatomic, strong) NSHTTPURLResponse *response; 39 | 40 | ///---------------------------------------------------------- 41 | /// @name Managing And Checking For Acceptable HTTP Responses 42 | ///---------------------------------------------------------- 43 | 44 | /** 45 | A Boolean value that corresponds to whether the status code of the response is within the specified set of acceptable status codes. Returns `YES` if `acceptableStatusCodes` is `nil`. 46 | */ 47 | @property (nonatomic, readonly) BOOL hasAcceptableStatusCode; 48 | 49 | /** 50 | A Boolean value that corresponds to whether the MIME type of the response is among the specified set of acceptable content types. Returns `YES` if `acceptableContentTypes` is `nil`. 51 | */ 52 | @property (nonatomic, readonly) BOOL hasAcceptableContentType; 53 | 54 | /** 55 | The callback dispatch queue on success. If `NULL` (default), the main queue is used. 56 | */ 57 | @property (nonatomic, assign) dispatch_queue_t successCallbackQueue; 58 | 59 | /** 60 | The callback dispatch queue on failure. If `NULL` (default), the main queue is used. 61 | */ 62 | @property (nonatomic, assign) dispatch_queue_t failureCallbackQueue; 63 | 64 | ///------------------------------------------------------------ 65 | /// @name Managing Acceptable HTTP Status Codes & Content Types 66 | ///------------------------------------------------------------ 67 | 68 | /** 69 | Returns an `NSIndexSet` object containing the ranges of acceptable HTTP status codes. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 70 | 71 | By default, this is the range 200 to 299, inclusive. 72 | */ 73 | + (NSIndexSet *)acceptableStatusCodes; 74 | 75 | /** 76 | Adds status codes to the set of acceptable HTTP status codes returned by `+acceptableStatusCodes` in subsequent calls by this class and its descendants. 77 | 78 | @param statusCodes The status codes to be added to the set of acceptable HTTP status codes 79 | */ 80 | + (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes; 81 | 82 | /** 83 | Returns an `NSSet` object containing the acceptable MIME types. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 84 | 85 | By default, this is `nil`. 86 | */ 87 | + (NSSet *)acceptableContentTypes; 88 | 89 | /** 90 | Adds content types to the set of acceptable MIME types returned by `+acceptableContentTypes` in subsequent calls by this class and its descendants. 91 | 92 | @param contentTypes The content types to be added to the set of acceptable MIME types 93 | */ 94 | + (void)addAcceptableContentTypes:(NSSet *)contentTypes; 95 | 96 | 97 | ///----------------------------------------------------- 98 | /// @name Determining Whether A Request Can Be Processed 99 | ///----------------------------------------------------- 100 | 101 | /** 102 | A Boolean value determining whether or not the class can process the specified request. For example, `AFJSONRequestOperation` may check to make sure the content type was `application/json` or the URL path extension was `.json`. 103 | 104 | @param urlRequest The request that is determined to be supported or not supported for this class. 105 | */ 106 | + (BOOL)canProcessRequest:(NSURLRequest *)urlRequest; 107 | 108 | ///----------------------------------------------------------- 109 | /// @name Setting Completion Block Success / Failure Callbacks 110 | ///----------------------------------------------------------- 111 | 112 | /** 113 | Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. 114 | 115 | This method should be overridden in subclasses in order to specify the response object passed into the success block. 116 | 117 | @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. 118 | @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. 119 | */ 120 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 121 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; 122 | 123 | @end 124 | 125 | ///---------------- 126 | /// @name Functions 127 | ///---------------- 128 | 129 | /** 130 | Returns a set of MIME types detected in an HTTP `Accept` or `Content-Type` header. 131 | */ 132 | extern NSSet * AFContentTypesFromHTTPHeader(NSString *string); 133 | 134 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m: -------------------------------------------------------------------------------- 1 | // AFJSONRequestOperation.m 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "AFJSONRequestOperation.h" 24 | 25 | static dispatch_queue_t json_request_operation_processing_queue() { 26 | static dispatch_queue_t af_json_request_operation_processing_queue; 27 | static dispatch_once_t onceToken; 28 | dispatch_once(&onceToken, ^{ 29 | af_json_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.json-request.processing", DISPATCH_QUEUE_CONCURRENT); 30 | }); 31 | 32 | return af_json_request_operation_processing_queue; 33 | } 34 | 35 | @interface AFJSONRequestOperation () 36 | @property (readwrite, nonatomic, strong) id responseJSON; 37 | @property (readwrite, nonatomic, strong) NSError *JSONError; 38 | @property (readwrite, nonatomic, strong) NSRecursiveLock *lock; 39 | @end 40 | 41 | @implementation AFJSONRequestOperation 42 | @synthesize responseJSON = _responseJSON; 43 | @synthesize JSONReadingOptions = _JSONReadingOptions; 44 | @synthesize JSONError = _JSONError; 45 | @dynamic lock; 46 | 47 | + (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest 48 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success 49 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure 50 | { 51 | AFJSONRequestOperation *requestOperation = [(AFJSONRequestOperation *)[self alloc] initWithRequest:urlRequest]; 52 | [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 53 | if (success) { 54 | success(operation.request, operation.response, responseObject); 55 | } 56 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 57 | if (failure) { 58 | failure(operation.request, operation.response, error, [(AFJSONRequestOperation *)operation responseJSON]); 59 | } 60 | }]; 61 | 62 | return requestOperation; 63 | } 64 | 65 | 66 | - (id)responseJSON { 67 | [self.lock lock]; 68 | if (!_responseJSON && [self.responseData length] > 0 && [self isFinished] && !self.JSONError) { 69 | NSError *error = nil; 70 | 71 | // 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. 72 | // See https://github.com/rails/rails/issues/1742 73 | if (self.responseString && ![self.responseString isEqualToString:@" "]) { 74 | // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character 75 | // See http://stackoverflow.com/a/12843465/157142 76 | NSData *data = [self.responseString dataUsingEncoding:NSUTF8StringEncoding]; 77 | 78 | if (data) { 79 | self.responseJSON = [NSJSONSerialization JSONObjectWithData:data options:self.JSONReadingOptions error:&error]; 80 | } else { 81 | NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; 82 | [userInfo setValue:@"Operation responseData failed decoding as a UTF-8 string" forKey:NSLocalizedDescriptionKey]; 83 | [userInfo setValue:[NSString stringWithFormat:@"Could not decode string: %@", self.responseString] forKey:NSLocalizedFailureReasonErrorKey]; 84 | error = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; 85 | } 86 | } 87 | 88 | self.JSONError = error; 89 | } 90 | [self.lock unlock]; 91 | 92 | return _responseJSON; 93 | } 94 | 95 | - (NSError *)error { 96 | if (_JSONError) { 97 | return _JSONError; 98 | } else { 99 | return [super error]; 100 | } 101 | } 102 | 103 | #pragma mark - AFHTTPRequestOperation 104 | 105 | + (NSSet *)acceptableContentTypes { 106 | return [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; 107 | } 108 | 109 | + (BOOL)canProcessRequest:(NSURLRequest *)request { 110 | return [[[request URL] pathExtension] isEqualToString:@"json"] || [super canProcessRequest:request]; 111 | } 112 | 113 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 114 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 115 | { 116 | #pragma clang diagnostic push 117 | #pragma clang diagnostic ignored "-Warc-retain-cycles" 118 | #pragma clang diagnostic ignored "-Wgnu" 119 | 120 | self.completionBlock = ^ { 121 | if (self.error) { 122 | if (failure) { 123 | dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ 124 | failure(self, self.error); 125 | }); 126 | } 127 | } else { 128 | dispatch_async(json_request_operation_processing_queue(), ^{ 129 | id JSON = self.responseJSON; 130 | 131 | if (self.error) { 132 | if (failure) { 133 | dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ 134 | failure(self, self.error); 135 | }); 136 | } 137 | } else { 138 | if (success) { 139 | dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ 140 | success(self, JSON); 141 | }); 142 | } 143 | } 144 | }); 145 | } 146 | }; 147 | #pragma clang diagnostic pop 148 | } 149 | 150 | @end 151 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m: -------------------------------------------------------------------------------- 1 | // AFXMLRequestOperation.m 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "AFXMLRequestOperation.h" 24 | 25 | #include 26 | 27 | static dispatch_queue_t xml_request_operation_processing_queue() { 28 | static dispatch_queue_t af_xml_request_operation_processing_queue; 29 | static dispatch_once_t onceToken; 30 | dispatch_once(&onceToken, ^{ 31 | af_xml_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.xml-request.processing", DISPATCH_QUEUE_CONCURRENT); 32 | }); 33 | 34 | return af_xml_request_operation_processing_queue; 35 | } 36 | 37 | @interface AFXMLRequestOperation () 38 | @property (readwrite, nonatomic, strong) NSXMLParser *responseXMLParser; 39 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 40 | @property (readwrite, nonatomic, strong) NSXMLDocument *responseXMLDocument; 41 | #endif 42 | @property (readwrite, nonatomic, strong) NSError *XMLError; 43 | @end 44 | 45 | @implementation AFXMLRequestOperation 46 | @synthesize responseXMLParser = _responseXMLParser; 47 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 48 | @synthesize responseXMLDocument = _responseXMLDocument; 49 | #endif 50 | @synthesize XMLError = _XMLError; 51 | 52 | + (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest 53 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success 54 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure 55 | { 56 | AFXMLRequestOperation *requestOperation = [(AFXMLRequestOperation *)[self alloc] initWithRequest:urlRequest]; 57 | [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 58 | if (success) { 59 | success(operation.request, operation.response, responseObject); 60 | } 61 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 62 | if (failure) { 63 | failure(operation.request, operation.response, error, [(AFXMLRequestOperation *)operation responseXMLParser]); 64 | } 65 | }]; 66 | 67 | return requestOperation; 68 | } 69 | 70 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 71 | + (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest 72 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success 73 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure 74 | { 75 | AFXMLRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest]; 76 | [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, __unused id responseObject) { 77 | if (success) { 78 | NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument]; 79 | success(operation.request, operation.response, XMLDocument); 80 | } 81 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 82 | if (failure) { 83 | NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument]; 84 | failure(operation.request, operation.response, error, XMLDocument); 85 | } 86 | }]; 87 | 88 | return requestOperation; 89 | } 90 | #endif 91 | 92 | 93 | - (NSXMLParser *)responseXMLParser { 94 | if (!_responseXMLParser && [self.responseData length] > 0 && [self isFinished]) { 95 | self.responseXMLParser = [[NSXMLParser alloc] initWithData:self.responseData]; 96 | } 97 | 98 | return _responseXMLParser; 99 | } 100 | 101 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 102 | - (NSXMLDocument *)responseXMLDocument { 103 | if (!_responseXMLDocument && [self.responseData length] > 0 && [self isFinished]) { 104 | NSError *error = nil; 105 | self.responseXMLDocument = [[NSXMLDocument alloc] initWithData:self.responseData options:0 error:&error]; 106 | self.XMLError = error; 107 | } 108 | 109 | return _responseXMLDocument; 110 | } 111 | #endif 112 | 113 | - (NSError *)error { 114 | if (_XMLError) { 115 | return _XMLError; 116 | } else { 117 | return [super error]; 118 | } 119 | } 120 | 121 | #pragma mark - NSOperation 122 | 123 | - (void)cancel { 124 | [super cancel]; 125 | 126 | self.responseXMLParser.delegate = nil; 127 | } 128 | 129 | #pragma mark - AFHTTPRequestOperation 130 | 131 | + (NSSet *)acceptableContentTypes { 132 | return [NSSet setWithObjects:@"application/xml", @"text/xml", nil]; 133 | } 134 | 135 | + (BOOL)canProcessRequest:(NSURLRequest *)request { 136 | return [[[request URL] pathExtension] isEqualToString:@"xml"] || [super canProcessRequest:request]; 137 | } 138 | 139 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 140 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 141 | { 142 | #pragma clang diagnostic push 143 | #pragma clang diagnostic ignored "-Warc-retain-cycles" 144 | #pragma clang diagnostic ignored "-Wgnu" 145 | self.completionBlock = ^ { 146 | dispatch_async(xml_request_operation_processing_queue(), ^(void) { 147 | NSXMLParser *XMLParser = self.responseXMLParser; 148 | 149 | if (self.error) { 150 | if (failure) { 151 | dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ 152 | failure(self, self.error); 153 | }); 154 | } 155 | } else { 156 | if (success) { 157 | dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ 158 | success(self, XMLParser); 159 | }); 160 | } 161 | } 162 | }); 163 | }; 164 | #pragma clang diagnostic pop 165 | } 166 | 167 | @end 168 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.m 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | #import "UIImageView+AFNetworking.h" 28 | 29 | @interface AFImageCache : NSCache 30 | - (UIImage *)cachedImageForRequest:(NSURLRequest *)request; 31 | - (void)cacheImage:(UIImage *)image 32 | forRequest:(NSURLRequest *)request; 33 | @end 34 | 35 | #pragma mark - 36 | 37 | static char kAFImageRequestOperationObjectKey; 38 | 39 | @interface UIImageView (_AFNetworking) 40 | @property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFImageRequestOperation *af_imageRequestOperation; 41 | @end 42 | 43 | @implementation UIImageView (_AFNetworking) 44 | @dynamic af_imageRequestOperation; 45 | @end 46 | 47 | #pragma mark - 48 | 49 | @implementation UIImageView (AFNetworking) 50 | 51 | - (AFHTTPRequestOperation *)af_imageRequestOperation { 52 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, &kAFImageRequestOperationObjectKey); 53 | } 54 | 55 | - (void)af_setImageRequestOperation:(AFImageRequestOperation *)imageRequestOperation { 56 | objc_setAssociatedObject(self, &kAFImageRequestOperationObjectKey, imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 57 | } 58 | 59 | + (NSOperationQueue *)af_sharedImageRequestOperationQueue { 60 | static NSOperationQueue *_af_imageRequestOperationQueue = nil; 61 | static dispatch_once_t onceToken; 62 | dispatch_once(&onceToken, ^{ 63 | _af_imageRequestOperationQueue = [[NSOperationQueue alloc] init]; 64 | [_af_imageRequestOperationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount]; 65 | }); 66 | 67 | return _af_imageRequestOperationQueue; 68 | } 69 | 70 | + (AFImageCache *)af_sharedImageCache { 71 | static AFImageCache *_af_imageCache = nil; 72 | static dispatch_once_t oncePredicate; 73 | dispatch_once(&oncePredicate, ^{ 74 | _af_imageCache = [[AFImageCache alloc] init]; 75 | }); 76 | 77 | return _af_imageCache; 78 | } 79 | 80 | #pragma mark - 81 | 82 | - (void)setImageWithURL:(NSURL *)url { 83 | [self setImageWithURL:url placeholderImage:nil]; 84 | } 85 | 86 | - (void)setImageWithURL:(NSURL *)url 87 | placeholderImage:(UIImage *)placeholderImage 88 | { 89 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 90 | [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; 91 | 92 | [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; 93 | } 94 | 95 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 96 | placeholderImage:(UIImage *)placeholderImage 97 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 98 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure 99 | { 100 | [self cancelImageRequestOperation]; 101 | 102 | UIImage *cachedImage = [[[self class] af_sharedImageCache] cachedImageForRequest:urlRequest]; 103 | if (cachedImage) { 104 | if (success) { 105 | success(nil, nil, cachedImage); 106 | } else { 107 | self.image = cachedImage; 108 | } 109 | 110 | self.af_imageRequestOperation = nil; 111 | } else { 112 | self.image = placeholderImage; 113 | 114 | AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; 115 | [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 116 | if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) { 117 | if (success) { 118 | success(operation.request, operation.response, responseObject); 119 | } else if (responseObject) { 120 | self.image = responseObject; 121 | } 122 | 123 | if (self.af_imageRequestOperation == operation) { 124 | self.af_imageRequestOperation = nil; 125 | } 126 | } 127 | 128 | [[[self class] af_sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; 129 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 130 | if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) { 131 | if (failure) { 132 | failure(operation.request, operation.response, error); 133 | } 134 | 135 | if (self.af_imageRequestOperation == operation) { 136 | self.af_imageRequestOperation = nil; 137 | } 138 | } 139 | }]; 140 | 141 | self.af_imageRequestOperation = requestOperation; 142 | 143 | [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation]; 144 | } 145 | } 146 | 147 | - (void)cancelImageRequestOperation { 148 | [self.af_imageRequestOperation cancel]; 149 | self.af_imageRequestOperation = nil; 150 | } 151 | 152 | @end 153 | 154 | #pragma mark - 155 | 156 | static inline NSString * AFImageCacheKeyFromURLRequest(NSURLRequest *request) { 157 | return [[request URL] absoluteString]; 158 | } 159 | 160 | @implementation AFImageCache 161 | 162 | - (UIImage *)cachedImageForRequest:(NSURLRequest *)request { 163 | switch ([request cachePolicy]) { 164 | case NSURLRequestReloadIgnoringCacheData: 165 | case NSURLRequestReloadIgnoringLocalAndRemoteCacheData: 166 | return nil; 167 | default: 168 | break; 169 | } 170 | 171 | return [self objectForKey:AFImageCacheKeyFromURLRequest(request)]; 172 | } 173 | 174 | - (void)cacheImage:(UIImage *)image 175 | forRequest:(NSURLRequest *)request 176 | { 177 | if (image && request) { 178 | [self setObject:image forKey:AFImageCacheKeyFromURLRequest(request)]; 179 | } 180 | } 181 | 182 | @end 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /Pods/AFNetworking/README.md: -------------------------------------------------------------------------------- 1 |

2 | AFNetworking 3 |

4 | 5 | [![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.png?branch=master)](https://travis-ci.org/AFNetworking/AFNetworking) 6 | 7 | AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of [NSURLConnection](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html), [NSOperation](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html), and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL: 8 | 9 | ```objective-c 10 | NSURL *url = [NSURL URLWithString:@"https://alpha-api.app.net/stream/0/posts/stream/global"]; 11 | NSURLRequest *request = [NSURLRequest requestWithURL:url]; 12 | AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { 13 | NSLog(@"App.net Global Stream: %@", JSON); 14 | } failure:nil]; 15 | [operation start]; 16 | ``` 17 | 18 | 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. 19 | 20 | Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did! 21 | 22 | ## How To Get Started 23 | 24 | - [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/zipball/master) and try out the included Mac and iPhone example apps 25 | - 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 in the wiki](https://github.com/AFNetworking/AFNetworking/wiki) 26 | - Check out the [complete documentation](http://afnetworking.github.com/AFNetworking/) for a comprehensive look at the APIs available in AFNetworking 27 | - Watch the [NSScreencast episode about AFNetworking](http://nsscreencast.com/episodes/6-afnetworking) for a quick introduction to how to use it in your application 28 | - Questions? [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking) is the best place to find answers 29 | 30 | ## Overview 31 | 32 |

33 | AFNetworking Architecture Diagram 34 |

35 | 36 | AFNetworking is architected to be as small and modular as possible, in order to make it simple to use and extend. 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 |
Core
AFURLConnectionOperationAn NSOperation that implements the NSURLConnection delegate methods.
HTTP Requests
AFHTTPRequestOperationA subclass of AFURLConnectionOperation for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.
AFJSONRequestOperationA subclass of AFHTTPRequestOperation for downloading and working with JSON response data.
AFXMLRequestOperationA subclass of AFHTTPRequestOperation for downloading and working with XML response data.
AFPropertyListRequestOperationA subclass of AFHTTPRequestOperation for downloading and deserializing objects with property list response data.
HTTP Client
AFHTTPClient 68 | Captures the common patterns of communicating with an web application over HTTP, including: 69 | 70 |
    71 |
  • Making requests from relative paths of a base URL
  • 72 |
  • Setting HTTP headers to be added automatically to requests
  • 73 |
  • Authenticating requests with HTTP Basic credentials or an OAuth token
  • 74 |
  • Managing an NSOperationQueue for requests made by the client
  • 75 |
  • Generating query strings or HTTP bodies from an NSDictionary
  • 76 |
  • Constructing multipart form requests
  • 77 |
  • Automatically parsing HTTP response data into its corresponding object representation
  • 78 |
  • Monitoring and responding to changes in network reachability
  • 79 |
80 |
Images
AFImageRequestOperationA subclass of AFHTTPRequestOperation for downloading and processing images.
UIImageView+AFNetworkingAdds methods to UIImageView for loading remote images asynchronously from a URL.
93 | 94 | ## Example Usage 95 | 96 | ### XML Request 97 | 98 | ```objective-c 99 | NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://api.flickr.com/services/rest/?method=flickr.groups.browse&api_key=b6300e17ad3c506e706cb0072175d047&cat_id=34427469792%40N01&format=rest"]]; 100 | AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) { 101 | XMLParser.delegate = self; 102 | [XMLParser parse]; 103 | } failure:nil]; 104 | [operation start]; 105 | ``` 106 | 107 | ### Image Request 108 | 109 | ```objective-c 110 | UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)]; 111 | [imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]]; 112 | ``` 113 | 114 | ### API Client Request 115 | 116 | ```objective-c 117 | // AFAppDotNetAPIClient is a subclass of AFHTTPClient, which defines the base URL and default HTTP headers for NSURLRequests it creates 118 | [[AFAppDotNetAPIClient sharedClient] getPath:@"stream/0/posts/stream/global" parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) { 119 | NSLog(@"App.net Global Stream: %@", JSON); 120 | } failure:nil]; 121 | ``` 122 | 123 | ### File Upload with Progress Callback 124 | 125 | ```objective-c 126 | NSURL *url = [NSURL URLWithString:@"http://api-base-url.com"]; 127 | AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; 128 | NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"avatar.jpg"], 0.5); 129 | NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/upload" parameters:nil constructingBodyWithBlock: ^(id formData) { 130 | [formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"]; 131 | }]; 132 | 133 | AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 134 | [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { 135 | NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite); 136 | }]; 137 | [httpClient enqueueHTTPRequestOperation:operation]; 138 | ``` 139 | 140 | ### Streaming Request 141 | 142 | ```objective-c 143 | NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:8080/encode"]]; 144 | 145 | AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 146 | operation.inputStream = [NSInputStream inputStreamWithFileAtPath:[[NSBundle mainBundle] pathForResource:@"large-image" ofType:@"tiff"]]; 147 | operation.outputStream = [NSOutputStream outputStreamToMemory]; 148 | [operation start]; 149 | ``` 150 | 151 | ## Requirements 152 | 153 | AFNetworking 1.0 and higher requires either [iOS 5.0](http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS4.html) and above, or [Mac OS 10.7](http://developer.apple.com/library/mac/#releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW7) ([64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)) and above. 154 | 155 | For compatibility with iOS 4.3, use the latest 0.10.x release. 156 | 157 | ### ARC 158 | 159 | AFNetworking uses ARC as of its 1.0 release. 160 | 161 | If you are using AFNetworking 1.0 in your non-arc project, you will need to set a `-fobjc-arc` compiler flag on all of the AFNetworking source files. Conversely, if you are adding a pre-1.0 version of AFNetworking, you will need to set a `-fno-objc-arc` compiler flag. 162 | 163 | To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Now select all AFNetworking source files, press Enter, insert `-fobjc-arc` or `-fno-objc-arc` and then "Done" to enable or disable ARC for AFNetworking. 164 | 165 | ## Unit Tests 166 | 167 | AFNetworking includes a suite of unit tests within the Tests subdirectory. In order to run the unit tests, you must install the testing dependencies via CocoaPods. To do so: 168 | 169 | $ gem install cocoapods # If necessary 170 | $ cd Tests 171 | $ pod install 172 | 173 | Once CocoaPods has finished the installation, you can execute the test suite via the 'iOS Tests' and 'OS X Tests' schemes within Xcode. 174 | 175 | ### Test Logging 176 | 177 | By default, the unit tests do not emit any output during execution. For debugging purposes, it can be useful to enable logging of the requests and responses. Logging support is provided by the [AFHTTPRequestOperationLogger](https://github.com/AFNetworking/AFHTTPRequestOperationLogger) extension, which is installed via CocoaPods into the test targets. To enable logging, edit the test Scheme and add an environment variable named `AFTestsLoggingEnabled` with a value of `YES`. 178 | 179 | ### Using xctool 180 | 181 | If you wish to execute the tests from the command line or within a continuous integration environment, you will need to install [xctool](https://github.com/facebook/xctool). The recommended installation method is [Homebrew](http://mxcl.github.io/homebrew/). 182 | 183 | To install the commandline testing support via Homebrew: 184 | 185 | $ brew update 186 | $ brew install xctool --HEAD 187 | 188 | Once xctool is installed, you can execute the suite via `rake test`. 189 | 190 | ## Credits 191 | 192 | AFNetworking was 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). 193 | 194 | AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/). 195 | 196 | And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors). 197 | 198 | ## Contact 199 | 200 | Follow AFNetworking on Twitter ([@AFNetworking](https://twitter.com/AFNetworking)) 201 | 202 | ### Creators 203 | 204 | [Mattt Thompson](http://github.com/mattt) 205 | [@mattt](https://twitter.com/mattt) 206 | 207 | [Scott Raymond](http://github.com/sco) 208 | [@sco](https://twitter.com/sco) 209 | 210 | ## License 211 | 212 | AFNetworking is available under the MIT license. See the LICENSE file for more info. 213 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m: -------------------------------------------------------------------------------- 1 | // AFImageRequestOperation.m 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "AFImageRequestOperation.h" 24 | 25 | static dispatch_queue_t image_request_operation_processing_queue() { 26 | static dispatch_queue_t af_image_request_operation_processing_queue; 27 | static dispatch_once_t onceToken; 28 | dispatch_once(&onceToken, ^{ 29 | af_image_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.image-request.processing", DISPATCH_QUEUE_CONCURRENT); 30 | }); 31 | 32 | return af_image_request_operation_processing_queue; 33 | } 34 | 35 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 36 | #import 37 | 38 | static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) { 39 | if ([UIImage instancesRespondToSelector:@selector(initWithData:scale:)]) { 40 | return [[UIImage alloc] initWithData:data scale:scale]; 41 | } else { 42 | UIImage *image = [[UIImage alloc] initWithData:data]; 43 | return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation]; 44 | } 45 | } 46 | 47 | static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) { 48 | if (!data || [data length] == 0) { 49 | return nil; 50 | } 51 | 52 | CGImageRef imageRef; 53 | 54 | CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data); 55 | 56 | NSSet *contentTypes = AFContentTypesFromHTTPHeader([[response allHeaderFields] valueForKey:@"Content-Type"]); 57 | if ([contentTypes containsObject:@"image/png"]) { 58 | imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); 59 | } else if ([contentTypes containsObject:@"image/jpeg"]) { 60 | imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); 61 | } else { 62 | UIImage *image = AFImageWithDataAtScale(data, scale); 63 | if (image.images) { 64 | CGDataProviderRelease(dataProvider); 65 | 66 | return image; 67 | } 68 | 69 | imageRef = CGImageCreateCopy([image CGImage]); 70 | } 71 | 72 | CGDataProviderRelease(dataProvider); 73 | 74 | if (!imageRef) { 75 | return nil; 76 | } 77 | 78 | size_t width = CGImageGetWidth(imageRef); 79 | size_t height = CGImageGetHeight(imageRef); 80 | size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef); 81 | size_t bytesPerRow = NULL; // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate() 82 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 83 | CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); 84 | 85 | if (CGColorSpaceGetNumberOfComponents(colorSpace) == 3) { 86 | int alpha = (bitmapInfo & kCGBitmapAlphaInfoMask); 87 | if (alpha == kCGImageAlphaNone) { 88 | bitmapInfo &= ~kCGBitmapAlphaInfoMask; 89 | bitmapInfo |= kCGImageAlphaNoneSkipFirst; 90 | } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) { 91 | bitmapInfo &= ~kCGBitmapAlphaInfoMask; 92 | bitmapInfo |= kCGImageAlphaPremultipliedFirst; 93 | } 94 | } 95 | 96 | CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo); 97 | 98 | CGColorSpaceRelease(colorSpace); 99 | 100 | if (!context) { 101 | CGImageRelease(imageRef); 102 | 103 | return [[UIImage alloc] initWithData:data]; 104 | } 105 | 106 | CGRect rect = CGRectMake(0.0f, 0.0f, width, height); 107 | CGContextDrawImage(context, rect, imageRef); 108 | CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context); 109 | CGContextRelease(context); 110 | 111 | UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:UIImageOrientationUp]; 112 | CGImageRelease(inflatedImageRef); 113 | CGImageRelease(imageRef); 114 | 115 | return inflatedImage; 116 | } 117 | #endif 118 | 119 | @interface AFImageRequestOperation () 120 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 121 | @property (readwrite, nonatomic, strong) UIImage *responseImage; 122 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 123 | @property (readwrite, nonatomic, strong) NSImage *responseImage; 124 | #endif 125 | @end 126 | 127 | @implementation AFImageRequestOperation 128 | @synthesize responseImage = _responseImage; 129 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 130 | @synthesize imageScale = _imageScale; 131 | #endif 132 | 133 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 134 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 135 | success:(void (^)(UIImage *image))success 136 | { 137 | return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, UIImage *image) { 138 | if (success) { 139 | success(image); 140 | } 141 | } failure:nil]; 142 | } 143 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 144 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 145 | success:(void (^)(NSImage *image))success 146 | { 147 | return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, NSImage *image) { 148 | if (success) { 149 | success(image); 150 | } 151 | } failure:nil]; 152 | } 153 | #endif 154 | 155 | 156 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 157 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 158 | imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock 159 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 160 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure 161 | { 162 | AFImageRequestOperation *requestOperation = [(AFImageRequestOperation *)[self alloc] initWithRequest:urlRequest]; 163 | [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 164 | if (success) { 165 | UIImage *image = responseObject; 166 | if (imageProcessingBlock) { 167 | dispatch_async(image_request_operation_processing_queue(), ^(void) { 168 | UIImage *processedImage = imageProcessingBlock(image); 169 | #pragma clang diagnostic push 170 | #pragma clang diagnostic ignored "-Wgnu" 171 | dispatch_async(operation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) { 172 | success(operation.request, operation.response, processedImage); 173 | }); 174 | #pragma clang diagnostic pop 175 | }); 176 | } else { 177 | success(operation.request, operation.response, image); 178 | } 179 | } 180 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 181 | if (failure) { 182 | failure(operation.request, operation.response, error); 183 | } 184 | }]; 185 | 186 | 187 | return requestOperation; 188 | } 189 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 190 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 191 | imageProcessingBlock:(NSImage *(^)(NSImage *))imageProcessingBlock 192 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success 193 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure 194 | { 195 | AFImageRequestOperation *requestOperation = [(AFImageRequestOperation *)[self alloc] initWithRequest:urlRequest]; 196 | [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 197 | if (success) { 198 | NSImage *image = responseObject; 199 | if (imageProcessingBlock) { 200 | dispatch_async(image_request_operation_processing_queue(), ^(void) { 201 | NSImage *processedImage = imageProcessingBlock(image); 202 | 203 | dispatch_async(operation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) { 204 | success(operation.request, operation.response, processedImage); 205 | }); 206 | }); 207 | } else { 208 | success(operation.request, operation.response, image); 209 | } 210 | } 211 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 212 | if (failure) { 213 | failure(operation.request, operation.response, error); 214 | } 215 | }]; 216 | 217 | return requestOperation; 218 | } 219 | #endif 220 | 221 | - (id)initWithRequest:(NSURLRequest *)urlRequest { 222 | self = [super initWithRequest:urlRequest]; 223 | if (!self) { 224 | return nil; 225 | } 226 | 227 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 228 | self.imageScale = [[UIScreen mainScreen] scale]; 229 | self.automaticallyInflatesResponseImage = YES; 230 | #endif 231 | 232 | return self; 233 | } 234 | 235 | 236 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 237 | - (UIImage *)responseImage { 238 | if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { 239 | if (self.automaticallyInflatesResponseImage) { 240 | self.responseImage = AFInflatedImageFromResponseWithDataAtScale(self.response, self.responseData, self.imageScale); 241 | } else { 242 | self.responseImage = AFImageWithDataAtScale(self.responseData, self.imageScale); 243 | } 244 | } 245 | 246 | return _responseImage; 247 | } 248 | 249 | - (void)setImageScale:(CGFloat)imageScale { 250 | #pragma clang diagnostic push 251 | #pragma clang diagnostic ignored "-Wfloat-equal" 252 | if (imageScale == _imageScale) { 253 | return; 254 | } 255 | #pragma clang diagnostic pop 256 | 257 | _imageScale = imageScale; 258 | 259 | self.responseImage = nil; 260 | } 261 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 262 | - (NSImage *)responseImage { 263 | if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { 264 | // Ensure that the image is set to it's correct pixel width and height 265 | NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:self.responseData]; 266 | self.responseImage = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; 267 | [self.responseImage addRepresentation:bitimage]; 268 | } 269 | 270 | return _responseImage; 271 | } 272 | #endif 273 | 274 | #pragma mark - AFHTTPRequestOperation 275 | 276 | + (NSSet *)acceptableContentTypes { 277 | return [NSSet setWithObjects:@"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]; 278 | } 279 | 280 | + (BOOL)canProcessRequest:(NSURLRequest *)request { 281 | static NSSet * _acceptablePathExtension = nil; 282 | static dispatch_once_t onceToken; 283 | dispatch_once(&onceToken, ^{ 284 | _acceptablePathExtension = [[NSSet alloc] initWithObjects:@"tif", @"tiff", @"jpg", @"jpeg", @"gif", @"png", @"ico", @"bmp", @"cur", nil]; 285 | }); 286 | 287 | return [_acceptablePathExtension containsObject:[[request URL] pathExtension]] || [super canProcessRequest:request]; 288 | } 289 | 290 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 291 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 292 | { 293 | #pragma clang diagnostic push 294 | #pragma clang diagnostic ignored "-Warc-retain-cycles" 295 | #pragma clang diagnostic ignored "-Wgnu" 296 | 297 | self.completionBlock = ^ { 298 | dispatch_async(image_request_operation_processing_queue(), ^(void) { 299 | if (self.error) { 300 | if (failure) { 301 | dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ 302 | failure(self, self.error); 303 | }); 304 | } 305 | } else { 306 | if (success) { 307 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 308 | UIImage *image = nil; 309 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 310 | NSImage *image = nil; 311 | #endif 312 | 313 | image = self.responseImage; 314 | 315 | dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ 316 | success(self, image); 317 | }); 318 | } 319 | } 320 | }); 321 | }; 322 | #pragma clang diagnostic pop 323 | } 324 | 325 | @end 326 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.m 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "AFHTTPRequestOperation.h" 24 | #import 25 | 26 | // Workaround for change in imp_implementationWithBlock() with Xcode 4.5 27 | #if defined(__IPHONE_6_0) || defined(__MAC_10_8) 28 | #define AF_CAST_TO_BLOCK id 29 | #else 30 | #define AF_CAST_TO_BLOCK __bridge void * 31 | #endif 32 | 33 | #pragma clang diagnostic push 34 | #pragma clang diagnostic ignored "-Wstrict-selector-match" 35 | 36 | NSSet * AFContentTypesFromHTTPHeader(NSString *string) { 37 | if (!string) { 38 | return nil; 39 | } 40 | 41 | NSArray *mediaRanges = [string componentsSeparatedByString:@","]; 42 | NSMutableSet *mutableContentTypes = [NSMutableSet setWithCapacity:mediaRanges.count]; 43 | 44 | [mediaRanges enumerateObjectsUsingBlock:^(NSString *mediaRange, __unused NSUInteger idx, __unused BOOL *stop) { 45 | NSRange parametersRange = [mediaRange rangeOfString:@";"]; 46 | if (parametersRange.location != NSNotFound) { 47 | mediaRange = [mediaRange substringToIndex:parametersRange.location]; 48 | } 49 | 50 | mediaRange = [mediaRange stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 51 | 52 | if (mediaRange.length > 0) { 53 | [mutableContentTypes addObject:mediaRange]; 54 | } 55 | }]; 56 | 57 | return [NSSet setWithSet:mutableContentTypes]; 58 | } 59 | 60 | static void AFGetMediaTypeAndSubtypeWithString(NSString *string, NSString **type, NSString **subtype) { 61 | NSScanner *scanner = [NSScanner scannerWithString:string]; 62 | [scanner setCharactersToBeSkipped:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 63 | [scanner scanUpToString:@"/" intoString:type]; 64 | [scanner scanString:@"/" intoString:nil]; 65 | [scanner scanUpToString:@";" intoString:subtype]; 66 | } 67 | 68 | static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) { 69 | NSMutableString *string = [NSMutableString string]; 70 | 71 | NSRange range = NSMakeRange([indexSet firstIndex], 1); 72 | while (range.location != NSNotFound) { 73 | NSUInteger nextIndex = [indexSet indexGreaterThanIndex:range.location]; 74 | while (nextIndex == range.location + range.length) { 75 | range.length++; 76 | nextIndex = [indexSet indexGreaterThanIndex:nextIndex]; 77 | } 78 | 79 | if (string.length) { 80 | [string appendString:@","]; 81 | } 82 | 83 | if (range.length == 1) { 84 | [string appendFormat:@"%lu", (long)range.location]; 85 | } else { 86 | NSUInteger firstIndex = range.location; 87 | NSUInteger lastIndex = firstIndex + range.length - 1; 88 | [string appendFormat:@"%lu-%lu", (long)firstIndex, (long)lastIndex]; 89 | } 90 | 91 | range.location = nextIndex; 92 | range.length = 1; 93 | } 94 | 95 | return string; 96 | } 97 | 98 | static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL selector, id block) { 99 | Method originalMethod = class_getClassMethod(klass, selector); 100 | IMP implementation = imp_implementationWithBlock((AF_CAST_TO_BLOCK)block); 101 | class_replaceMethod(objc_getMetaClass([NSStringFromClass(klass) UTF8String]), selector, implementation, method_getTypeEncoding(originalMethod)); 102 | } 103 | 104 | #pragma mark - 105 | 106 | @interface AFHTTPRequestOperation () 107 | @property (readwrite, nonatomic, strong) NSURLRequest *request; 108 | @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; 109 | @property (readwrite, nonatomic, strong) NSError *HTTPError; 110 | @end 111 | 112 | @implementation AFHTTPRequestOperation 113 | @synthesize HTTPError = _HTTPError; 114 | @synthesize successCallbackQueue = _successCallbackQueue; 115 | @synthesize failureCallbackQueue = _failureCallbackQueue; 116 | @dynamic request; 117 | @dynamic response; 118 | 119 | - (void)dealloc { 120 | if (_successCallbackQueue) { 121 | #if !OS_OBJECT_USE_OBJC 122 | dispatch_release(_successCallbackQueue); 123 | #endif 124 | _successCallbackQueue = NULL; 125 | } 126 | 127 | if (_failureCallbackQueue) { 128 | #if !OS_OBJECT_USE_OBJC 129 | dispatch_release(_failureCallbackQueue); 130 | #endif 131 | _failureCallbackQueue = NULL; 132 | } 133 | } 134 | 135 | - (NSError *)error { 136 | if (!self.HTTPError && self.response) { 137 | if (![self hasAcceptableStatusCode] || ![self hasAcceptableContentType]) { 138 | NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; 139 | [userInfo setValue:self.responseString forKey:NSLocalizedRecoverySuggestionErrorKey]; 140 | [userInfo setValue:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; 141 | [userInfo setValue:self.request forKey:AFNetworkingOperationFailingURLRequestErrorKey]; 142 | [userInfo setValue:self.response forKey:AFNetworkingOperationFailingURLResponseErrorKey]; 143 | 144 | if (![self hasAcceptableStatusCode]) { 145 | NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200; 146 | [userInfo setValue:[NSString stringWithFormat:NSLocalizedStringFromTable(@"Expected status code in (%@), got %d", @"AFNetworking", nil), AFStringFromIndexSet([[self class] acceptableStatusCodes]), statusCode] forKey:NSLocalizedDescriptionKey]; 147 | self.HTTPError = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo]; 148 | } else if (![self hasAcceptableContentType]) { 149 | // Don't invalidate content type if there is no content 150 | if ([self.responseData length] > 0) { 151 | [userInfo setValue:[NSString stringWithFormat:NSLocalizedStringFromTable(@"Expected content type %@, got %@", @"AFNetworking", nil), [[self class] acceptableContentTypes], [self.response MIMEType]] forKey:NSLocalizedDescriptionKey]; 152 | self.HTTPError = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; 153 | } 154 | } 155 | } 156 | } 157 | 158 | if (self.HTTPError) { 159 | return self.HTTPError; 160 | } else { 161 | return [super error]; 162 | } 163 | } 164 | 165 | - (NSStringEncoding)responseStringEncoding { 166 | // When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP. Data in character sets other than "ISO-8859-1" or its subsets MUST be labeled with an appropriate charset value. 167 | // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.4.1 168 | if (self.response && !self.response.textEncodingName && self.responseData && [self.response respondsToSelector:@selector(allHeaderFields)]) { 169 | NSString *type = nil; 170 | AFGetMediaTypeAndSubtypeWithString([[self.response allHeaderFields] valueForKey:@"Content-Type"], &type, nil); 171 | 172 | if ([type isEqualToString:@"text"]) { 173 | return NSISOLatin1StringEncoding; 174 | } 175 | } 176 | 177 | return [super responseStringEncoding]; 178 | } 179 | 180 | - (void)pause { 181 | unsigned long long offset = 0; 182 | if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { 183 | offset = [[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; 184 | } else { 185 | offset = [[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length]; 186 | } 187 | 188 | NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy]; 189 | if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) { 190 | [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; 191 | } 192 | [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; 193 | self.request = mutableURLRequest; 194 | 195 | [super pause]; 196 | } 197 | 198 | - (BOOL)hasAcceptableStatusCode { 199 | if (!self.response) { 200 | return NO; 201 | } 202 | 203 | NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200; 204 | return ![[self class] acceptableStatusCodes] || [[[self class] acceptableStatusCodes] containsIndex:statusCode]; 205 | } 206 | 207 | - (BOOL)hasAcceptableContentType { 208 | if (!self.response) { 209 | return NO; 210 | } 211 | 212 | // Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource. If the media type remains unknown, the recipient SHOULD treat it as type "application/octet-stream". 213 | // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html 214 | NSString *contentType = [self.response MIMEType]; 215 | if (!contentType) { 216 | contentType = @"application/octet-stream"; 217 | } 218 | 219 | return ![[self class] acceptableContentTypes] || [[[self class] acceptableContentTypes] containsObject:contentType]; 220 | } 221 | 222 | - (void)setSuccessCallbackQueue:(dispatch_queue_t)successCallbackQueue { 223 | if (successCallbackQueue != _successCallbackQueue) { 224 | if (_successCallbackQueue) { 225 | #if !OS_OBJECT_USE_OBJC 226 | dispatch_release(_successCallbackQueue); 227 | #endif 228 | _successCallbackQueue = NULL; 229 | } 230 | 231 | if (successCallbackQueue) { 232 | #if !OS_OBJECT_USE_OBJC 233 | dispatch_retain(successCallbackQueue); 234 | #endif 235 | _successCallbackQueue = successCallbackQueue; 236 | } 237 | } 238 | } 239 | 240 | - (void)setFailureCallbackQueue:(dispatch_queue_t)failureCallbackQueue { 241 | if (failureCallbackQueue != _failureCallbackQueue) { 242 | if (_failureCallbackQueue) { 243 | #if !OS_OBJECT_USE_OBJC 244 | dispatch_release(_failureCallbackQueue); 245 | #endif 246 | _failureCallbackQueue = NULL; 247 | } 248 | 249 | if (failureCallbackQueue) { 250 | #if !OS_OBJECT_USE_OBJC 251 | dispatch_retain(failureCallbackQueue); 252 | #endif 253 | _failureCallbackQueue = failureCallbackQueue; 254 | } 255 | } 256 | } 257 | 258 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 259 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 260 | { 261 | // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. 262 | #pragma clang diagnostic push 263 | #pragma clang diagnostic ignored "-Warc-retain-cycles" 264 | #pragma clang diagnostic ignored "-Wgnu" 265 | self.completionBlock = ^{ 266 | if (self.error) { 267 | if (failure) { 268 | dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ 269 | failure(self, self.error); 270 | }); 271 | } 272 | } else { 273 | if (success) { 274 | dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ 275 | success(self, self.responseData); 276 | }); 277 | } 278 | } 279 | }; 280 | #pragma clang diagnostic pop 281 | } 282 | 283 | #pragma mark - AFHTTPRequestOperation 284 | 285 | + (NSIndexSet *)acceptableStatusCodes { 286 | return [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; 287 | } 288 | 289 | + (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes { 290 | NSMutableIndexSet *mutableStatusCodes = [[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]]; 291 | [mutableStatusCodes addIndexes:statusCodes]; 292 | AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(__unused id _self) { 293 | return mutableStatusCodes; 294 | }); 295 | } 296 | 297 | + (NSSet *)acceptableContentTypes { 298 | return nil; 299 | } 300 | 301 | + (void)addAcceptableContentTypes:(NSSet *)contentTypes { 302 | NSMutableSet *mutableContentTypes = [[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES]; 303 | [mutableContentTypes unionSet:contentTypes]; 304 | AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(__unused id _self) { 305 | return mutableContentTypes; 306 | }); 307 | } 308 | 309 | + (BOOL)canProcessRequest:(NSURLRequest *)request { 310 | if ([[self class] isEqual:[AFHTTPRequestOperation class]]) { 311 | return YES; 312 | } 313 | 314 | return [[self acceptableContentTypes] intersectsSet:AFContentTypesFromHTTPHeader([request valueForHTTPHeaderField:@"Accept"])]; 315 | } 316 | 317 | @end 318 | 319 | #pragma clang diagnostic pop 320 | -------------------------------------------------------------------------------- /AFProgressiveImageDownload.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 24383D952DE74E219B67C39B /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8199CBAFCF7B43378737DE5E /* libPods.a */; }; 11 | B5B1564E177F9EDF0029F6D4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5B1564D177F9EDF0029F6D4 /* UIKit.framework */; }; 12 | B5B15650177F9EDF0029F6D4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5B1564F177F9EDF0029F6D4 /* Foundation.framework */; }; 13 | B5B15652177F9EDF0029F6D4 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5B15651177F9EDF0029F6D4 /* CoreGraphics.framework */; }; 14 | B5B15658177F9EDF0029F6D4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B5B15656177F9EDF0029F6D4 /* InfoPlist.strings */; }; 15 | B5B1565A177F9EDF0029F6D4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B15659177F9EDF0029F6D4 /* main.m */; }; 16 | B5B1565E177F9EDF0029F6D4 /* AFAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B1565D177F9EDF0029F6D4 /* AFAppDelegate.m */; }; 17 | B5B15660177F9EDF0029F6D4 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = B5B1565F177F9EDF0029F6D4 /* Default.png */; }; 18 | B5B15662177F9EDF0029F6D4 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B5B15661177F9EDF0029F6D4 /* Default@2x.png */; }; 19 | B5B15664177F9EDF0029F6D4 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B5B15663177F9EDF0029F6D4 /* Default-568h@2x.png */; }; 20 | B5B15667177F9EDF0029F6D4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B15666177F9EDF0029F6D4 /* ViewController.m */; }; 21 | B5B1566A177F9EDF0029F6D4 /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5B15668177F9EDF0029F6D4 /* ViewController.xib */; }; 22 | B5B15672177FA4A50029F6D4 /* img-placeholder.png in Resources */ = {isa = PBXBuildFile; fileRef = B5B15671177FA4A50029F6D4 /* img-placeholder.png */; }; 23 | B5B15678177FB5590029F6D4 /* UIImageView+AFProgressiveImageDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B15676177FB5590029F6D4 /* UIImageView+AFProgressiveImageDownload.m */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | 8199CBAFCF7B43378737DE5E /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | B5B1564A177F9EDF0029F6D4 /* AFProgressiveImageDownload.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AFProgressiveImageDownload.app; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | B5B1564D177F9EDF0029F6D4 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 30 | B5B1564F177F9EDF0029F6D4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 31 | B5B15651177F9EDF0029F6D4 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 32 | B5B15655177F9EDF0029F6D4 /* AFProgressiveImageDownload-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AFProgressiveImageDownload-Info.plist"; sourceTree = ""; }; 33 | B5B15657177F9EDF0029F6D4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 34 | B5B15659177F9EDF0029F6D4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 35 | B5B1565B177F9EDF0029F6D4 /* AFProgressiveImageDownload-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AFProgressiveImageDownload-Prefix.pch"; sourceTree = ""; }; 36 | B5B1565C177F9EDF0029F6D4 /* AFAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AFAppDelegate.h; sourceTree = ""; }; 37 | B5B1565D177F9EDF0029F6D4 /* AFAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AFAppDelegate.m; sourceTree = ""; }; 38 | B5B1565F177F9EDF0029F6D4 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 39 | B5B15661177F9EDF0029F6D4 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 40 | B5B15663177F9EDF0029F6D4 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 41 | B5B15665177F9EDF0029F6D4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 42 | B5B15666177F9EDF0029F6D4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 43 | B5B15669177F9EDF0029F6D4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController.xib; sourceTree = ""; }; 44 | B5B15671177FA4A50029F6D4 /* img-placeholder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "img-placeholder.png"; sourceTree = ""; }; 45 | B5B15676177FB5590029F6D4 /* UIImageView+AFProgressiveImageDownload.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFProgressiveImageDownload.m"; sourceTree = ""; }; 46 | B5B15677177FB5590029F6D4 /* UIImageView+AFProgressiveImageDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFProgressiveImageDownload.h"; sourceTree = ""; }; 47 | C0748F86A3184EED84B6B600 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = SOURCE_ROOT; }; 48 | /* End PBXFileReference section */ 49 | 50 | /* Begin PBXFrameworksBuildPhase section */ 51 | B5B15647177F9EDF0029F6D4 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | B5B1564E177F9EDF0029F6D4 /* UIKit.framework in Frameworks */, 56 | B5B15650177F9EDF0029F6D4 /* Foundation.framework in Frameworks */, 57 | B5B15652177F9EDF0029F6D4 /* CoreGraphics.framework in Frameworks */, 58 | 24383D952DE74E219B67C39B /* libPods.a in Frameworks */, 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | B5B15641177F9EDF0029F6D4 = { 66 | isa = PBXGroup; 67 | children = ( 68 | B5B15670177F9F8F0029F6D4 /* AFProgressiveImageDownload */, 69 | B5B15653177F9EDF0029F6D4 /* Example App */, 70 | B5B1564C177F9EDF0029F6D4 /* Frameworks */, 71 | B5B1564B177F9EDF0029F6D4 /* Products */, 72 | C0748F86A3184EED84B6B600 /* Pods.xcconfig */, 73 | ); 74 | sourceTree = ""; 75 | }; 76 | B5B1564B177F9EDF0029F6D4 /* Products */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | B5B1564A177F9EDF0029F6D4 /* AFProgressiveImageDownload.app */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | B5B1564C177F9EDF0029F6D4 /* Frameworks */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | B5B1564D177F9EDF0029F6D4 /* UIKit.framework */, 88 | B5B1564F177F9EDF0029F6D4 /* Foundation.framework */, 89 | B5B15651177F9EDF0029F6D4 /* CoreGraphics.framework */, 90 | 8199CBAFCF7B43378737DE5E /* libPods.a */, 91 | ); 92 | name = Frameworks; 93 | sourceTree = ""; 94 | }; 95 | B5B15653177F9EDF0029F6D4 /* Example App */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | B5B1565C177F9EDF0029F6D4 /* AFAppDelegate.h */, 99 | B5B1565D177F9EDF0029F6D4 /* AFAppDelegate.m */, 100 | B5B15665177F9EDF0029F6D4 /* ViewController.h */, 101 | B5B15666177F9EDF0029F6D4 /* ViewController.m */, 102 | B5B15668177F9EDF0029F6D4 /* ViewController.xib */, 103 | B5B15654177F9EDF0029F6D4 /* Supporting Files */, 104 | ); 105 | name = "Example App"; 106 | path = Example; 107 | sourceTree = ""; 108 | }; 109 | B5B15654177F9EDF0029F6D4 /* Supporting Files */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | B5B15671177FA4A50029F6D4 /* img-placeholder.png */, 113 | B5B15655177F9EDF0029F6D4 /* AFProgressiveImageDownload-Info.plist */, 114 | B5B15656177F9EDF0029F6D4 /* InfoPlist.strings */, 115 | B5B15659177F9EDF0029F6D4 /* main.m */, 116 | B5B1565B177F9EDF0029F6D4 /* AFProgressiveImageDownload-Prefix.pch */, 117 | B5B1565F177F9EDF0029F6D4 /* Default.png */, 118 | B5B15661177F9EDF0029F6D4 /* Default@2x.png */, 119 | B5B15663177F9EDF0029F6D4 /* Default-568h@2x.png */, 120 | ); 121 | name = "Supporting Files"; 122 | sourceTree = ""; 123 | }; 124 | B5B15670177F9F8F0029F6D4 /* AFProgressiveImageDownload */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | B5B15676177FB5590029F6D4 /* UIImageView+AFProgressiveImageDownload.m */, 128 | B5B15677177FB5590029F6D4 /* UIImageView+AFProgressiveImageDownload.h */, 129 | ); 130 | path = AFProgressiveImageDownload; 131 | sourceTree = ""; 132 | }; 133 | /* End PBXGroup section */ 134 | 135 | /* Begin PBXNativeTarget section */ 136 | B5B15649177F9EDF0029F6D4 /* AFProgressiveImageDownload */ = { 137 | isa = PBXNativeTarget; 138 | buildConfigurationList = B5B1566D177F9EDF0029F6D4 /* Build configuration list for PBXNativeTarget "AFProgressiveImageDownload" */; 139 | buildPhases = ( 140 | 88B83506B36E4570B626A089 /* Check Pods Manifest.lock */, 141 | B5B15646177F9EDF0029F6D4 /* Sources */, 142 | B5B15647177F9EDF0029F6D4 /* Frameworks */, 143 | B5B15648177F9EDF0029F6D4 /* Resources */, 144 | 78097BD4E84C454F84E226A1 /* Copy Pods Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | ); 150 | name = AFProgressiveImageDownload; 151 | productName = AFProgressImageDownload; 152 | productReference = B5B1564A177F9EDF0029F6D4 /* AFProgressiveImageDownload.app */; 153 | productType = "com.apple.product-type.application"; 154 | }; 155 | /* End PBXNativeTarget section */ 156 | 157 | /* Begin PBXProject section */ 158 | B5B15642177F9EDF0029F6D4 /* Project object */ = { 159 | isa = PBXProject; 160 | attributes = { 161 | CLASSPREFIX = AF; 162 | LastUpgradeCheck = 0460; 163 | ORGANIZATIONNAME = "Fickle Bits"; 164 | }; 165 | buildConfigurationList = B5B15645177F9EDF0029F6D4 /* Build configuration list for PBXProject "AFProgressiveImageDownload" */; 166 | compatibilityVersion = "Xcode 3.2"; 167 | developmentRegion = English; 168 | hasScannedForEncodings = 0; 169 | knownRegions = ( 170 | en, 171 | ); 172 | mainGroup = B5B15641177F9EDF0029F6D4; 173 | productRefGroup = B5B1564B177F9EDF0029F6D4 /* Products */; 174 | projectDirPath = ""; 175 | projectRoot = ""; 176 | targets = ( 177 | B5B15649177F9EDF0029F6D4 /* AFProgressiveImageDownload */, 178 | ); 179 | }; 180 | /* End PBXProject section */ 181 | 182 | /* Begin PBXResourcesBuildPhase section */ 183 | B5B15648177F9EDF0029F6D4 /* Resources */ = { 184 | isa = PBXResourcesBuildPhase; 185 | buildActionMask = 2147483647; 186 | files = ( 187 | B5B15658177F9EDF0029F6D4 /* InfoPlist.strings in Resources */, 188 | B5B15660177F9EDF0029F6D4 /* Default.png in Resources */, 189 | B5B15662177F9EDF0029F6D4 /* Default@2x.png in Resources */, 190 | B5B15664177F9EDF0029F6D4 /* Default-568h@2x.png in Resources */, 191 | B5B1566A177F9EDF0029F6D4 /* ViewController.xib in Resources */, 192 | B5B15672177FA4A50029F6D4 /* img-placeholder.png in Resources */, 193 | ); 194 | runOnlyForDeploymentPostprocessing = 0; 195 | }; 196 | /* End PBXResourcesBuildPhase section */ 197 | 198 | /* Begin PBXShellScriptBuildPhase section */ 199 | 78097BD4E84C454F84E226A1 /* Copy Pods Resources */ = { 200 | isa = PBXShellScriptBuildPhase; 201 | buildActionMask = 2147483647; 202 | files = ( 203 | ); 204 | inputPaths = ( 205 | ); 206 | name = "Copy Pods Resources"; 207 | outputPaths = ( 208 | ); 209 | runOnlyForDeploymentPostprocessing = 0; 210 | shellPath = /bin/sh; 211 | shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n"; 212 | }; 213 | 88B83506B36E4570B626A089 /* Check Pods Manifest.lock */ = { 214 | isa = PBXShellScriptBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | ); 218 | inputPaths = ( 219 | ); 220 | name = "Check Pods Manifest.lock"; 221 | outputPaths = ( 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | shellPath = /bin/sh; 225 | 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"; 226 | }; 227 | /* End PBXShellScriptBuildPhase section */ 228 | 229 | /* Begin PBXSourcesBuildPhase section */ 230 | B5B15646177F9EDF0029F6D4 /* Sources */ = { 231 | isa = PBXSourcesBuildPhase; 232 | buildActionMask = 2147483647; 233 | files = ( 234 | B5B1565A177F9EDF0029F6D4 /* main.m in Sources */, 235 | B5B1565E177F9EDF0029F6D4 /* AFAppDelegate.m in Sources */, 236 | B5B15667177F9EDF0029F6D4 /* ViewController.m in Sources */, 237 | B5B15678177FB5590029F6D4 /* UIImageView+AFProgressiveImageDownload.m in Sources */, 238 | ); 239 | runOnlyForDeploymentPostprocessing = 0; 240 | }; 241 | /* End PBXSourcesBuildPhase section */ 242 | 243 | /* Begin PBXVariantGroup section */ 244 | B5B15656177F9EDF0029F6D4 /* InfoPlist.strings */ = { 245 | isa = PBXVariantGroup; 246 | children = ( 247 | B5B15657177F9EDF0029F6D4 /* en */, 248 | ); 249 | name = InfoPlist.strings; 250 | sourceTree = ""; 251 | }; 252 | B5B15668177F9EDF0029F6D4 /* ViewController.xib */ = { 253 | isa = PBXVariantGroup; 254 | children = ( 255 | B5B15669177F9EDF0029F6D4 /* en */, 256 | ); 257 | name = ViewController.xib; 258 | sourceTree = ""; 259 | }; 260 | /* End PBXVariantGroup section */ 261 | 262 | /* Begin XCBuildConfiguration section */ 263 | B5B1566B177F9EDF0029F6D4 /* Debug */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | ALWAYS_SEARCH_USER_PATHS = NO; 267 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 268 | CLANG_CXX_LIBRARY = "libc++"; 269 | CLANG_ENABLE_OBJC_ARC = YES; 270 | CLANG_WARN_CONSTANT_CONVERSION = YES; 271 | CLANG_WARN_EMPTY_BODY = YES; 272 | CLANG_WARN_ENUM_CONVERSION = YES; 273 | CLANG_WARN_INT_CONVERSION = YES; 274 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 275 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 276 | COPY_PHASE_STRIP = NO; 277 | GCC_C_LANGUAGE_STANDARD = gnu99; 278 | GCC_DYNAMIC_NO_PIC = NO; 279 | GCC_OPTIMIZATION_LEVEL = 0; 280 | GCC_PREPROCESSOR_DEFINITIONS = ( 281 | "DEBUG=1", 282 | "$(inherited)", 283 | ); 284 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 286 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 287 | GCC_WARN_UNUSED_VARIABLE = YES; 288 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 289 | ONLY_ACTIVE_ARCH = YES; 290 | SDKROOT = iphoneos; 291 | }; 292 | name = Debug; 293 | }; 294 | B5B1566C177F9EDF0029F6D4 /* Release */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | ALWAYS_SEARCH_USER_PATHS = NO; 298 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 299 | CLANG_CXX_LIBRARY = "libc++"; 300 | CLANG_ENABLE_OBJC_ARC = YES; 301 | CLANG_WARN_CONSTANT_CONVERSION = YES; 302 | CLANG_WARN_EMPTY_BODY = YES; 303 | CLANG_WARN_ENUM_CONVERSION = YES; 304 | CLANG_WARN_INT_CONVERSION = YES; 305 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 306 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 307 | COPY_PHASE_STRIP = YES; 308 | GCC_C_LANGUAGE_STANDARD = gnu99; 309 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 310 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 311 | GCC_WARN_UNUSED_VARIABLE = YES; 312 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 313 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 314 | SDKROOT = iphoneos; 315 | VALIDATE_PRODUCT = YES; 316 | }; 317 | name = Release; 318 | }; 319 | B5B1566E177F9EDF0029F6D4 /* Debug */ = { 320 | isa = XCBuildConfiguration; 321 | baseConfigurationReference = C0748F86A3184EED84B6B600 /* Pods.xcconfig */; 322 | buildSettings = { 323 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 324 | GCC_PREFIX_HEADER = "Example/AFProgressiveImageDownload-Prefix.pch"; 325 | INFOPLIST_FILE = "Example/AFProgressiveImageDownload-Info.plist"; 326 | PRODUCT_NAME = AFProgressiveImageDownload; 327 | WRAPPER_EXTENSION = app; 328 | }; 329 | name = Debug; 330 | }; 331 | B5B1566F177F9EDF0029F6D4 /* Release */ = { 332 | isa = XCBuildConfiguration; 333 | baseConfigurationReference = C0748F86A3184EED84B6B600 /* Pods.xcconfig */; 334 | buildSettings = { 335 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 336 | GCC_PREFIX_HEADER = "Example/AFProgressiveImageDownload-Prefix.pch"; 337 | INFOPLIST_FILE = "Example/AFProgressiveImageDownload-Info.plist"; 338 | PRODUCT_NAME = AFProgressiveImageDownload; 339 | WRAPPER_EXTENSION = app; 340 | }; 341 | name = Release; 342 | }; 343 | /* End XCBuildConfiguration section */ 344 | 345 | /* Begin XCConfigurationList section */ 346 | B5B15645177F9EDF0029F6D4 /* Build configuration list for PBXProject "AFProgressiveImageDownload" */ = { 347 | isa = XCConfigurationList; 348 | buildConfigurations = ( 349 | B5B1566B177F9EDF0029F6D4 /* Debug */, 350 | B5B1566C177F9EDF0029F6D4 /* Release */, 351 | ); 352 | defaultConfigurationIsVisible = 0; 353 | defaultConfigurationName = Release; 354 | }; 355 | B5B1566D177F9EDF0029F6D4 /* Build configuration list for PBXNativeTarget "AFProgressiveImageDownload" */ = { 356 | isa = XCConfigurationList; 357 | buildConfigurations = ( 358 | B5B1566E177F9EDF0029F6D4 /* Debug */, 359 | B5B1566F177F9EDF0029F6D4 /* Release */, 360 | ); 361 | defaultConfigurationIsVisible = 0; 362 | defaultConfigurationName = Release; 363 | }; 364 | /* End XCConfigurationList section */ 365 | }; 366 | rootObject = B5B15642177F9EDF0029F6D4 /* Project object */; 367 | } 368 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h: -------------------------------------------------------------------------------- 1 | // AFURLConnectionOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | /** 28 | `AFURLConnectionOperation` is a subclass of `NSOperation` that implements `NSURLConnection` delegate methods. 29 | 30 | ## Subclassing Notes 31 | 32 | This is the base class of all network request operations. You may wish to create your own subclass in order to implement additional `NSURLConnection` delegate methods (see "`NSURLConnection` Delegate Methods" below), or to provide additional properties and/or class constructors. 33 | 34 | If you are creating a subclass that communicates over the HTTP or HTTPS protocols, you may want to consider subclassing `AFHTTPRequestOperation` instead, as it supports specifying acceptable content types or status codes. 35 | 36 | ## NSURLConnection Delegate Methods 37 | 38 | `AFURLConnectionOperation` implements the following `NSURLConnection` delegate methods: 39 | 40 | - `connection:didReceiveResponse:` 41 | - `connection:didReceiveData:` 42 | - `connectionDidFinishLoading:` 43 | - `connection:didFailWithError:` 44 | - `connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:` 45 | - `connection:willCacheResponse:` 46 | - `connectionShouldUseCredentialStorage:` 47 | - `connection:needNewBodyStream:` 48 | 49 | When _AFNETWORKING_PIN_SSL_CERTIFICATES_ is defined, the following authentication delegate method is implemented: 50 | 51 | - `connection:willSendRequestForAuthenticationChallenge:` 52 | 53 | Otherwise, the following authentication delegate methods are implemented: 54 | 55 | - `connection:canAuthenticateAgainstProtectionSpace:` 56 | - `connection:didReceiveAuthenticationChallenge:` 57 | 58 | If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. 59 | 60 | ## Class Constructors 61 | 62 | Class constructors, or methods that return an unowned instance, are the preferred way for subclasses to encapsulate any particular logic for handling the setup or parsing of response data. For instance, `AFJSONRequestOperation` provides `JSONRequestOperationWithRequest:success:failure:`, which takes block arguments, whose parameter on for a successful request is the JSON object initialized from the `response data`. 63 | 64 | ## Callbacks and Completion Blocks 65 | 66 | The built-in `completionBlock` provided by `NSOperation` allows for custom behavior to be executed after the request finishes. It is a common pattern for class constructors in subclasses to take callback block parameters, and execute them conditionally in the body of its `completionBlock`. Make sure to handle cancelled operations appropriately when setting a `completionBlock` (i.e. returning early before parsing response data). See the implementation of any of the `AFHTTPRequestOperation` subclasses for an example of this. 67 | 68 | Subclasses are strongly discouraged from overriding `setCompletionBlock:`, as `AFURLConnectionOperation`'s implementation includes a workaround to mitigate retain cycles, and what Apple rather ominously refers to as ["The Deallocation Problem"](http://developer.apple.com/library/ios/#technotes/tn2109/). 69 | 70 | ## SSL Pinning 71 | 72 | Relying on the CA trust model to validate SSL certificates exposes your app to security vulnerabilities, such as man-in-the-middle attacks. For applications that connect to known servers, SSL certificate pinning provides an increased level of security, by checking server certificate validity against those specified in the app bundle. 73 | 74 | SSL with certificate pinning is strongly recommended for any application that transmits sensitive information to an external webservice. 75 | 76 | When `_AFNETWORKING_PIN_SSL_CERTIFICATES_` is defined and the Security framework is linked, connections will be validated on all matching certificates with a `.cer` extension in the bundle root. 77 | 78 | ## NSCoding & NSCopying Conformance 79 | 80 | `AFURLConnectionOperation` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. However, because of the intrinsic limitations of capturing the exact state of an operation at a particular moment, there are some important caveats to keep in mind: 81 | 82 | ### NSCoding Caveats 83 | 84 | - Encoded operations do not include any block or stream properties. Be sure to set `completionBlock`, `outputStream`, and any callback blocks as necessary when using `-initWithCoder:` or `NSKeyedUnarchiver`. 85 | - Operations are paused on `encodeWithCoder:`. If the operation was encoded while paused or still executing, its archived state will return `YES` for `isReady`. Otherwise, the state of an operation when encoding will remain unchanged. 86 | 87 | ### NSCopying Caveats 88 | 89 | - `-copy` and `-copyWithZone:` return a new operation with the `NSURLRequest` of the original. So rather than an exact copy of the operation at that particular instant, the copying mechanism returns a completely new instance, which can be useful for retrying operations. 90 | - A copy of an operation will not include the `outputStream` of the original. 91 | - Operation copies do not include `completionBlock`. `completionBlock` often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. 92 | */ 93 | 94 | #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ 95 | typedef enum { 96 | AFSSLPinningModeNone, 97 | AFSSLPinningModePublicKey, 98 | AFSSLPinningModeCertificate, 99 | } AFURLConnectionOperationSSLPinningMode; 100 | #endif 101 | 102 | @interface AFURLConnectionOperation : NSOperation = 50000) || \ 104 | (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080) 105 | NSURLConnectionDataDelegate, 106 | #endif 107 | NSCoding, NSCopying> 108 | 109 | ///------------------------------- 110 | /// @name Accessing Run Loop Modes 111 | ///------------------------------- 112 | 113 | /** 114 | The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing `NSRunLoopCommonModes`. 115 | */ 116 | @property (nonatomic, strong) NSSet *runLoopModes; 117 | 118 | ///----------------------------------------- 119 | /// @name Getting URL Connection Information 120 | ///----------------------------------------- 121 | 122 | /** 123 | The request used by the operation's connection. 124 | */ 125 | @property (readonly, nonatomic, strong) NSURLRequest *request; 126 | 127 | /** 128 | The last response received by the operation's connection. 129 | */ 130 | @property (readonly, nonatomic, strong) NSURLResponse *response; 131 | 132 | /** 133 | The error, if any, that occurred in the lifecycle of the request. 134 | */ 135 | @property (readonly, nonatomic, strong) NSError *error; 136 | 137 | /** 138 | Whether the connection should accept an invalid SSL certificate. 139 | 140 | If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`. 141 | */ 142 | @property (nonatomic, assign) BOOL allowsInvalidSSLCertificate; 143 | 144 | ///---------------------------- 145 | /// @name Getting Response Data 146 | ///---------------------------- 147 | 148 | /** 149 | The data received during the request. 150 | */ 151 | @property (readonly, nonatomic, strong) NSData *responseData; 152 | 153 | /** 154 | The string representation of the response data. 155 | */ 156 | @property (readonly, nonatomic, copy) NSString *responseString; 157 | 158 | /** 159 | The string encoding of the response. 160 | 161 | If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. 162 | */ 163 | @property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; 164 | 165 | ///------------------------------- 166 | /// @name Managing URL Credentials 167 | ///------------------------------- 168 | 169 | /** 170 | Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. 171 | 172 | This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. 173 | */ 174 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage; 175 | 176 | /** 177 | The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. 178 | 179 | This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. 180 | */ 181 | @property (nonatomic, strong) NSURLCredential *credential; 182 | 183 | /** 184 | The pinning mode which will be used for SSL connections. `AFSSLPinningModePublicKey` by default. 185 | 186 | To enable SSL Pinning, `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` in `Prefix.pch`. Also, make sure that the Security framework is linked with the binary. See the "SSL Pinning" section in the `AFURLConnectionOperation`" header for more information. 187 | */ 188 | #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ 189 | @property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode SSLPinningMode; 190 | #endif 191 | 192 | ///------------------------ 193 | /// @name Accessing Streams 194 | ///------------------------ 195 | 196 | /** 197 | The input stream used to read data to be sent during the request. 198 | 199 | This property acts as a proxy to the `HTTPBodyStream` property of `request`. 200 | */ 201 | @property (nonatomic, strong) NSInputStream *inputStream; 202 | 203 | /** 204 | The output stream that is used to write data received until the request is finished. 205 | 206 | By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. 207 | */ 208 | @property (nonatomic, strong) NSOutputStream *outputStream; 209 | 210 | ///--------------------------------------------- 211 | /// @name Managing Request Operation Information 212 | ///--------------------------------------------- 213 | 214 | /** 215 | The user info dictionary for the receiver. 216 | */ 217 | @property (nonatomic, strong) NSDictionary *userInfo; 218 | 219 | ///------------------------------------------------------ 220 | /// @name Initializing an AFURLConnectionOperation Object 221 | ///------------------------------------------------------ 222 | 223 | /** 224 | Initializes and returns a newly allocated operation object with a url connection configured with the specified url request. 225 | 226 | This is the designated initializer. 227 | 228 | @param urlRequest The request object to be used by the operation connection. 229 | */ 230 | - (id)initWithRequest:(NSURLRequest *)urlRequest; 231 | 232 | ///---------------------------------- 233 | /// @name Pausing / Resuming Requests 234 | ///---------------------------------- 235 | 236 | /** 237 | Pauses the execution of the request operation. 238 | 239 | A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. 240 | */ 241 | - (void)pause; 242 | 243 | /** 244 | Whether the request operation is currently paused. 245 | 246 | @return `YES` if the operation is currently paused, otherwise `NO`. 247 | */ 248 | - (BOOL)isPaused; 249 | 250 | /** 251 | Resumes the execution of the paused request operation. 252 | 253 | Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. 254 | */ 255 | - (void)resume; 256 | 257 | ///---------------------------------------------- 258 | /// @name Configuring Backgrounding Task Behavior 259 | ///---------------------------------------------- 260 | 261 | /** 262 | Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task. 263 | 264 | @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. 265 | */ 266 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 267 | - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler; 268 | #endif 269 | 270 | ///--------------------------------- 271 | /// @name Setting Progress Callbacks 272 | ///--------------------------------- 273 | 274 | /** 275 | Sets a callback to be called when an undetermined number of bytes have been uploaded to the server. 276 | 277 | @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 three arguments: 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. 278 | */ 279 | - (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block; 280 | 281 | /** 282 | Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. 283 | 284 | @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 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 main thread. 285 | */ 286 | - (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block; 287 | 288 | ///------------------------------------------------- 289 | /// @name Setting NSURLConnection Delegate Callbacks 290 | ///------------------------------------------------- 291 | 292 | #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ 293 | /** 294 | Sets a block to be executed when the connection will authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:willSendRequestForAuthenticationChallenge:`. 295 | 296 | @param block A block object to be executed when the connection will authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. This block must invoke one of the challenge-responder methods (NSURLAuthenticationChallengeSender protocol). 297 | 298 | If `allowsInvalidSSLCertificate` is set to YES, `connection:willSendRequestForAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. 299 | */ 300 | - (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; 301 | 302 | #else 303 | 304 | /** 305 | Sets a block to be executed to determine whether the connection should be able to respond to a protection space's form of authentication, as handled by the `NSURLConnectionDelegate` method `connection:canAuthenticateAgainstProtectionSpace:`. 306 | 307 | If `allowsInvalidSSLCertificate` is set to YES, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. 308 | 309 | @param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against. 310 | */ 311 | - (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace))block; 312 | 313 | /** 314 | Sets a block to be executed when the connection must authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:didReceiveAuthenticationChallenge:`. 315 | 316 | @param block A block object to be executed when the connection must authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. 317 | 318 | If `allowsInvalidSSLCertificate` is set to YES, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. 319 | */ 320 | - (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; 321 | 322 | #endif 323 | 324 | /** 325 | Sets a block to be executed when the server redirects the request from one URL to another URL, or when the request URL changed by the `NSURLProtocol` subclass handling the request in order to standardize its format, as handled by the `NSURLConnectionDelegate` method `connection:willSendRequest:redirectResponse:`. 326 | 327 | @param block A block object to be executed when the request URL was changed. The block returns an `NSURLRequest` object, the URL request to redirect, and takes three arguments: the URL connection object, the the proposed redirected request, and the URL response that caused the redirect. 328 | */ 329 | - (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block; 330 | 331 | 332 | /** 333 | Sets a block to be executed to modify the response a connection will cache, if any, as handled by the `NSURLConnectionDelegate` method `connection:willCacheResponse:`. 334 | 335 | @param block A block object to be executed to determine what response a connection will cache, if any. The block returns an `NSCachedURLResponse` object, the cached response to store in memory or `nil` to prevent the response from being cached, and takes two arguments: the URL connection object, and the cached response provided for the request. 336 | */ 337 | - (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block; 338 | 339 | @end 340 | 341 | ///---------------- 342 | /// @name Constants 343 | ///---------------- 344 | 345 | /** 346 | ## SSL Pinning Options 347 | 348 | The following constants are provided by `AFURLConnectionOperation` as possible SSL Pinning options. 349 | 350 | enum { 351 | AFSSLPinningModeNone, 352 | AFSSLPinningModePublicKey, 353 | AFSSLPinningModeCertificate, 354 | } 355 | 356 | `AFSSLPinningModeNone` 357 | Do not pin SSL connections 358 | 359 | `AFSSLPinningModePublicKey` 360 | Pin SSL connections to certificate public key (SPKI). 361 | 362 | `AFSSLPinningModeCertificate` 363 | Pin SSL connections to exact certificate. This may cause problems when your certificate expires and needs re-issuance. 364 | 365 | ## User info dictionary keys 366 | 367 | These keys may exist in the user info dictionary, in addition to those defined for NSError. 368 | 369 | - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` 370 | - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` 371 | 372 | ### Constants 373 | 374 | `AFNetworkingOperationFailingURLRequestErrorKey` 375 | The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFNetworkingErrorDomain`. 376 | 377 | `AFNetworkingOperationFailingURLResponseErrorKey` 378 | The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFNetworkingErrorDomain`. 379 | 380 | ## Error Domains 381 | 382 | The following error domain is predefined. 383 | 384 | - `NSString * const AFNetworkingErrorDomain` 385 | 386 | ### Constants 387 | 388 | `AFNetworkingErrorDomain` 389 | AFNetworking errors. Error codes for `AFNetworkingErrorDomain` correspond to codes in `NSURLErrorDomain`. 390 | */ 391 | extern NSString * const AFNetworkingErrorDomain; 392 | extern NSString * const AFNetworkingOperationFailingURLRequestErrorKey; 393 | extern NSString * const AFNetworkingOperationFailingURLResponseErrorKey; 394 | 395 | ///-------------------- 396 | /// @name Notifications 397 | ///-------------------- 398 | 399 | /** 400 | Posted when an operation begins executing. 401 | */ 402 | extern NSString * const AFNetworkingOperationDidStartNotification; 403 | 404 | /** 405 | Posted when an operation finishes. 406 | */ 407 | extern NSString * const AFNetworkingOperationDidFinishNotification; 408 | -------------------------------------------------------------------------------- /Example/en.lproj/ViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1552 5 | 12E55 6 | 3084 7 | 1187.39 8 | 626.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 2083 12 | 13 | 14 | IBNSLayoutConstraint 15 | IBProxyObject 16 | IBUIButton 17 | IBUIImageView 18 | IBUILabel 19 | IBUIView 20 | 21 | 22 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 23 | 24 | 25 | PluginDependencyRecalculationVersion 26 | 27 | 28 | 29 | 30 | IBFilesOwner 31 | IBCocoaTouchFramework 32 | 33 | 34 | IBFirstResponder 35 | IBCocoaTouchFramework 36 | 37 | 38 | 39 | 274 40 | 41 | 42 | 43 | 292 44 | {{20, 485}, {280, 44}} 45 | 46 | 47 | _NS:9 48 | NO 49 | IBCocoaTouchFramework 50 | 0 51 | 0 52 | 1 53 | Start Download 54 | 55 | 3 56 | MQA 57 | 58 | 59 | 1 60 | MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA 61 | 62 | 63 | 3 64 | MC41AA 65 | 66 | 67 | 2 68 | 15 69 | 70 | 71 | Helvetica-Bold 72 | 15 73 | 16 74 | 75 | 76 | 77 | 78 | 292 79 | {320, 214} 80 | 81 | 82 | 83 | _NS:9 84 | NO 85 | IBCocoaTouchFramework 86 | 87 | 88 | 89 | 292 90 | {{20, 354}, {280, 123}} 91 | 92 | 93 | 94 | _NS:9 95 | NO 96 | YES 97 | 7 98 | NO 99 | IBCocoaTouchFramework 100 | 101 | 102 | 1 103 | MCAwIDAAA 104 | darkTextColor 105 | 106 | 107 | 0 108 | 6 109 | 110 | 1 111 | 16 112 | 113 | 114 | Helvetica 115 | 16 116 | 16 117 | 118 | NO 119 | 280 120 | 121 | 122 | {{0, 20}, {320, 548}} 123 | 124 | 125 | 126 | 127 | 3 128 | MC43NQA 129 | 130 | 2 131 | 132 | 133 | NO 134 | 135 | 136 | IBUIScreenMetrics 137 | 138 | YES 139 | 140 | 141 | 142 | 143 | 144 | {320, 568} 145 | {568, 320} 146 | 147 | 148 | IBCocoaTouchFramework 149 | Retina 4 Full Screen 150 | 2 151 | 152 | IBCocoaTouchFramework 153 | 154 | 155 | 156 | 157 | 158 | 159 | view 160 | 161 | 162 | 163 | 7 164 | 165 | 166 | 167 | imageView 168 | 169 | 170 | 171 | 42 172 | 173 | 174 | 175 | statusLabel 176 | 177 | 178 | 179 | 43 180 | 181 | 182 | 183 | startDownload: 184 | 185 | 186 | 7 187 | 188 | 41 189 | 190 | 191 | 192 | 193 | 194 | 0 195 | 196 | 197 | 198 | 199 | 200 | -1 201 | 202 | 203 | File's Owner 204 | 205 | 206 | -2 207 | 208 | 209 | 210 | 211 | 6 212 | 213 | 214 | 215 | 216 | 217 | 3 218 | 0 219 | 220 | 4 221 | 1 222 | 223 | 8 224 | 225 | 1000 226 | 227 | 6 228 | 24 229 | 3 230 | 231 | 232 | 233 | 6 234 | 0 235 | 236 | 6 237 | 1 238 | 239 | 20 240 | 241 | 1000 242 | 243 | 8 244 | 29 245 | 3 246 | 247 | 248 | 249 | 5 250 | 0 251 | 252 | 5 253 | 1 254 | 255 | 20 256 | 257 | 1000 258 | 259 | 8 260 | 29 261 | 3 262 | 263 | 264 | 265 | 4 266 | 0 267 | 268 | 4 269 | 1 270 | 271 | 20 272 | 273 | 1000 274 | 275 | 8 276 | 29 277 | 3 278 | 279 | 280 | 281 | 6 282 | 0 283 | 284 | 6 285 | 1 286 | 287 | 20 288 | 289 | 1000 290 | 291 | 8 292 | 29 293 | 3 294 | 295 | 296 | 297 | 5 298 | 0 299 | 300 | 5 301 | 1 302 | 303 | 20 304 | 305 | 1000 306 | 307 | 8 308 | 29 309 | 3 310 | 311 | 312 | 313 | 6 314 | 0 315 | 316 | 6 317 | 1 318 | 319 | 0.0 320 | 321 | 1000 322 | 323 | 8 324 | 29 325 | 3 326 | 327 | 328 | 329 | 3 330 | 0 331 | 332 | 3 333 | 1 334 | 335 | 0.0 336 | 337 | 1000 338 | 339 | 8 340 | 29 341 | 3 342 | 343 | 344 | 345 | 5 346 | 0 347 | 348 | 5 349 | 1 350 | 351 | 0.0 352 | 353 | 1000 354 | 355 | 8 356 | 29 357 | 3 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 8 366 | 367 | 368 | 369 | 370 | 371 | 10 372 | 373 | 374 | 375 | 376 | 12 377 | 378 | 379 | 380 | 381 | 14 382 | 383 | 384 | 385 | 386 | 15 387 | 388 | 389 | 390 | 391 | 8 392 | 0 393 | 394 | 0 395 | 1 396 | 397 | 214 398 | 399 | 1000 400 | 401 | 3 402 | 9 403 | 1 404 | 405 | 406 | 407 | 408 | 409 | 23 410 | 411 | 412 | 413 | 414 | 8 415 | 0 416 | 417 | 0 418 | 1 419 | 420 | 123 421 | 422 | 1000 423 | 424 | 3 425 | 9 426 | 1 427 | 428 | 429 | 430 | 431 | 432 | 24 433 | 434 | 435 | 436 | 437 | 26 438 | 439 | 440 | 441 | 442 | 27 443 | 444 | 445 | 446 | 447 | 32 448 | 449 | 450 | 451 | 452 | 35 453 | 454 | 455 | 456 | 457 | 37 458 | 459 | 460 | 461 | 462 | 38 463 | 464 | 465 | 466 | 467 | 40 468 | 469 | 470 | 471 | 472 | 473 | 474 | ViewController 475 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 476 | UIResponder 477 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 478 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 479 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 480 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 481 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 482 | 483 | 484 | 485 | 486 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 487 | 488 | 489 | 490 | 491 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 492 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 493 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 494 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 495 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 496 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 497 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 498 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 499 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 512 | 513 | 514 | 515 | 516 | 517 | 518 | 43 519 | 520 | 521 | 522 | 523 | NSLayoutConstraint 524 | NSObject 525 | 526 | IBProjectSource 527 | ./Classes/NSLayoutConstraint.h 528 | 529 | 530 | 531 | ViewController 532 | UIViewController 533 | 534 | startDownload: 535 | id 536 | 537 | 538 | startDownload: 539 | 540 | startDownload: 541 | id 542 | 543 | 544 | 545 | UIImageView 546 | UILabel 547 | 548 | 549 | 550 | imageView 551 | UIImageView 552 | 553 | 554 | statusLabel 555 | UILabel 556 | 557 | 558 | 559 | IBProjectSource 560 | ./Classes/ViewController.h 561 | 562 | 563 | 564 | 565 | 0 566 | IBCocoaTouchFramework 567 | YES 568 | 3 569 | YES 570 | 2083 571 | 572 | 573 | --------------------------------------------------------------------------------