├── .gitignore ├── Podfile ├── Podfile.lock ├── Pods ├── AFNetworking │ ├── AFNetworking │ │ ├── AFHTTPRequestOperation.h │ │ ├── AFHTTPRequestOperation.m │ │ ├── AFHTTPRequestOperationManager.h │ │ ├── AFHTTPRequestOperationManager.m │ │ ├── AFHTTPSessionManager.h │ │ ├── AFHTTPSessionManager.m │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworkReachabilityManager.m │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFSecurityPolicy.m │ │ ├── AFURLConnectionOperation.h │ │ ├── AFURLConnectionOperation.m │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLRequestSerialization.m │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLResponseSerialization.m │ │ ├── AFURLSessionManager.h │ │ └── AFURLSessionManager.m │ ├── LICENSE │ ├── README.md │ └── UIKit+AFNetworking │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkActivityIndicatorManager.m │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIActivityIndicatorView+AFNetworking.m │ │ ├── UIAlertView+AFNetworking.h │ │ ├── UIAlertView+AFNetworking.m │ │ ├── UIButton+AFNetworking.h │ │ ├── UIButton+AFNetworking.m │ │ ├── UIImage+AFNetworking.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIImageView+AFNetworking.m │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.m │ │ ├── UIRefreshControl+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.m │ │ ├── UIWebView+AFNetworking.h │ │ └── UIWebView+AFNetworking.m ├── BDBOAuth1Manager │ ├── BDBOAuth1Manager │ │ ├── BDBOAuth1RequestOperationManager.h │ │ ├── BDBOAuth1RequestOperationManager.m │ │ ├── BDBOAuth1RequestSerializer.h │ │ ├── BDBOAuth1RequestSerializer.m │ │ ├── BDBOAuth1SessionManager.h │ │ ├── BDBOAuth1SessionManager.m │ │ └── Categories │ │ │ ├── NSDictionary+BDBOAuth1Manager.h │ │ │ ├── NSDictionary+BDBOAuth1Manager.m │ │ │ ├── NSString+BDBOAuth1Manager.h │ │ │ └── NSString+BDBOAuth1Manager.m │ ├── LICENSE │ └── README.md ├── Manifest.lock ├── Pods.xcodeproj │ └── project.pbxproj └── Target Support Files │ ├── AFNetworking │ ├── AFNetworking-dummy.m │ ├── AFNetworking-prefix.pch │ ├── AFNetworking-umbrella.h │ ├── AFNetworking.modulemap │ ├── AFNetworking.xcconfig │ └── Info.plist │ ├── BDBOAuth1Manager │ ├── BDBOAuth1Manager-dummy.m │ ├── BDBOAuth1Manager-prefix.pch │ ├── BDBOAuth1Manager-umbrella.h │ ├── BDBOAuth1Manager.modulemap │ ├── BDBOAuth1Manager.xcconfig │ └── Info.plist │ ├── Pods-Yelp │ ├── Info.plist │ ├── Pods-Yelp-acknowledgements.markdown │ ├── Pods-Yelp-acknowledgements.plist │ ├── Pods-Yelp-dummy.m │ ├── Pods-Yelp-frameworks.sh │ ├── Pods-Yelp-resources.sh │ ├── Pods-Yelp-umbrella.h │ ├── Pods-Yelp.debug.xcconfig │ ├── Pods-Yelp.modulemap │ └── Pods-Yelp.release.xcconfig │ └── Pods-YelpTests │ ├── Info.plist │ ├── Pods-YelpTests-acknowledgements.markdown │ ├── Pods-YelpTests-acknowledgements.plist │ ├── Pods-YelpTests-dummy.m │ ├── Pods-YelpTests-frameworks.sh │ ├── Pods-YelpTests-resources.sh │ ├── Pods-YelpTests-umbrella.h │ ├── Pods-YelpTests.debug.xcconfig │ ├── Pods-YelpTests.modulemap │ └── Pods-YelpTests.release.xcconfig ├── README.md ├── Yelp.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── Yelp.xcworkspace └── contents.xcworkspacedata ├── Yelp ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Business.swift ├── BusinessesViewController.swift ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── stars_0.imageset │ │ ├── Contents.json │ │ ├── regular_0.png │ │ ├── regular_0@3x.png │ │ └── stars_0.png │ ├── stars_1.imageset │ │ ├── Contents.json │ │ ├── regular_1.png │ │ ├── regular_1@3x.png │ │ └── stars_1.png │ ├── stars_1half.imageset │ │ ├── Contents.json │ │ ├── regular_1_half.png │ │ ├── regular_1_half@3x.png │ │ └── stars_1half.png │ ├── stars_2.imageset │ │ ├── Contents.json │ │ ├── regular_2.png │ │ ├── regular_2@3x.png │ │ └── stars_2.png │ ├── stars_2half.imageset │ │ ├── Contents.json │ │ ├── regular_2_half.png │ │ ├── regular_2_half@3x.png │ │ └── stars_2half.png │ ├── stars_3.imageset │ │ ├── Contents.json │ │ ├── regular_3.png │ │ ├── regular_3@3x.png │ │ └── stars_3.png │ ├── stars_3half.imageset │ │ ├── Contents.json │ │ ├── regular_3_half.png │ │ ├── regular_3_half@3x.png │ │ └── stars_3half.png │ ├── stars_4.imageset │ │ ├── Contents.json │ │ ├── regular_4.png │ │ ├── regular_4@3x.png │ │ └── stars_4.png │ ├── stars_4half.imageset │ │ ├── Contents.json │ │ ├── regular_4_half.png │ │ ├── regular_4_half@3x.png │ │ └── stars_4half.png │ └── stars_5.imageset │ │ ├── Contents.json │ │ ├── regular_5.png │ │ ├── regular_5@3x.png │ │ └── stars_5.png ├── Info.plist └── YelpClient.swift └── YelpTests ├── Info.plist └── YelpTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS 2 | .DS_Store 3 | 4 | # Xcode 5 | # 6 | build/ 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | *.xcuserstate 22 | 23 | # CocoaPods 24 | # 25 | # We recommend against adding the Pods directory to your .gitignore. However 26 | # you should judge for yourself, the pros and cons are mentioned at: 27 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 28 | # 29 | # Pods/ 30 | 31 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'Yelp' do 5 | # Comment this line if you're not using Swift and don't want to use dynamic frameworks 6 | use_frameworks! 7 | 8 | # Pods for Yelp 9 | pod 'AFNetworking', '~> 2.5' 10 | pod 'BDBOAuth1Manager' 11 | 12 | target 'YelpTests' do 13 | inherit! :search_paths 14 | # Pods for testing 15 | end 16 | 17 | end 18 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (2.6.3): 3 | - AFNetworking/NSURLConnection (= 2.6.3) 4 | - AFNetworking/NSURLSession (= 2.6.3) 5 | - AFNetworking/Reachability (= 2.6.3) 6 | - AFNetworking/Security (= 2.6.3) 7 | - AFNetworking/Serialization (= 2.6.3) 8 | - AFNetworking/UIKit (= 2.6.3) 9 | - AFNetworking/NSURLConnection (2.6.3): 10 | - AFNetworking/Reachability 11 | - AFNetworking/Security 12 | - AFNetworking/Serialization 13 | - AFNetworking/NSURLSession (2.6.3): 14 | - AFNetworking/Reachability 15 | - AFNetworking/Security 16 | - AFNetworking/Serialization 17 | - AFNetworking/Reachability (2.6.3) 18 | - AFNetworking/Security (2.6.3) 19 | - AFNetworking/Serialization (2.6.3) 20 | - AFNetworking/UIKit (2.6.3): 21 | - AFNetworking/NSURLConnection 22 | - AFNetworking/NSURLSession 23 | - BDBOAuth1Manager (1.6.0): 24 | - AFNetworking/NSURLConnection (~> 2.6.0) 25 | - AFNetworking/NSURLSession (~> 2.6.0) 26 | 27 | DEPENDENCIES: 28 | - AFNetworking (~> 2.5) 29 | - BDBOAuth1Manager 30 | 31 | SPEC CHECKSUMS: 32 | AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60 33 | BDBOAuth1Manager: cd5a5872f355ca38180d52ca2dd844f0b0c84797 34 | 35 | PODFILE CHECKSUM: e93d023552e6cb9e3bc0b66e42e1d29f24efef97 36 | 37 | COCOAPODS: 1.0.1 38 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import "AFURLConnectionOperation.h" 24 | 25 | NS_ASSUME_NONNULL_BEGIN 26 | 27 | /** 28 | `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. 29 | */ 30 | @interface AFHTTPRequestOperation : AFURLConnectionOperation 31 | 32 | ///------------------------------------------------ 33 | /// @name Getting HTTP URL Connection Information 34 | ///------------------------------------------------ 35 | 36 | /** 37 | The last HTTP response received by the operation's connection. 38 | */ 39 | @property (readonly, nonatomic, strong, nullable) NSHTTPURLResponse *response; 40 | 41 | /** 42 | Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. 43 | 44 | @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value 45 | */ 46 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 47 | 48 | /** 49 | An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error. 50 | */ 51 | @property (readonly, nonatomic, strong, nullable) id responseObject; 52 | 53 | ///----------------------------------------------------------- 54 | /// @name Setting Completion Block Success / Failure Callbacks 55 | ///----------------------------------------------------------- 56 | 57 | /** 58 | 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. 59 | 60 | This method should be overridden in subclasses in order to specify the response object passed into the success block. 61 | 62 | @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. 63 | @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. 64 | */ 65 | - (void)setCompletionBlockWithSuccess:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success 66 | failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; 67 | 68 | @end 69 | 70 | NS_ASSUME_NONNULL_END 71 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.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 "AFURLRequestSerialization.h" 30 | #import "AFURLResponseSerialization.h" 31 | #import "AFSecurityPolicy.h" 32 | #if !TARGET_OS_WATCH 33 | #import "AFNetworkReachabilityManager.h" 34 | #import "AFURLConnectionOperation.h" 35 | #import "AFHTTPRequestOperation.h" 36 | #import "AFHTTPRequestOperationManager.h" 37 | #endif 38 | 39 | #if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ 40 | ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) || \ 41 | TARGET_OS_WATCH ) 42 | #import "AFURLSessionManager.h" 43 | #import "AFHTTPSessionManager.h" 44 | #endif 45 | 46 | #endif /* _AFNETWORKING_ */ 47 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | // AFSecurityPolicy.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import 24 | 25 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { 26 | AFSSLPinningModeNone, 27 | AFSSLPinningModePublicKey, 28 | AFSSLPinningModeCertificate, 29 | }; 30 | 31 | /** 32 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. 33 | 34 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. 35 | */ 36 | 37 | NS_ASSUME_NONNULL_BEGIN 38 | 39 | @interface AFSecurityPolicy : NSObject 40 | 41 | /** 42 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. 43 | */ 44 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; 45 | 46 | /** 47 | The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. Note that if you create an array with duplicate certificates, the duplicate certificates will be removed. Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. 48 | */ 49 | @property (nonatomic, strong, nullable) NSArray *pinnedCertificates; 50 | 51 | /** 52 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. 53 | */ 54 | @property (nonatomic, assign) BOOL allowInvalidCertificates; 55 | 56 | /** 57 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. 58 | */ 59 | @property (nonatomic, assign) BOOL validatesDomainName; 60 | 61 | ///----------------------------------------- 62 | /// @name Getting Specific Security Policies 63 | ///----------------------------------------- 64 | 65 | /** 66 | Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. 67 | 68 | @return The default security policy. 69 | */ 70 | + (instancetype)defaultPolicy; 71 | 72 | ///--------------------- 73 | /// @name Initialization 74 | ///--------------------- 75 | 76 | /** 77 | Creates and returns a security policy with the specified pinning mode. 78 | 79 | @param pinningMode The SSL pinning mode. 80 | 81 | @return A new security policy. 82 | */ 83 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; 84 | 85 | ///------------------------------ 86 | /// @name Evaluating Server Trust 87 | ///------------------------------ 88 | 89 | /** 90 | Whether or not the specified server trust should be accepted, based on the security policy. 91 | 92 | This method should be used when responding to an authentication challenge from a server. 93 | 94 | @param serverTrust The X.509 certificate trust of the server. 95 | 96 | @return Whether or not to trust the server. 97 | 98 | @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. 99 | */ 100 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; 101 | 102 | /** 103 | Whether or not the specified server trust should be accepted, based on the security policy. 104 | 105 | This method should be used when responding to an authentication challenge from a server. 106 | 107 | @param serverTrust The X.509 certificate trust of the server. 108 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 109 | 110 | @return Whether or not to trust the server. 111 | */ 112 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 113 | forDomain:(nullable NSString *)domain; 114 | 115 | @end 116 | 117 | NS_ASSUME_NONNULL_END 118 | 119 | ///---------------- 120 | /// @name Constants 121 | ///---------------- 122 | 123 | /** 124 | ## SSL Pinning Modes 125 | 126 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. 127 | 128 | enum { 129 | AFSSLPinningModeNone, 130 | AFSSLPinningModePublicKey, 131 | AFSSLPinningModeCertificate, 132 | } 133 | 134 | `AFSSLPinningModeNone` 135 | Do not used pinned certificates to validate servers. 136 | 137 | `AFSSLPinningModePublicKey` 138 | Validate host certificates against public keys of pinned certificates. 139 | 140 | `AFSSLPinningModeCertificate` 141 | Validate host certificates against pinned certificates. 142 | */ 143 | -------------------------------------------------------------------------------- /Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 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 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | `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. 34 | 35 | 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: 36 | 37 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 38 | 39 | By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. 40 | 41 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 42 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 43 | */ 44 | NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") 45 | @interface AFNetworkActivityIndicatorManager : NSObject 46 | 47 | /** 48 | A Boolean value indicating whether the manager is enabled. 49 | 50 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 51 | */ 52 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 53 | 54 | /** 55 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. 56 | */ 57 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; 58 | 59 | /** 60 | Returns the shared network activity indicator manager object for the system. 61 | 62 | @return The systemwide network activity indicator manager. 63 | */ 64 | + (instancetype)sharedManager; 65 | 66 | /** 67 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 68 | */ 69 | - (void)incrementActivityCount; 70 | 71 | /** 72 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. 73 | */ 74 | - (void)decrementActivityCount; 75 | 76 | @end 77 | 78 | NS_ASSUME_NONNULL_END 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "AFNetworkActivityIndicatorManager.h" 23 | 24 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) 25 | 26 | #import "AFHTTPRequestOperation.h" 27 | 28 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 29 | #import "AFURLSessionManager.h" 30 | #endif 31 | 32 | static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; 33 | 34 | static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { 35 | if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) { 36 | return [(AFURLConnectionOperation *)[notification object] request]; 37 | } 38 | 39 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 40 | if ([[notification object] respondsToSelector:@selector(originalRequest)]) { 41 | return [(NSURLSessionTask *)[notification object] originalRequest]; 42 | } 43 | #endif 44 | 45 | return nil; 46 | } 47 | 48 | @interface AFNetworkActivityIndicatorManager () 49 | @property (readwrite, nonatomic, assign) NSInteger activityCount; 50 | @property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer; 51 | @property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 52 | 53 | - (void)updateNetworkActivityIndicatorVisibility; 54 | - (void)updateNetworkActivityIndicatorVisibilityDelayed; 55 | @end 56 | 57 | @implementation AFNetworkActivityIndicatorManager 58 | @dynamic networkActivityIndicatorVisible; 59 | 60 | + (instancetype)sharedManager { 61 | static AFNetworkActivityIndicatorManager *_sharedManager = nil; 62 | static dispatch_once_t oncePredicate; 63 | dispatch_once(&oncePredicate, ^{ 64 | _sharedManager = [[self alloc] init]; 65 | }); 66 | 67 | return _sharedManager; 68 | } 69 | 70 | + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { 71 | return [NSSet setWithObject:@"activityCount"]; 72 | } 73 | 74 | - (id)init { 75 | self = [super init]; 76 | if (!self) { 77 | return nil; 78 | } 79 | 80 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; 81 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; 82 | 83 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 84 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; 85 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; 86 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; 87 | #endif 88 | 89 | return self; 90 | } 91 | 92 | - (void)dealloc { 93 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 94 | 95 | [_activityIndicatorVisibilityTimer invalidate]; 96 | } 97 | 98 | - (void)updateNetworkActivityIndicatorVisibilityDelayed { 99 | if (self.enabled) { 100 | // Delay hiding of activity indicator for a short interval, to avoid flickering 101 | if (![self isNetworkActivityIndicatorVisible]) { 102 | [self.activityIndicatorVisibilityTimer invalidate]; 103 | self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO]; 104 | [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes]; 105 | } else { 106 | [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]]; 107 | } 108 | } 109 | } 110 | 111 | - (BOOL)isNetworkActivityIndicatorVisible { 112 | return self.activityCount > 0; 113 | } 114 | 115 | - (void)updateNetworkActivityIndicatorVisibility { 116 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; 117 | } 118 | 119 | - (void)setActivityCount:(NSInteger)activityCount { 120 | @synchronized(self) { 121 | _activityCount = activityCount; 122 | } 123 | 124 | dispatch_async(dispatch_get_main_queue(), ^{ 125 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 126 | }); 127 | } 128 | 129 | - (void)incrementActivityCount { 130 | [self willChangeValueForKey:@"activityCount"]; 131 | @synchronized(self) { 132 | _activityCount++; 133 | } 134 | [self didChangeValueForKey:@"activityCount"]; 135 | 136 | dispatch_async(dispatch_get_main_queue(), ^{ 137 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 138 | }); 139 | } 140 | 141 | - (void)decrementActivityCount { 142 | [self willChangeValueForKey:@"activityCount"]; 143 | @synchronized(self) { 144 | #pragma clang diagnostic push 145 | #pragma clang diagnostic ignored "-Wgnu" 146 | _activityCount = MAX(_activityCount - 1, 0); 147 | #pragma clang diagnostic pop 148 | } 149 | [self didChangeValueForKey:@"activityCount"]; 150 | 151 | dispatch_async(dispatch_get_main_queue(), ^{ 152 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 153 | }); 154 | } 155 | 156 | - (void)networkRequestDidStart:(NSNotification *)notification { 157 | if ([AFNetworkRequestFromNotification(notification) URL]) { 158 | [self incrementActivityCount]; 159 | } 160 | } 161 | 162 | - (void)networkRequestDidFinish:(NSNotification *)notification { 163 | if ([AFNetworkRequestFromNotification(notification) URL]) { 164 | [self decrementActivityCount]; 165 | } 166 | } 167 | 168 | @end 169 | 170 | #endif 171 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | @class AFURLConnectionOperation; 31 | 32 | /** 33 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a request operation or session task. 34 | */ 35 | @interface UIActivityIndicatorView (AFNetworking) 36 | 37 | ///---------------------------------- 38 | /// @name Animating for Session Tasks 39 | ///---------------------------------- 40 | 41 | /** 42 | Binds the animating state to the state of the specified task. 43 | 44 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 45 | */ 46 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 47 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; 48 | #endif 49 | 50 | ///--------------------------------------- 51 | /// @name Animating for Request Operations 52 | ///--------------------------------------- 53 | 54 | /** 55 | Binds the animating state to the execution state of the specified operation. 56 | 57 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 58 | */ 59 | - (void)setAnimatingWithStateOfOperation:(nullable AFURLConnectionOperation *)operation; 60 | 61 | @end 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIActivityIndicatorView+AFNetworking.h" 23 | #import 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 26 | 27 | #import "AFHTTPRequestOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | @interface AFActivityIndicatorViewNotificationObserver : NSObject 34 | @property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; 35 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; 36 | 37 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 38 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; 39 | #endif 40 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation; 41 | 42 | @end 43 | 44 | @implementation UIActivityIndicatorView (AFNetworking) 45 | 46 | - (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { 47 | AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 48 | if (notificationObserver == nil) { 49 | notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; 50 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 51 | } 52 | return notificationObserver; 53 | } 54 | 55 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 56 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 57 | [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; 58 | } 59 | #endif 60 | 61 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { 62 | [[self af_notificationObserver] setAnimatingWithStateOfOperation:operation]; 63 | } 64 | 65 | @end 66 | 67 | @implementation AFActivityIndicatorViewNotificationObserver 68 | 69 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView 70 | { 71 | self = [super init]; 72 | if (self) { 73 | _activityIndicatorView = activityIndicatorView; 74 | } 75 | return self; 76 | } 77 | 78 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 79 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 80 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 81 | 82 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 83 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 84 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 85 | 86 | if (task) { 87 | if (task.state != NSURLSessionTaskStateCompleted) { 88 | 89 | #pragma clang diagnostic push 90 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 91 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 92 | if (task.state == NSURLSessionTaskStateRunning) { 93 | [self.activityIndicatorView startAnimating]; 94 | } else { 95 | [self.activityIndicatorView stopAnimating]; 96 | } 97 | #pragma clang diagnostic pop 98 | 99 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; 100 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; 101 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; 102 | } 103 | } 104 | } 105 | #endif 106 | 107 | #pragma mark - 108 | 109 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { 110 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 111 | 112 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 113 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 114 | 115 | if (operation) { 116 | if (![operation isFinished]) { 117 | 118 | #pragma clang diagnostic push 119 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 120 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 121 | if ([operation isExecuting]) { 122 | [self.activityIndicatorView startAnimating]; 123 | } else { 124 | [self.activityIndicatorView stopAnimating]; 125 | } 126 | #pragma clang diagnostic pop 127 | 128 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation]; 129 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation]; 130 | } 131 | } 132 | } 133 | 134 | #pragma mark - 135 | 136 | - (void)af_startAnimating { 137 | dispatch_async(dispatch_get_main_queue(), ^{ 138 | #pragma clang diagnostic push 139 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 140 | [self.activityIndicatorView startAnimating]; 141 | #pragma clang diagnostic pop 142 | }); 143 | } 144 | 145 | - (void)af_stopAnimating { 146 | dispatch_async(dispatch_get_main_queue(), ^{ 147 | #pragma clang diagnostic push 148 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 149 | [self.activityIndicatorView stopAnimating]; 150 | #pragma clang diagnostic pop 151 | }); 152 | } 153 | 154 | #pragma mark - 155 | 156 | - (void)dealloc { 157 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 158 | 159 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 160 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 161 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 162 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 163 | #endif 164 | 165 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 166 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 167 | } 168 | 169 | @end 170 | 171 | #endif 172 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFURLConnectionOperation; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error. 36 | */ 37 | @interface UIAlertView (AFNetworking) 38 | 39 | ///------------------------------------- 40 | /// @name Showing Alert for Session Task 41 | ///------------------------------------- 42 | 43 | /** 44 | Shows an alert view with the error of the specified session task, if any. 45 | 46 | @param task The session task. 47 | @param delegate The alert view delegate. 48 | */ 49 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 50 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 51 | delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); 52 | #endif 53 | 54 | /** 55 | Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles. 56 | 57 | @param task The session task. 58 | @param delegate The alert view delegate. 59 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. 60 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. 61 | */ 62 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 63 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 64 | delegate:(nullable id)delegate 65 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 66 | otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); 67 | #endif 68 | 69 | ///------------------------------------------ 70 | /// @name Showing Alert for Request Operation 71 | ///------------------------------------------ 72 | 73 | /** 74 | Shows an alert view with the error of the specified request operation, if any. 75 | 76 | @param operation The request operation. 77 | @param delegate The alert view delegate. 78 | */ 79 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 80 | delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); 81 | 82 | /** 83 | Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles. 84 | 85 | @param operation The request operation. 86 | @param delegate The alert view delegate. 87 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. 88 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. 89 | */ 90 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 91 | delegate:(nullable id)delegate 92 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 93 | otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); 94 | 95 | @end 96 | 97 | NS_ASSUME_NONNULL_END 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIAlertView+AFNetworking.h" 23 | 24 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 25 | 26 | #import "AFURLConnectionOperation.h" 27 | 28 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 29 | #import "AFURLSessionManager.h" 30 | #endif 31 | 32 | static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) { 33 | if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) { 34 | *title = error.localizedDescription; 35 | 36 | if (error.localizedRecoverySuggestion) { 37 | *message = error.localizedRecoverySuggestion; 38 | } else { 39 | *message = error.localizedFailureReason; 40 | } 41 | } else if (error.localizedDescription) { 42 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 43 | *message = error.localizedDescription; 44 | } else { 45 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 46 | *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code]; 47 | } 48 | } 49 | 50 | @implementation UIAlertView (AFNetworking) 51 | 52 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 53 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 54 | delegate:(id)delegate 55 | { 56 | [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; 57 | } 58 | 59 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 60 | delegate:(id)delegate 61 | cancelButtonTitle:(NSString *)cancelButtonTitle 62 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 63 | { 64 | NSMutableArray *mutableOtherTitles = [NSMutableArray array]; 65 | va_list otherButtonTitleList; 66 | va_start(otherButtonTitleList, otherButtonTitles); 67 | { 68 | for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { 69 | [mutableOtherTitles addObject:otherButtonTitle]; 70 | } 71 | } 72 | va_end(otherButtonTitleList); 73 | 74 | __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 75 | NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey]; 76 | if (error) { 77 | NSString *title, *message; 78 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 79 | 80 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; 81 | for (NSString *otherButtonTitle in mutableOtherTitles) { 82 | [alertView addButtonWithTitle:otherButtonTitle]; 83 | } 84 | [alertView setTitle:title]; 85 | [alertView setMessage:message]; 86 | [alertView show]; 87 | } 88 | 89 | [[NSNotificationCenter defaultCenter] removeObserver:observer]; 90 | }]; 91 | } 92 | #endif 93 | 94 | #pragma mark - 95 | 96 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 97 | delegate:(id)delegate 98 | { 99 | [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; 100 | } 101 | 102 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 103 | delegate:(id)delegate 104 | cancelButtonTitle:(NSString *)cancelButtonTitle 105 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 106 | { 107 | NSMutableArray *mutableOtherTitles = [NSMutableArray array]; 108 | va_list otherButtonTitleList; 109 | va_start(otherButtonTitleList, otherButtonTitles); 110 | { 111 | for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { 112 | [mutableOtherTitles addObject:otherButtonTitle]; 113 | } 114 | } 115 | va_end(otherButtonTitleList); 116 | 117 | __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 118 | 119 | if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) { 120 | NSError *error = [(AFURLConnectionOperation *)notification.object error]; 121 | if (error) { 122 | NSString *title, *message; 123 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 124 | 125 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; 126 | for (NSString *otherButtonTitle in mutableOtherTitles) { 127 | [alertView addButtonWithTitle:otherButtonTitle]; 128 | } 129 | [alertView setTitle:title]; 130 | [alertView setMessage:message]; 131 | [alertView show]; 132 | } 133 | } 134 | 135 | [[NSNotificationCenter defaultCenter] removeObserver:observer]; 136 | }]; 137 | } 138 | 139 | @end 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+AFNetworking.h 3 | // 4 | // 5 | // Created by Paulo Ferreira on 08/07/15. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 26 | 27 | #import 28 | 29 | @interface UIImage (AFNetworking) 30 | 31 | + (UIImage*) safeImageWithData:(NSData*)data; 32 | 33 | @end 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @protocol AFURLResponseSerialization, AFImageCache; 33 | 34 | /** 35 | 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. 36 | */ 37 | @interface UIImageView (AFNetworking) 38 | 39 | ///---------------------------- 40 | /// @name Accessing Image Cache 41 | ///---------------------------- 42 | 43 | /** 44 | The image cache used to improve image loading performance on scroll views. By default, this is an `NSCache` subclass conforming to the `AFImageCache` protocol, which listens for notification warnings and evicts objects accordingly. 45 | */ 46 | + (id )sharedImageCache; 47 | 48 | /** 49 | Set the cache used for image loading. 50 | 51 | @param imageCache The image cache. 52 | */ 53 | + (void)setSharedImageCache:(__nullable id )imageCache; 54 | 55 | ///------------------------------------ 56 | /// @name Accessing Response Serializer 57 | ///------------------------------------ 58 | 59 | /** 60 | The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. 61 | 62 | @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer 63 | */ 64 | @property (nonatomic, strong) id imageResponseSerializer; 65 | 66 | ///-------------------- 67 | /// @name Setting Image 68 | ///-------------------- 69 | 70 | /** 71 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 72 | 73 | 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. 74 | 75 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 76 | 77 | @param url The URL used for the image request. 78 | */ 79 | - (void)setImageWithURL:(NSURL *)url; 80 | 81 | /** 82 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 83 | 84 | 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. 85 | 86 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 87 | 88 | @param url The URL used for the image request. 89 | @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. 90 | */ 91 | - (void)setImageWithURL:(NSURL *)url 92 | placeholderImage:(nullable UIImage *)placeholderImage; 93 | 94 | /** 95 | Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 96 | 97 | 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. 98 | 99 | If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. 100 | 101 | @param urlRequest The URL request used for the image request. 102 | @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. 103 | @param success A block to be executed when the image request 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 image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. 104 | @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. 105 | */ 106 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 107 | placeholderImage:(nullable UIImage *)placeholderImage 108 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success 109 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, NSError *error))failure; 110 | 111 | /** 112 | Cancels any executing image operation for the receiver, if one exists. 113 | */ 114 | - (void)cancelImageRequestOperation; 115 | 116 | @end 117 | 118 | #pragma mark - 119 | 120 | /** 121 | The `AFImageCache` protocol is adopted by an object used to cache images loaded by the AFNetworking category on `UIImageView`. 122 | */ 123 | @protocol AFImageCache 124 | 125 | /** 126 | Returns a cached image for the specified request, if available. 127 | 128 | @param request The image request. 129 | 130 | @return The cached image. 131 | */ 132 | - (nullable UIImage *)cachedImageForRequest:(NSURLRequest *)request; 133 | 134 | /** 135 | Caches a particular image for the specified request. 136 | 137 | @param image The image to cache. 138 | @param request The request to be used as a cache key. 139 | */ 140 | - (void)cacheImage:(UIImage *)image 141 | forRequest:(NSURLRequest *)request; 142 | @end 143 | 144 | NS_ASSUME_NONNULL_END 145 | 146 | #endif 147 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIKit+AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.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 | #if TARGET_OS_IOS 24 | #import 25 | 26 | #ifndef _UIKIT_AFNETWORKING_ 27 | #define _UIKIT_AFNETWORKING_ 28 | 29 | #import "AFNetworkActivityIndicatorManager.h" 30 | 31 | #import "UIActivityIndicatorView+AFNetworking.h" 32 | #import "UIAlertView+AFNetworking.h" 33 | #import "UIButton+AFNetworking.h" 34 | #import "UIImageView+AFNetworking.h" 35 | #import "UIProgressView+AFNetworking.h" 36 | #import "UIRefreshControl+AFNetworking.h" 37 | #import "UIWebView+AFNetworking.h" 38 | #endif /* _UIKIT_AFNETWORKING_ */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFURLConnectionOperation; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task or request operation. 36 | */ 37 | @interface UIProgressView (AFNetworking) 38 | 39 | ///------------------------------------ 40 | /// @name Setting Session Task Progress 41 | ///------------------------------------ 42 | 43 | /** 44 | Binds the progress to the upload progress of the specified session task. 45 | 46 | @param task The session task. 47 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 48 | */ 49 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 50 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 51 | animated:(BOOL)animated; 52 | #endif 53 | 54 | /** 55 | Binds the progress to the download progress of the specified session task. 56 | 57 | @param task The session task. 58 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 59 | */ 60 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 61 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 62 | animated:(BOOL)animated; 63 | #endif 64 | 65 | ///------------------------------------ 66 | /// @name Setting Session Task Progress 67 | ///------------------------------------ 68 | 69 | /** 70 | Binds the progress to the upload progress of the specified request operation. 71 | 72 | @param operation The request operation. 73 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 74 | */ 75 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation 76 | animated:(BOOL)animated; 77 | 78 | /** 79 | Binds the progress to the download progress of the specified request operation. 80 | 81 | @param operation The request operation. 82 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 83 | */ 84 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation 85 | animated:(BOOL)animated; 86 | 87 | @end 88 | 89 | NS_ASSUME_NONNULL_END 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.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 | 29 | #import 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | @class AFURLConnectionOperation; 34 | 35 | /** 36 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a request operation or session task. 37 | */ 38 | @interface UIRefreshControl (AFNetworking) 39 | 40 | ///----------------------------------- 41 | /// @name Refreshing for Session Tasks 42 | ///----------------------------------- 43 | 44 | /** 45 | Binds the refreshing state to the state of the specified task. 46 | 47 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 48 | */ 49 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 50 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 51 | #endif 52 | 53 | ///---------------------------------------- 54 | /// @name Refreshing for Request Operations 55 | ///---------------------------------------- 56 | 57 | /** 58 | Binds the refreshing state to the execution state of the specified operation. 59 | 60 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 61 | */ 62 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; 63 | 64 | @end 65 | 66 | NS_ASSUME_NONNULL_END 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.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 "UIRefreshControl+AFNetworking.h" 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import "AFHTTPRequestOperation.h" 29 | 30 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 31 | #import "AFURLSessionManager.h" 32 | #endif 33 | 34 | @interface AFRefreshControlNotificationObserver : NSObject 35 | @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; 36 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; 37 | 38 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 39 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 40 | #endif 41 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; 42 | 43 | @end 44 | 45 | @implementation UIRefreshControl (AFNetworking) 46 | 47 | - (AFRefreshControlNotificationObserver *)af_notificationObserver { 48 | AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 49 | if (notificationObserver == nil) { 50 | notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; 51 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 52 | } 53 | return notificationObserver; 54 | } 55 | 56 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 57 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 58 | [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; 59 | } 60 | #endif 61 | 62 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { 63 | [[self af_notificationObserver] setRefreshingWithStateOfOperation:operation]; 64 | } 65 | 66 | @end 67 | 68 | @implementation AFRefreshControlNotificationObserver 69 | 70 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl 71 | { 72 | self = [super init]; 73 | if (self) { 74 | _refreshControl = refreshControl; 75 | } 76 | return self; 77 | } 78 | 79 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 80 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 81 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 82 | 83 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 84 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 85 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 86 | 87 | if (task) { 88 | #pragma clang diagnostic push 89 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 90 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 91 | if (task.state == NSURLSessionTaskStateRunning) { 92 | [self.refreshControl beginRefreshing]; 93 | 94 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; 95 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; 96 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; 97 | } else { 98 | [self.refreshControl endRefreshing]; 99 | } 100 | #pragma clang diagnostic pop 101 | } 102 | } 103 | #endif 104 | 105 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { 106 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 107 | 108 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 109 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 110 | 111 | if (operation) { 112 | #pragma clang diagnostic push 113 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 114 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 115 | if (![operation isFinished]) { 116 | if ([operation isExecuting]) { 117 | [self.refreshControl beginRefreshing]; 118 | } else { 119 | [self.refreshControl endRefreshing]; 120 | } 121 | 122 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation]; 123 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation]; 124 | } 125 | #pragma clang diagnostic pop 126 | } 127 | } 128 | 129 | #pragma mark - 130 | 131 | - (void)af_beginRefreshing { 132 | dispatch_async(dispatch_get_main_queue(), ^{ 133 | #pragma clang diagnostic push 134 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 135 | [self.refreshControl beginRefreshing]; 136 | #pragma clang diagnostic pop 137 | }); 138 | } 139 | 140 | - (void)af_endRefreshing { 141 | dispatch_async(dispatch_get_main_queue(), ^{ 142 | #pragma clang diagnostic push 143 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 144 | [self.refreshControl endRefreshing]; 145 | #pragma clang diagnostic pop 146 | }); 147 | } 148 | 149 | #pragma mark - 150 | 151 | - (void)dealloc { 152 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 153 | 154 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 155 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 156 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 157 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 158 | #endif 159 | 160 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 161 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 162 | } 163 | 164 | @end 165 | 166 | #endif 167 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFHTTPRequestSerializer, AFHTTPResponseSerializer; 33 | @protocol AFURLRequestSerialization, AFURLResponseSerialization; 34 | 35 | /** 36 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. 37 | 38 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. 39 | */ 40 | @interface UIWebView (AFNetworking) 41 | 42 | /** 43 | The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`. 44 | */ 45 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; 46 | 47 | /** 48 | The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`. 49 | */ 50 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 51 | 52 | /** 53 | Asynchronously loads the specified request. 54 | 55 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 56 | @param progress 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. 57 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. 58 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 59 | */ 60 | - (void)loadRequest:(NSURLRequest *)request 61 | progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 62 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 63 | failure:(nullable void (^)(NSError *error))failure; 64 | 65 | /** 66 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. 67 | 68 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 69 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. 70 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. 71 | @param progress 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. 72 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. 73 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 74 | */ 75 | - (void)loadRequest:(NSURLRequest *)request 76 | MIMEType:(nullable NSString *)MIMEType 77 | textEncodingName:(nullable NSString *)textEncodingName 78 | progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 79 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 80 | failure:(nullable void (^)(NSError *error))failure; 81 | 82 | @end 83 | 84 | NS_ASSUME_NONNULL_END 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIWebView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import "AFHTTPRequestOperation.h" 29 | #import "AFURLResponseSerialization.h" 30 | #import "AFURLRequestSerialization.h" 31 | 32 | @interface UIWebView (_AFNetworking) 33 | @property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation; 34 | @end 35 | 36 | @implementation UIWebView (_AFNetworking) 37 | 38 | - (AFHTTPRequestOperation *)af_HTTPRequestOperation { 39 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_HTTPRequestOperation)); 40 | } 41 | 42 | - (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation { 43 | objc_setAssociatedObject(self, @selector(af_HTTPRequestOperation), operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | } 45 | 46 | @end 47 | 48 | #pragma mark - 49 | 50 | @implementation UIWebView (AFNetworking) 51 | 52 | - (AFHTTPRequestSerializer *)requestSerializer { 53 | static AFHTTPRequestSerializer *_af_defaultRequestSerializer = nil; 54 | static dispatch_once_t onceToken; 55 | dispatch_once(&onceToken, ^{ 56 | _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer]; 57 | }); 58 | 59 | #pragma clang diagnostic push 60 | #pragma clang diagnostic ignored "-Wgnu" 61 | return objc_getAssociatedObject(self, @selector(requestSerializer)) ?: _af_defaultRequestSerializer; 62 | #pragma clang diagnostic pop 63 | } 64 | 65 | - (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { 66 | objc_setAssociatedObject(self, @selector(requestSerializer), requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 67 | } 68 | 69 | - (AFHTTPResponseSerializer *)responseSerializer { 70 | static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; 71 | static dispatch_once_t onceToken; 72 | dispatch_once(&onceToken, ^{ 73 | _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; 74 | }); 75 | 76 | #pragma clang diagnostic push 77 | #pragma clang diagnostic ignored "-Wgnu" 78 | return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; 79 | #pragma clang diagnostic pop 80 | } 81 | 82 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 83 | objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 84 | } 85 | 86 | #pragma mark - 87 | 88 | - (void)loadRequest:(NSURLRequest *)request 89 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 90 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 91 | failure:(void (^)(NSError *error))failure 92 | { 93 | [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { 94 | NSStringEncoding stringEncoding = NSUTF8StringEncoding; 95 | if (response.textEncodingName) { 96 | CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); 97 | if (encoding != kCFStringEncodingInvalidId) { 98 | stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); 99 | } 100 | } 101 | 102 | NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; 103 | if (success) { 104 | string = success(response, string); 105 | } 106 | 107 | return [string dataUsingEncoding:stringEncoding]; 108 | } failure:failure]; 109 | } 110 | 111 | - (void)loadRequest:(NSURLRequest *)request 112 | MIMEType:(NSString *)MIMEType 113 | textEncodingName:(NSString *)textEncodingName 114 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 115 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 116 | failure:(void (^)(NSError *error))failure 117 | { 118 | NSParameterAssert(request); 119 | 120 | if (self.af_HTTPRequestOperation) { 121 | [self.af_HTTPRequestOperation cancel]; 122 | } 123 | 124 | request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil]; 125 | 126 | self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 127 | self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer; 128 | 129 | __weak __typeof(self)weakSelf = self; 130 | [self.af_HTTPRequestOperation setDownloadProgressBlock:progress]; 131 | [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) { 132 | NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData; 133 | 134 | #pragma clang diagnostic push 135 | #pragma clang diagnostic ignored "-Wgnu" 136 | __strong __typeof(weakSelf) strongSelf = weakSelf; 137 | [strongSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]]; 138 | 139 | if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) { 140 | [strongSelf.delegate webViewDidFinishLoad:strongSelf]; 141 | } 142 | 143 | #pragma clang diagnostic pop 144 | } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) { 145 | if (failure) { 146 | failure(error); 147 | } 148 | }]; 149 | 150 | [self.af_HTTPRequestOperation start]; 151 | 152 | if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { 153 | [self.delegate webViewDidStartLoad:self]; 154 | } 155 | } 156 | 157 | @end 158 | 159 | #endif 160 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestOperationManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1RequestOperationManager.h 3 | // 4 | // Copyright (c) 2013-2015 Bradley David Bergeron 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import "BDBOAuth1RequestSerializer.h" 26 | 27 | 28 | #pragma mark - 29 | @interface BDBOAuth1RequestOperationManager : AFHTTPRequestOperationManager 30 | 31 | /** 32 | * BDBOAuth1RequestSerializer instance used to serialize HTTP requests. 33 | */ 34 | @property (nonatomic) BDBOAuth1RequestSerializer *requestSerializer; 35 | 36 | 37 | /** 38 | * --------------------------------------------------------------------------------------- 39 | * @name Initialization 40 | * --------------------------------------------------------------------------------------- 41 | */ 42 | #pragma mark Initialization 43 | 44 | /** 45 | * Initialize a new BDBOAuth1RequestOperationManager instance with the given baseURL, consumerKey, and consumerSecret. 46 | * 47 | * @param baseURL Base URL for HTTP requests. 48 | * @param consumerKey OAuth consumer key. 49 | * @param consumerSecret OAuth consumer secret. 50 | * 51 | * @return New BDBOAuth1RequestOperationManager instance. 52 | */ 53 | - (instancetype)initWithBaseURL:(NSURL *)baseURL 54 | consumerKey:(NSString *)consumerKey 55 | consumerSecret:(NSString *)consumerSecret; 56 | 57 | 58 | /** 59 | * --------------------------------------------------------------------------------------- 60 | * @name Authorization Status 61 | * --------------------------------------------------------------------------------------- 62 | */ 63 | #pragma mark Authorization Status 64 | 65 | /** 66 | * Check whehter or not this manager instance has a valid access token. 67 | */ 68 | @property (nonatomic, assign, readonly, getter = isAuthorized) BOOL authorized; 69 | 70 | /** 71 | * Deauthorize this manager instance and remove any associated access token from the keychain. 72 | * 73 | * @return YES if an access token was found and removed from the keychain, NO otherwise. 74 | */ 75 | - (BOOL)deauthorize; 76 | 77 | 78 | /** 79 | * --------------------------------------------------------------------------------------- 80 | * @name OAuth Handshake 81 | * --------------------------------------------------------------------------------------- 82 | */ 83 | #pragma mark OAuth Handshake 84 | 85 | /** 86 | * Fetch an OAuth request token. 87 | * 88 | * @param requestPath OAuth request token endpoint. 89 | * @param method HTTP method for fetching OAuth request token. 90 | * @param callbackURL The URL to be set for oauth_callback. 91 | * @param scope Authorization scope. 92 | * @param success Completion block performed upon successful acquisition of the OAuth request token. 93 | * @param failure Completion block performed if the OAuth request token could not be acquired. 94 | */ 95 | - (void)fetchRequestTokenWithPath:(NSString *)requestPath 96 | method:(NSString *)method 97 | callbackURL:(NSURL *)callbackURL 98 | scope:(NSString *)scope 99 | success:(void (^)(BDBOAuth1Credential *requestToken))success 100 | failure:(void (^)(NSError *error))failure; 101 | 102 | /** 103 | * Fetch an OAuth access token using a previously-acquired request token. 104 | * 105 | * @param accessPath OAuth access token endpoint. 106 | * @param method HTTP method for fetching OAuth access token. 107 | * @param requestToken OAuth request token. 108 | * @param success Completion block performed upon successful acquisition of the OAuth access token. 109 | * @param failure Completion block performed if the OAuth access token could not be acquired. 110 | */ 111 | - (void)fetchAccessTokenWithPath:(NSString *)accessPath 112 | method:(NSString *)method 113 | requestToken:(BDBOAuth1Credential *)requestToken 114 | success:(void (^)(BDBOAuth1Credential *accessToken))success 115 | failure:(void (^)(NSError *error))failure; 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestOperationManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1RequestOperationManager.m 3 | // 4 | // Copyright (c) 2013-2015 Bradley David Bergeron 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | #import "BDBOAuth1RequestOperationManager.h" 24 | 25 | 26 | #pragma mark - 27 | @interface BDBOAuth1RequestOperationManager () 28 | 29 | @end 30 | 31 | 32 | #pragma mark - 33 | @implementation BDBOAuth1RequestOperationManager 34 | 35 | @dynamic requestSerializer; 36 | 37 | #pragma mark Initialization 38 | - (instancetype)initWithBaseURL:(NSURL *)baseURL 39 | consumerKey:(NSString *)consumerKey 40 | consumerSecret:(NSString *)consumerSecret { 41 | self = [super initWithBaseURL:baseURL]; 42 | 43 | if (self) { 44 | self.requestSerializer = [BDBOAuth1RequestSerializer serializerForService:baseURL.host 45 | withConsumerKey:consumerKey 46 | consumerSecret:consumerSecret]; 47 | } 48 | 49 | return self; 50 | } 51 | 52 | #pragma mark Authorization Status 53 | - (BOOL)isAuthorized { 54 | return (self.requestSerializer.accessToken && !self.requestSerializer.accessToken.expired); 55 | } 56 | 57 | - (BOOL)deauthorize { 58 | return [self.requestSerializer removeAccessToken]; 59 | } 60 | 61 | #pragma mark OAuth Handshake 62 | - (void)fetchRequestTokenWithPath:(NSString *)requestPath 63 | method:(NSString *)method 64 | callbackURL:(NSURL *)callbackURL 65 | scope:(NSString *)scope 66 | success:(void (^)(BDBOAuth1Credential *requestToken))success 67 | failure:(void (^)(NSError *error))failure { 68 | self.requestSerializer.requestToken = nil; 69 | 70 | AFHTTPResponseSerializer *defaultSerializer = self.responseSerializer; 71 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 72 | 73 | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; 74 | parameters[BDBOAuth1OAuthCallbackParameter] = [callbackURL absoluteString]; 75 | 76 | if (scope && !self.requestSerializer.accessToken) { 77 | parameters[@"scope"] = scope; 78 | } 79 | 80 | NSString *URLString = [[NSURL URLWithString:requestPath relativeToURL:self.baseURL] absoluteString]; 81 | NSError *error; 82 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:URLString parameters:parameters error:&error]; 83 | 84 | if (error) { 85 | failure(error); 86 | 87 | return; 88 | } 89 | 90 | void (^successBlock)(AFHTTPRequestOperation *, id) = ^(AFHTTPRequestOperation *operation, id responseObject) { 91 | self.responseSerializer = defaultSerializer; 92 | 93 | BDBOAuth1Credential *requestToken = [BDBOAuth1Credential credentialWithQueryString:operation.responseString]; 94 | self.requestSerializer.requestToken = requestToken; 95 | 96 | success(requestToken); 97 | }; 98 | 99 | void (^failureBlock)(AFHTTPRequestOperation *, NSError *) = ^(AFHTTPRequestOperation *operation, NSError *completionError) { 100 | self.responseSerializer = defaultSerializer; 101 | 102 | failure(completionError); 103 | }; 104 | 105 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:successBlock failure:failureBlock]; 106 | [self.operationQueue addOperation:operation]; 107 | } 108 | 109 | - (void)fetchAccessTokenWithPath:(NSString *)accessPath 110 | method:(NSString *)method 111 | requestToken:(BDBOAuth1Credential *)requestToken 112 | success:(void (^)(BDBOAuth1Credential *accessToken))success 113 | failure:(void (^)(NSError *error))failure { 114 | if (!requestToken.token || !requestToken.verifier) { 115 | NSError *error = [[NSError alloc] initWithDomain:BDBOAuth1ErrorDomain 116 | code:NSURLErrorBadServerResponse 117 | userInfo:@{NSLocalizedFailureReasonErrorKey:@"Invalid OAuth response received from server."}]; 118 | 119 | failure(error); 120 | 121 | return; 122 | } 123 | 124 | AFHTTPResponseSerializer *defaultSerializer = self.responseSerializer; 125 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 126 | 127 | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; 128 | parameters[BDBOAuth1OAuthTokenParameter] = requestToken.token; 129 | parameters[BDBOAuth1OAuthVerifierParameter] = requestToken.verifier; 130 | 131 | NSString *URLString = [[NSURL URLWithString:accessPath relativeToURL:self.baseURL] absoluteString]; 132 | NSError *error; 133 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:URLString parameters:parameters error:&error]; 134 | 135 | if (error) { 136 | failure(error); 137 | 138 | return; 139 | } 140 | 141 | void (^successBlock)(AFHTTPRequestOperation *, id) = ^(AFHTTPRequestOperation *operation, id responseObject) { 142 | self.responseSerializer = defaultSerializer; 143 | 144 | self.requestSerializer.requestToken = nil; 145 | 146 | BDBOAuth1Credential *accessToken = [BDBOAuth1Credential credentialWithQueryString:operation.responseString]; 147 | [self.requestSerializer saveAccessToken:accessToken]; 148 | 149 | success(accessToken); 150 | }; 151 | 152 | void (^failureBlock)(AFHTTPRequestOperation *, NSError *) = ^(AFHTTPRequestOperation *operation, NSError *completionError) { 153 | self.responseSerializer = defaultSerializer; 154 | self.requestSerializer.requestToken = nil; 155 | 156 | failure(completionError); 157 | }; 158 | 159 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:successBlock failure:failureBlock]; 160 | [self.operationQueue addOperation:operation]; 161 | } 162 | 163 | @end 164 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestSerializer.h: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1RequestSerializer.h 3 | // 4 | // Copyright (c) 2013-2015 Bradley David Bergeron 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | #import 24 | 25 | 26 | FOUNDATION_EXPORT NSString * const BDBOAuth1ErrorDomain; 27 | 28 | FOUNDATION_EXPORT NSString * const BDBOAuth1OAuthTokenParameter; 29 | FOUNDATION_EXPORT NSString * const BDBOAuth1OAuthTokenSecretParameter; 30 | FOUNDATION_EXPORT NSString * const BDBOAuth1OAuthVerifierParameter; 31 | FOUNDATION_EXPORT NSString * const BDBOAuth1OAuthTokenDurationParameter; 32 | FOUNDATION_EXPORT NSString * const BDBOAuth1OAuthSignatureParameter; 33 | FOUNDATION_EXPORT NSString * const BDBOAuth1OAuthCallbackParameter; 34 | 35 | 36 | #pragma mark - 37 | @interface BDBOAuth1Credential : NSObject 38 | 39 | 40 | /** 41 | * Token ('oauth_token') 42 | */ 43 | @property (nonatomic, copy, readonly) NSString *token; 44 | 45 | /** 46 | * Token secret ('oauth_token_secret') 47 | */ 48 | @property (nonatomic, copy, readonly) NSString *secret; 49 | 50 | /** 51 | * Verifier ('oauth_verifier') 52 | */ 53 | @property (nonatomic, copy) NSString *verifier; 54 | 55 | /** 56 | * Check whether or not this token is expired. 57 | */ 58 | @property (nonatomic, assign, readonly, getter = isExpired) BOOL expired; 59 | 60 | /** 61 | * Additional custom (non-OAuth) parameters included with this credential. 62 | */ 63 | @property (nonatomic) NSDictionary *userInfo; 64 | 65 | 66 | /** 67 | * --------------------------------------------------------------------------------------- 68 | * @name Initialization 69 | * --------------------------------------------------------------------------------------- 70 | */ 71 | #pragma mark Initialization 72 | 73 | /** 74 | * Create a new BDBOAuth1Credential instance with the given token, token secret, and verifier. 75 | * 76 | * @param token OAuth token ('oauth_token'). 77 | * @param secret OAuth token secret ('oauth_token_secret'). 78 | * @param expiration Expiration date or nil if the credential does not expire. 79 | * 80 | * @return New BDBOAuth1Credential. 81 | */ 82 | + (instancetype)credentialWithToken:(NSString *)token 83 | secret:(NSString *)secret 84 | expiration:(NSDate *)expiration; 85 | 86 | /** 87 | * Instantiate a new BDBOAuth1Credential instance with the given token, token secret, and verifier. 88 | * 89 | * @param token OAuth token ('oauth_token'). 90 | * @param secret OAuth token secret ('oauth_token_secret'). 91 | * @param expiration Expiration date or nil if the credential does not expire. 92 | * 93 | * @return New BDBOAuth1Credential. 94 | */ 95 | - (instancetype)initWithToken:(NSString *)token 96 | secret:(NSString *)secret 97 | expiration:(NSDate *)expiration; 98 | 99 | /** 100 | * Create a new BDBOAuth1Credential instance using parameters in the given URL query string. 101 | * 102 | * @param queryString URL query string containing OAuth token parameters. 103 | * 104 | * @return New BDBOAuth1Credential. 105 | */ 106 | + (instancetype)credentialWithQueryString:(NSString *)queryString; 107 | 108 | /** 109 | * Instantiate a new BDBOAuth1Credential instance using parameters in the given URL query string. 110 | * 111 | * @param queryString URL query string containing OAuth token parameters. 112 | * 113 | * @return New BDBOAuth1Credential. 114 | */ 115 | - (instancetype)initWithQueryString:(NSString *)queryString; 116 | 117 | @end 118 | 119 | 120 | #pragma mark - 121 | @interface BDBOAuth1RequestSerializer : AFHTTPRequestSerializer 122 | 123 | /** 124 | * OAuth request token. 125 | */ 126 | @property (nonatomic, copy) BDBOAuth1Credential *requestToken; 127 | 128 | /** 129 | * OAuth access token. 130 | */ 131 | @property (nonatomic, copy, readonly) BDBOAuth1Credential *accessToken; 132 | 133 | 134 | /** 135 | * --------------------------------------------------------------------------------------- 136 | * @name Initialization 137 | * --------------------------------------------------------------------------------------- 138 | */ 139 | #pragma mark Initialization 140 | 141 | /** 142 | * Create a new BDBOAuth1RequestSerializer instance for the given service with its consumerKey and consumerSecret. 143 | * 144 | * @param service Service (base URL) this request serializer is used for. 145 | * @param consumerKey OAuth consumer key. 146 | * @param consumerSecret OAuth consumer secret. 147 | * 148 | * @return New BDBOAuth1RequestSerializer for the specified service. 149 | */ 150 | + (instancetype)serializerForService:(NSString *)service 151 | withConsumerKey:(NSString *)consumerKey 152 | consumerSecret:(NSString *)consumerSecret; 153 | 154 | /** 155 | * Instantiate a new BDBOAuth1RequestSerializer instance for the given service with its consumerKey and consumerSecret. 156 | * 157 | * @param service Service (base URL) this request serializer is used for. 158 | * @param consumerKey OAuth consumer key. 159 | * @param consumerSecret OAuth consumer secret. 160 | * 161 | * @return New BDBOAuth1RequestSerializer for the specified service. 162 | */ 163 | - (instancetype)initWithService:(NSString *)service 164 | consumerKey:(NSString *)consumerKey 165 | consumerSecret:(NSString *)consumerSecret; 166 | 167 | 168 | /** 169 | * --------------------------------------------------------------------------------------- 170 | * @name Storing the Access Token 171 | * --------------------------------------------------------------------------------------- 172 | */ 173 | #pragma mark Storing the Access Token 174 | 175 | /** 176 | * Save the given OAuth access token in the user's keychain for future use with this serializer's service. 177 | * 178 | * @param accessToken OAuth access token. 179 | * 180 | * @return Success of keychain item add/update operation. 181 | */ 182 | - (BOOL)saveAccessToken:(BDBOAuth1Credential *)accessToken; 183 | 184 | /** 185 | * Remove the access token currently stored in the keychain for this serializer's service. 186 | * 187 | * @return Success of keychain item removal operation. 188 | */ 189 | - (BOOL)removeAccessToken; 190 | 191 | 192 | /** 193 | * --------------------------------------------------------------------------------------- 194 | * @name OAuth Parameters 195 | * --------------------------------------------------------------------------------------- 196 | */ 197 | #pragma mark OAuth Parameters 198 | 199 | /** 200 | * Retrieve the set of OAuth parameters to be included in authorized HTTP requests. 201 | * 202 | * @return Dictionary of OAuth parameters. 203 | */ 204 | - (NSDictionary *)OAuthParameters; 205 | 206 | @end 207 | 208 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1SessionManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1SessionManager.h 3 | // 4 | // Copyright (c) 2013-2015 Bradley David Bergeron 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import "BDBOAuth1RequestSerializer.h" 26 | 27 | #if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) 28 | 29 | #pragma mark - 30 | @interface BDBOAuth1SessionManager : AFHTTPSessionManager 31 | 32 | /** 33 | * BDBOAuth1RequestSerializer instance used to serialize HTTP requests. 34 | */ 35 | @property (nonatomic) BDBOAuth1RequestSerializer *requestSerializer; 36 | 37 | 38 | /** 39 | * --------------------------------------------------------------------------------------- 40 | * @name Initialization 41 | * --------------------------------------------------------------------------------------- 42 | */ 43 | #pragma mark Initialization 44 | 45 | /** 46 | * Initialize a new BDBOAuth1SessionManager instance with the given baseURL, consumerKey, and consumerSecret. 47 | * 48 | * @param baseURL Base URL for HTTP requests. 49 | * @param consumerKey OAuth consumer key. 50 | * @param consumerSecret OAuth consumer secret. 51 | * 52 | * @return New BDBOAuth1SessionManager instance. 53 | */ 54 | - (instancetype)initWithBaseURL:(NSURL *)baseURL 55 | consumerKey:(NSString *)consumerKey 56 | consumerSecret:(NSString *)consumerSecret; 57 | 58 | 59 | /** 60 | * --------------------------------------------------------------------------------------- 61 | * @name Authorization Status 62 | * --------------------------------------------------------------------------------------- 63 | */ 64 | #pragma mark Authorization Status 65 | 66 | /** 67 | * Check whehter or not this manager instance has a valid access token. 68 | */ 69 | @property (nonatomic, assign, readonly, getter = isAuthorized) BOOL authorized; 70 | 71 | /** 72 | * Deauthorize this manager instance and remove any associated access token from the keychain. 73 | * 74 | * @return YES if an access token was found and removed from the keychain, NO otherwise. 75 | */ 76 | - (BOOL)deauthorize; 77 | 78 | 79 | /** 80 | * --------------------------------------------------------------------------------------- 81 | * @name OAuth Handshake 82 | * --------------------------------------------------------------------------------------- 83 | */ 84 | #pragma mark OAuth Handshake 85 | 86 | /** 87 | * Fetch an OAuth request token. 88 | * 89 | * @param requestPath OAuth request token endpoint. 90 | * @param method HTTP method for fetching OAuth request token. 91 | * @param callbackURL The URL to be set for oauth_callback. 92 | * @param scope Authorization scope. 93 | * @param success Completion block performed upon successful acquisition of the OAuth request token. 94 | * @param failure Completion block performed if the OAuth request token could not be acquired. 95 | */ 96 | - (void)fetchRequestTokenWithPath:(NSString *)requestPath 97 | method:(NSString *)method 98 | callbackURL:(NSURL *)callbackURL 99 | scope:(NSString *)scope 100 | success:(void (^)(BDBOAuth1Credential *requestToken))success 101 | failure:(void (^)(NSError *error))failure; 102 | 103 | 104 | /** 105 | * Fetch an OAuth access token using a previously-acquired request token. 106 | * 107 | * @param accessPath OAuth access token endpoint. 108 | * @param method HTTP method for fetching OAuth access token. 109 | * @param requestToken OAuth request token. 110 | * @param success Completion block performed upon successful acquisition of the OAuth access token. 111 | * @param failure Completion block performed if the OAuth access token could not be acquired. 112 | */ 113 | - (void)fetchAccessTokenWithPath:(NSString *)accessPath 114 | method:(NSString *)method 115 | requestToken:(BDBOAuth1Credential *)requestToken 116 | success:(void (^)(BDBOAuth1Credential *accessToken))success 117 | failure:(void (^)(NSError *error))failure; 118 | 119 | @end 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1SessionManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1SessionManager.m 3 | // 4 | // Copyright (c) 2013-2015 Bradley David Bergeron 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | #import "AFURLConnectionOperation.h" 24 | #import "BDBOAuth1SessionManager.h" 25 | 26 | #if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) 27 | 28 | #pragma mark - 29 | @interface BDBOAuth1SessionManager () 30 | 31 | @end 32 | 33 | 34 | #pragma mark - 35 | @implementation BDBOAuth1SessionManager 36 | 37 | @dynamic requestSerializer; 38 | 39 | #pragma mark Initialization 40 | - (instancetype)initWithBaseURL:(NSURL *)baseURL 41 | consumerKey:(NSString *)consumerKey 42 | consumerSecret:(NSString *)consumerSecret { 43 | self = [super initWithBaseURL:baseURL]; 44 | 45 | if (self) { 46 | self.requestSerializer = [BDBOAuth1RequestSerializer serializerForService:baseURL.host 47 | withConsumerKey:consumerKey 48 | consumerSecret:consumerSecret]; 49 | } 50 | 51 | return self; 52 | } 53 | 54 | #pragma mark Authorization Status 55 | - (BOOL)isAuthorized { 56 | return (self.requestSerializer.accessToken && !self.requestSerializer.accessToken.expired); 57 | } 58 | 59 | - (BOOL)deauthorize { 60 | return [self.requestSerializer removeAccessToken]; 61 | } 62 | 63 | #pragma mark OAuth Handshake 64 | - (void)fetchRequestTokenWithPath:(NSString *)requestPath 65 | method:(NSString *)method 66 | callbackURL:(NSURL *)callbackURL 67 | scope:(NSString *)scope 68 | success:(void (^)(BDBOAuth1Credential *requestToken))success 69 | failure:(void (^)(NSError *error))failure { 70 | self.requestSerializer.requestToken = nil; 71 | 72 | AFHTTPResponseSerializer *defaultSerializer = self.responseSerializer; 73 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 74 | 75 | NSMutableDictionary *parameters = [[self.requestSerializer OAuthParameters] mutableCopy]; 76 | parameters[BDBOAuth1OAuthCallbackParameter] = [callbackURL absoluteString]; 77 | 78 | if (scope && !self.requestSerializer.accessToken) { 79 | parameters[@"scope"] = scope; 80 | } 81 | 82 | NSString *URLString = [[NSURL URLWithString:requestPath relativeToURL:self.baseURL] absoluteString]; 83 | NSError *error; 84 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:URLString parameters:parameters error:&error]; 85 | 86 | if (error) { 87 | failure(error); 88 | 89 | return; 90 | } 91 | 92 | void (^completionBlock)(NSURLResponse * __unused, id, NSError *) = ^(NSURLResponse * __unused response, id responseObject, NSError *completionError) { 93 | self.responseSerializer = defaultSerializer; 94 | 95 | if (completionError) { 96 | failure(completionError); 97 | 98 | return; 99 | } 100 | 101 | BDBOAuth1Credential *requestToken = [BDBOAuth1Credential credentialWithQueryString:[[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]]; 102 | self.requestSerializer.requestToken = requestToken; 103 | 104 | success(requestToken); 105 | }; 106 | 107 | NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:completionBlock]; 108 | [task resume]; 109 | } 110 | 111 | - (void)fetchAccessTokenWithPath:(NSString *)accessPath 112 | method:(NSString *)method 113 | requestToken:(BDBOAuth1Credential *)requestToken 114 | success:(void (^)(BDBOAuth1Credential *accessToken))success 115 | failure:(void (^)(NSError *error))failure { 116 | if (!requestToken.token || !requestToken.verifier) { 117 | NSError *error = [[NSError alloc] initWithDomain:BDBOAuth1ErrorDomain 118 | code:NSURLErrorBadServerResponse 119 | userInfo:@{NSLocalizedFailureReasonErrorKey:@"Invalid OAuth response received from server."}]; 120 | 121 | failure(error); 122 | 123 | return; 124 | } 125 | 126 | AFHTTPResponseSerializer *defaultSerializer = self.responseSerializer; 127 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 128 | 129 | NSMutableDictionary *parameters = [[self.requestSerializer OAuthParameters] mutableCopy]; 130 | parameters[BDBOAuth1OAuthTokenParameter] = requestToken.token; 131 | parameters[BDBOAuth1OAuthVerifierParameter] = requestToken.verifier; 132 | 133 | NSString *URLString = [[NSURL URLWithString:accessPath relativeToURL:self.baseURL] absoluteString]; 134 | NSError *error; 135 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:URLString parameters:parameters error:&error]; 136 | 137 | if (error) { 138 | failure(error); 139 | 140 | return; 141 | } 142 | 143 | void (^completionBlock)(NSURLResponse * __unused, id, NSError *) = ^(NSURLResponse * __unused response, id responseObject, NSError *completionError) { 144 | self.responseSerializer = defaultSerializer; 145 | self.requestSerializer.requestToken = nil; 146 | 147 | if (completionError) { 148 | failure(completionError); 149 | 150 | return; 151 | } 152 | 153 | BDBOAuth1Credential *accessToken = [BDBOAuth1Credential credentialWithQueryString:[[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]]; 154 | [self.requestSerializer saveAccessToken:accessToken]; 155 | 156 | success(accessToken); 157 | }; 158 | 159 | NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:completionBlock]; 160 | [task resume]; 161 | } 162 | 163 | @end 164 | 165 | #endif 166 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSDictionary+BDBOAuth1Manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+BDBOAuth1Manager.h 3 | // 4 | // Copyright (c) 2013-2015 Bradley David Bergeron 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | #import 24 | 25 | 26 | /** 27 | * Additions to NSDictionary. 28 | */ 29 | #pragma mark - 30 | @interface NSDictionary (BDBOAuth1Manager) 31 | 32 | /** 33 | * --------------------------------------------------------------------------------------- 34 | * @name Query String 35 | * --------------------------------------------------------------------------------------- 36 | */ 37 | #pragma mark Query String 38 | 39 | /** 40 | * Create a dictionary representation of a URL query string. 41 | * 42 | * @param queryString URL query string. 43 | * 44 | * @return Dictionary containing each key-value pair in the query string. 45 | */ 46 | + (instancetype)bdb_dictionaryFromQueryString:(NSString *)queryString; 47 | 48 | /** 49 | * Return each key-value pair in the dictionary as a URL query string. 50 | * 51 | * @return URL query string reperesntation of this dictionary. 52 | */ 53 | - (NSString *)bdb_queryStringRepresentation; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSDictionary+BDBOAuth1Manager.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+BDBOAuth1Manager.m 3 | // 4 | // Copyright (c) 2013-2015 Bradley David Bergeron 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | #import "NSDictionary+BDBOAuth1Manager.h" 24 | #import "NSString+BDBOAuth1Manager.h" 25 | 26 | 27 | #pragma mark - 28 | @implementation NSDictionary (BDBOAuth1Manager) 29 | 30 | #pragma mark Query String 31 | + (instancetype)bdb_dictionaryFromQueryString:(NSString *)queryString { 32 | NSArray *components = [queryString componentsSeparatedByString:@"&"]; 33 | NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; 34 | 35 | for (NSString *component in components) { 36 | NSArray *keyValue = [component componentsSeparatedByString:@"="]; 37 | dictionary[[keyValue[0] bdb_URLDecode]] = [keyValue[1] bdb_URLDecode]; 38 | } 39 | 40 | return [[[self class] alloc] initWithDictionary:dictionary]; 41 | } 42 | 43 | - (NSString *)bdb_queryStringRepresentation { 44 | NSMutableArray *paramArray = [NSMutableArray array]; 45 | 46 | [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { 47 | NSString *param = [NSString stringWithFormat:@"%@=%@", [key bdb_URLEncode], [obj bdb_URLEncode]]; 48 | [paramArray addObject:param]; 49 | }]; 50 | 51 | return [paramArray componentsJoinedByString:@"&"]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSString+BDBOAuth1Manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+BDBOAuth1Manager.h 3 | // 4 | // Copyright (c) 2013-2015 Bradley David Bergeron 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | #import 24 | 25 | 26 | /** 27 | * Additions to NSString. 28 | */ 29 | #pragma mark - 30 | @interface NSString (BDBOAuth1Manager) 31 | 32 | /** 33 | * --------------------------------------------------------------------------------------- 34 | * @name URL Encoding/Decoding 35 | * --------------------------------------------------------------------------------------- 36 | */ 37 | #pragma mark URL Encoding/Decoding 38 | 39 | /** 40 | * Returns a properly URL-decoded representation of the given string. 41 | * 42 | * See http://cybersam.com/ios-dev/proper-url-percent-encoding-in-ios for more details. 43 | * 44 | * @return URL-decoded string 45 | */ 46 | - (NSString *)bdb_URLDecode; 47 | 48 | /** 49 | * Returns a properly URL-encoded representation of the given string. 50 | * 51 | * See http://cybersam.com/ios-dev/proper-url-percent-encoding-in-ios for more details. 52 | * 53 | * @return URL-encoded string 54 | */ 55 | 56 | - (NSString *)bdb_URLEncode; 57 | 58 | 59 | /** 60 | * Returns the given string with the '/' and '?' characters URL-encoded. 61 | * 62 | * AFNetworking 2.6 no longer encodes '/' and '?' characters. See https://github.com/AFNetworking/AFNetworking/pull/2908 63 | * 64 | * @return '?' and '/' URL-encoded string 65 | */ 66 | - (NSString *)bdb_URLEncodeSlashesAndQuestionMarks; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSString+BDBOAuth1Manager.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+BDBOAuth1Manager.m 3 | // 4 | // Copyright (c) 2013-2015 Bradley David Bergeron 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import "NSString+BDBOAuth1Manager.h" 26 | 27 | 28 | #pragma mark - 29 | @implementation NSString (BDBOAuth1Manager) 30 | 31 | #pragma mark URL Encoding/Decoding 32 | - (NSString *)bdb_URLEncode { 33 | return (__bridge_transfer NSString *) 34 | CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, 35 | (__bridge CFStringRef)self, 36 | NULL, 37 | (__bridge CFStringRef)@"!*'\"();:@&=+$,/?%#[] ", 38 | kCFStringEncodingUTF8); 39 | } 40 | 41 | - (NSString *)bdb_URLDecode { 42 | return (__bridge_transfer NSString *) 43 | CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, 44 | (__bridge CFStringRef)self, 45 | (__bridge CFStringRef)@"", 46 | kCFStringEncodingUTF8); 47 | } 48 | 49 | - (NSString *)bdb_URLEncodeSlashesAndQuestionMarks { 50 | NSString *selfWithSlashesEscaped = [self stringByReplacingOccurrencesOfString:@"/" withString:@"%2F"]; 51 | NSString *selfWithQuestionMarksEscaped = [selfWithSlashesEscaped stringByReplacingOccurrencesOfString:@"?" withString:@"%3F"]; 52 | return selfWithQuestionMarksEscaped; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Bradley David Bergeron 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/README.md: -------------------------------------------------------------------------------- 1 | # BDBOAuth1Manager 2 | 3 | BDBOAuth1Manager is an OAuth 1.0a library for AFNetworking 2.x. 4 | 5 | ## Usage 6 | 7 | BDBOAuth1Manager consists of three core classes: `BDBOAuth1RequestSerializer`, `BDBOAuth1RequestOperationManger`, and `BDBOAuth1SessionManager`. Below I will provide a quick overview of each, but to really see how the three classes work together, take a look at the included demo apps. One is a simple Twitter client and the other a simple Flickr photo gallery, but they show how to get started using BDBOAuth1Manager in your projects. 8 | 9 | ### BDBOAuth1RequestOperationManger 10 | 11 | `BDBOAuth1RequestOperationManger` is a subclass of `AFHTTPRequestOperationManager` that provides methods to facilitate the OAuth 1 authentication flow. 12 | 13 | ```objective-c 14 | @property (nonatomic) BDBOAuth1RequestSerializer *requestSerializer; 15 | 16 | #pragma mark Initialization 17 | - (instancetype)initWithBaseURL:(NSURL *)baseURL 18 | consumerKey:(NSString *)consumerKey 19 | consumerSecret:(NSString *)consumerSecret; 20 | 21 | #pragma mark Authorization Status 22 | @property (nonatomic, assign, readonly, getter = isAuthorized) BOOL authorized; 23 | 24 | - (BOOL)deauthorize; 25 | 26 | #pragma mark OAuth Handshake 27 | - (void)fetchRequestTokenWithPath:(NSString *)requestPath 28 | method:(NSString *)method 29 | callbackURL:(NSURL *)callbackURL 30 | scope:(NSString *)scope 31 | success:(void (^)(BDBOAuth1Credential *requestToken))success 32 | failure:(void (^)(NSError *error))failure; 33 | 34 | - (void)fetchAccessTokenWithPath:(NSString *)accessPath 35 | method:(NSString *)method 36 | requestToken:(BDBOAuth1Credential *)requestToken 37 | success:(void (^)(BDBOAuth1Credential *accessToken))success 38 | failure:(void (^)(NSError *error))failure; 39 | ``` 40 | 41 | ### BDBOAuth1SessionManager 42 | 43 | `BDBOAuth1SessionManager` is a subclass of `AFHTTPSessionManager` that has the same API as `BDBOAuth1RequestOperationManger`, which is described above. 44 | 45 | If your deployment target is either iOS 6 or OS X 10.8, you must use `BDBOAuth1RequestOperationManger`, as the underlying `NSURLSession` that is used by `AFHTTPSessionManager` is a new addition to the iOS and OS X networking frameworks for iOS 7 and OS X 10.9. 46 | 47 | ### BDBOAuth1RequestSerializer 48 | 49 | `BDBOAuth1RequestSerializer` is a subclass of `AFHTTPRequestSerializer` that handles all the networking requests performed by `BDBOAuth1RequestOperationManger` and `BDBOAuth1SessionManager`. Both classes automatically handle the creation of this serializer, so you should never have to instantiate it on your own. 50 | 51 | `BDBOAuth1RequestSerializer` also has built-in support for storing and retrieving an OAuth access token to/from the user's keychain, utilizing the service name to differentiate tokens. `BDBOAuth1RequestOperationManger` and `BDBOAuth1SessionManager` automatically set the service name to baseURL.host (e.g. api.twitter.com) when they are instantiated. 52 | 53 | ## OAuth Handshake 54 | 55 | The first step in performing the OAuth handshake is getting an OAuth request token for your application. This can be done with the `fetchRequestTokenWithPath:method:callbackURL:scope:success:failure:` method. 56 | 57 | ```objective-c 58 | [self.networkManager fetchRequestTokenWithPath:@"/oauth/request_token" 59 | method:@"POST" 60 | callbackURL:[NSURL URLWithString:@"bdboauth://request"] 61 | scope:nil 62 | success:^(BDBOAuth1Credential *requestToken) { 63 | NSString *authURL = [NSString stringWithFormat:@"https://api.twitter.com/oauth/authorize?oauth_token=%@", requestToken.token]; 64 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:authURL]]; 65 | } 66 | failure:^(NSError *error) { 67 | NSLog(@"Error: %@", error.localizedDescription); 68 | }]; 69 | ``` 70 | 71 | ### Creating a URL Type for OAuth Callbacks 72 | 73 | When calling `fetchRequestTokenWithPath:method:callbackURL:scope:success:failure:`, you must provide a unique callback URL whose scheme corresponds to a URL type you've added to your project target. This allows the OAuth provider to return the user to your app after the user has authorized it. For example, if I add a URL type to my project with the scheme `bdboauth`, my application would then respond to all URL requests that begin with `bdboauth:`. If I pass `bdboauth://request` as the callback URL, the OAuth provider would call that URL and my application would resume. 74 | 75 | ![URL Types Screenshot](https://dl.dropboxusercontent.com/u/6225/GitHub/BDBOAuth1Manager/urltypes.png) 76 | 77 | ### Responding to the OAuth Callback URL 78 | 79 | In order to respond to your application's URL scheme being called, you must implement the `-application:openURL:sourceApplication:annotation` method within your application delegate. You can do something like this: 80 | 81 | ```objective-c 82 | - (BOOL)application:(UIApplication *)application 83 | openURL:(NSURL *)url 84 | sourceApplication:(NSString *)sourceApplication 85 | annotation:(id)annotation { 86 | if ([url.scheme isEqualToString:@"bdboauth"]) { 87 | if ([url.host isEqualToString:@"request"]) { 88 | NSDictionary *parameters = [url dictionaryFromQueryString]; 89 | if (parameters[@"oauth_token"] && parameters[@"oauth_verifier"]) { 90 | [self.networkManager fetchAccessTokenWithPath:@"/oauth/access_token" 91 | method:@"POST" 92 | requestToken:[BDBOAuth1Credential credentialWithQueryString:url.query] 93 | success:^(BDBOAuth1Credential *accessToken) { 94 | [self.networkManager.requestSerializer saveAccessToken:accessToken]; 95 | }]; 96 | } 97 | } 98 | return YES; 99 | } 100 | return NO; 101 | } 102 | ``` 103 | 104 | ## Credits 105 | 106 | BDBOAuth1Manager was created by [Bradley David Bergeron](http://www.bradbergeron.com) and influenced by [AFOAuth1Client](https://github.com/AFNetworking/AFOAuth1Client). Both [AFNetworking](https://github.com/AFNetworking/AFNetworking) and [AFOAuth1Client](https://github.com/AFNetworking/AFOAuth1Client) are the awesome work of [Mattt Thompson](https://github.com/mattt). 107 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (2.6.3): 3 | - AFNetworking/NSURLConnection (= 2.6.3) 4 | - AFNetworking/NSURLSession (= 2.6.3) 5 | - AFNetworking/Reachability (= 2.6.3) 6 | - AFNetworking/Security (= 2.6.3) 7 | - AFNetworking/Serialization (= 2.6.3) 8 | - AFNetworking/UIKit (= 2.6.3) 9 | - AFNetworking/NSURLConnection (2.6.3): 10 | - AFNetworking/Reachability 11 | - AFNetworking/Security 12 | - AFNetworking/Serialization 13 | - AFNetworking/NSURLSession (2.6.3): 14 | - AFNetworking/Reachability 15 | - AFNetworking/Security 16 | - AFNetworking/Serialization 17 | - AFNetworking/Reachability (2.6.3) 18 | - AFNetworking/Security (2.6.3) 19 | - AFNetworking/Serialization (2.6.3) 20 | - AFNetworking/UIKit (2.6.3): 21 | - AFNetworking/NSURLConnection 22 | - AFNetworking/NSURLSession 23 | - BDBOAuth1Manager (1.6.0): 24 | - AFNetworking/NSURLConnection (~> 2.6.0) 25 | - AFNetworking/NSURLSession (~> 2.6.0) 26 | 27 | DEPENDENCIES: 28 | - AFNetworking (~> 2.5) 29 | - BDBOAuth1Manager 30 | 31 | SPEC CHECKSUMS: 32 | AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60 33 | BDBOAuth1Manager: cd5a5872f355ca38180d52ca2dd844f0b0c84797 34 | 35 | PODFILE CHECKSUM: e93d023552e6cb9e3bc0b66e42e1d29f24efef97 36 | 37 | COCOAPODS: 1.0.1 38 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_AFNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_AFNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #ifndef TARGET_OS_IOS 6 | #define TARGET_OS_IOS TARGET_OS_IPHONE 7 | #endif 8 | 9 | #ifndef TARGET_OS_WATCH 10 | #define TARGET_OS_WATCH 0 11 | #endif 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AFNetworking.h" 4 | #import "AFURLConnectionOperation.h" 5 | #import "AFHTTPRequestOperation.h" 6 | #import "AFHTTPRequestOperationManager.h" 7 | #import "AFHTTPSessionManager.h" 8 | #import "AFURLSessionManager.h" 9 | #import "AFNetworkReachabilityManager.h" 10 | #import "AFSecurityPolicy.h" 11 | #import "AFURLRequestSerialization.h" 12 | #import "AFURLResponseSerialization.h" 13 | #import "AFNetworkActivityIndicatorManager.h" 14 | #import "UIActivityIndicatorView+AFNetworking.h" 15 | #import "UIAlertView+AFNetworking.h" 16 | #import "UIButton+AFNetworking.h" 17 | #import "UIImage+AFNetworking.h" 18 | #import "UIImageView+AFNetworking.h" 19 | #import "UIKit+AFNetworking.h" 20 | #import "UIProgressView+AFNetworking.h" 21 | #import "UIRefreshControl+AFNetworking.h" 22 | #import "UIWebView+AFNetworking.h" 23 | 24 | FOUNDATION_EXPORT double AFNetworkingVersionNumber; 25 | FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[]; 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking.modulemap: -------------------------------------------------------------------------------- 1 | framework module AFNetworking { 2 | umbrella header "AFNetworking-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/AFNetworking 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.6.3 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/BDBOAuth1Manager/BDBOAuth1Manager-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_BDBOAuth1Manager : NSObject 3 | @end 4 | @implementation PodsDummy_BDBOAuth1Manager 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/BDBOAuth1Manager/BDBOAuth1Manager-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/BDBOAuth1Manager/BDBOAuth1Manager-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "BDBOAuth1RequestOperationManager.h" 4 | #import "BDBOAuth1RequestSerializer.h" 5 | #import "BDBOAuth1SessionManager.h" 6 | #import "NSDictionary+BDBOAuth1Manager.h" 7 | #import "NSString+BDBOAuth1Manager.h" 8 | 9 | FOUNDATION_EXPORT double BDBOAuth1ManagerVersionNumber; 10 | FOUNDATION_EXPORT const unsigned char BDBOAuth1ManagerVersionString[]; 11 | 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/BDBOAuth1Manager/BDBOAuth1Manager.modulemap: -------------------------------------------------------------------------------- 1 | framework module BDBOAuth1Manager { 2 | umbrella header "BDBOAuth1Manager-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/BDBOAuth1Manager/BDBOAuth1Manager.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/BDBOAuth1Manager 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/BDBOAuth1Manager/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.6.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Pods-Yelp-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 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 | 27 | ## BDBOAuth1Manager 28 | 29 | The MIT License (MIT) 30 | 31 | Copyright (c) 2013 Bradley David Bergeron 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy of 34 | this software and associated documentation files (the "Software"), to deal in 35 | the Software without restriction, including without limitation the rights to 36 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 37 | the Software, and to permit persons to whom the Software is furnished to do so, 38 | subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included in all 41 | copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 45 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 46 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 47 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 48 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 49 | 50 | Generated by CocoaPods - https://cocoapods.org 51 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Pods-Yelp-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–2015 Alamofire Software Foundation (http://alamofire.org/) 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 | The MIT License (MIT) 45 | 46 | Copyright (c) 2013 Bradley David Bergeron 47 | 48 | Permission is hereby granted, free of charge, to any person obtaining a copy of 49 | this software and associated documentation files (the "Software"), to deal in 50 | the Software without restriction, including without limitation the rights to 51 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 52 | the Software, and to permit persons to whom the Software is furnished to do so, 53 | subject to the following conditions: 54 | 55 | The above copyright notice and this permission notice shall be included in all 56 | copies or substantial portions of the Software. 57 | 58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 60 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 61 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 62 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 63 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 64 | 65 | Title 66 | BDBOAuth1Manager 67 | Type 68 | PSGroupSpecifier 69 | 70 | 71 | FooterText 72 | Generated by CocoaPods - https://cocoapods.org 73 | Title 74 | 75 | Type 76 | PSGroupSpecifier 77 | 78 | 79 | StringsTable 80 | Acknowledgements 81 | Title 82 | Acknowledgements 83 | 84 | 85 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Pods-Yelp-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Yelp : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Yelp 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Pods-Yelp-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/AFNetworking/AFNetworking.framework" 88 | install_framework "$BUILT_PRODUCTS_DIR/BDBOAuth1Manager/BDBOAuth1Manager.framework" 89 | fi 90 | if [[ "$CONFIGURATION" == "Release" ]]; then 91 | install_framework "$BUILT_PRODUCTS_DIR/AFNetworking/AFNetworking.framework" 92 | install_framework "$BUILT_PRODUCTS_DIR/BDBOAuth1Manager/BDBOAuth1Manager.framework" 93 | fi 94 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Pods-Yelp-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | realpath() { 27 | DIRECTORY="$(cd "${1%/*}" && pwd)" 28 | FILENAME="${1##*/}" 29 | echo "$DIRECTORY/$FILENAME" 30 | } 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Pods-Yelp-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_YelpVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_YelpVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Pods-Yelp.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/BDBOAuth1Manager" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking/AFNetworking.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/BDBOAuth1Manager/BDBOAuth1Manager.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "BDBOAuth1Manager" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Pods-Yelp.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_Yelp { 2 | umbrella header "Pods-Yelp-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-Yelp/Pods-Yelp.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/BDBOAuth1Manager" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking/AFNetworking.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/BDBOAuth1Manager/BDBOAuth1Manager.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "BDBOAuth1Manager" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Pods-YelpTests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Pods-YelpTests-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 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Pods-YelpTests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_YelpTests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_YelpTests 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Pods-YelpTests-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Pods-YelpTests-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | realpath() { 27 | DIRECTORY="$(cd "${1%/*}" && pwd)" 28 | FILENAME="${1##*/}" 29 | echo "$DIRECTORY/$FILENAME" 30 | } 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Pods-YelpTests-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_YelpTestsVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_YelpTestsVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Pods-YelpTests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/BDBOAuth1Manager" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking/AFNetworking.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/BDBOAuth1Manager/BDBOAuth1Manager.framework/Headers" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT}/Pods 8 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Pods-YelpTests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_YelpTests { 2 | umbrella header "Pods-YelpTests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YelpTests/Pods-YelpTests.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/BDBOAuth1Manager" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking/AFNetworking.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/BDBOAuth1Manager/BDBOAuth1Manager.framework/Headers" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT}/Pods 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Basic Yelp client 2 | 3 | This is a headless example of how to implement an OAuth 1.0a Yelp API client. The Yelp API provides an application token that allows applications to make unauthenticated requests to their search API. 4 | 5 | ### Next steps 6 | 7 | - Check out `BusinessesViewController.swift` to see how to use the `Business` model. 8 | 9 | ### Sample request 10 | 11 | **Basic search with query** 12 | 13 | ``` 14 | Business.searchWithTerm("Thai", completion: { (businesses: [Business]!, error: Error!) -> Void in 15 | self.businesses = businesses 16 | 17 | for business in businesses { 18 | print(business.name!) 19 | print(business.address!) 20 | } 21 | }) 22 | ``` 23 | 24 | **Advanced search with categories, sort, and deal filters** 25 | 26 | ``` 27 | Business.searchWithTerm("Restaurants", sort: .distance, categories: ["asianfusion", "burgers"], deals: true) { (businesses: [Business]!, error: Error!) -> Void in 28 | 29 | for business in businesses { 30 | print(business.name!) 31 | print(business.address!) 32 | } 33 | } 34 | ``` 35 | -------------------------------------------------------------------------------- /Yelp.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Yelp.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Yelp/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Yelp 4 | // 5 | // Created by Timothy Lee on 9/19/14. 6 | // Copyright (c) 2014 Timothy Lee. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Yelp/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Yelp/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Yelp/Business.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Business.swift 3 | // Yelp 4 | // 5 | // Created by Timothy Lee on 4/23/15. 6 | // Copyright (c) 2015 Timothy Lee. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class Business: NSObject { 12 | let name: String? 13 | let address: String? 14 | let imageURL: URL? 15 | let categories: String? 16 | let distance: String? 17 | let ratingImage: UIImage? 18 | let reviewCount: NSNumber? 19 | 20 | init(dictionary: NSDictionary) { 21 | name = dictionary["name"] as? String 22 | 23 | let imageURLString = dictionary["image_url"] as? String 24 | if imageURLString != nil { 25 | imageURL = URL(string: imageURLString!)! 26 | } else { 27 | imageURL = nil 28 | } 29 | 30 | let location = dictionary["location"] as? NSDictionary 31 | var address = "" 32 | if location != nil { 33 | let addressArray = location!["display_address"] as? NSArray 34 | if addressArray != nil { 35 | if addressArray!.count > 0 { 36 | address = addressArray![0] as! String 37 | } 38 | if addressArray!.count > 1 { 39 | address += ", " + (addressArray![1] as! String) 40 | } 41 | } 42 | } 43 | self.address = address 44 | 45 | let categoriesArray = dictionary["categories"] as? [NSDictionary] 46 | if categoriesArray != nil { 47 | var categoryNames = [String]() 48 | for category in categoriesArray! { 49 | let categoryName = category["title"] as! String 50 | categoryNames.append(categoryName) 51 | } 52 | categories = categoryNames.joined(separator: ", ") 53 | } else { 54 | categories = nil 55 | } 56 | 57 | let distanceMeters = dictionary["distance"] as? NSNumber 58 | if distanceMeters != nil { 59 | let milesPerMeter = 0.000621371 60 | distance = String(format: "%.2f mi", milesPerMeter * distanceMeters!.doubleValue) 61 | } else { 62 | distance = nil 63 | } 64 | 65 | let rating = dictionary["rating"] as? Double 66 | if rating != nil { 67 | switch rating { 68 | case 1: 69 | self.ratingImage = UIImage(named: "stars_1") 70 | break 71 | case 1.5: 72 | self.ratingImage = UIImage(named: "stars_1half") 73 | break 74 | case 2: 75 | self.ratingImage = UIImage(named: "stars_2") 76 | break 77 | case 2.5: 78 | self.ratingImage = UIImage(named: "stars_2half") 79 | break 80 | case 3: 81 | self.ratingImage = UIImage(named: "stars_3") 82 | break 83 | case 3.5: 84 | self.ratingImage = UIImage(named: "stars_3half") 85 | break 86 | case 4: 87 | self.ratingImage = UIImage(named: "stars_4") 88 | break 89 | case 4.5: 90 | self.ratingImage = UIImage(named: "stars_4half") 91 | break 92 | case 5: 93 | self.ratingImage = UIImage(named: "stars_5") 94 | break 95 | default: 96 | self.ratingImage = UIImage(named: "stars_0") 97 | break 98 | } 99 | } else { 100 | self.ratingImage = UIImage(named: "stars_0") 101 | } 102 | 103 | reviewCount = dictionary["review_count"] as? NSNumber 104 | } 105 | 106 | class func businesses(array: [NSDictionary]) -> [Business] { 107 | var businesses = [Business]() 108 | for dictionary in array { 109 | let business = Business(dictionary: dictionary) 110 | businesses.append(business) 111 | } 112 | return businesses 113 | } 114 | 115 | class func searchWithTerm(term: String, completion: @escaping ([Business]?, Error?) -> Void) { 116 | _ = YelpClient.sharedInstance.searchWithTerm(term, completion: completion) 117 | } 118 | 119 | class func searchWithTerm(term: String, sort: YelpSortMode?, categories: [String]?, completion: @escaping ([Business]?, Error?) -> Void) -> Void { 120 | _ = YelpClient.sharedInstance.searchWithTerm(term, sort: sort, categories: categories, openNow: false, completion: completion) 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Yelp/BusinessesViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BusinessesViewController.swift 3 | // Yelp 4 | // 5 | // Created by Timothy Lee on 4/23/15. 6 | // Copyright (c) 2015 Timothy Lee. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BusinessesViewController: UIViewController { 12 | 13 | var businesses: [Business]! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | Business.searchWithTerm(term: "Thai", completion: { (businesses: [Business]?, error: Error?) -> Void in 19 | 20 | self.businesses = businesses 21 | if let businesses = businesses { 22 | for business in businesses { 23 | print(business.name!) 24 | print(business.address!) 25 | } 26 | } 27 | 28 | } 29 | ) 30 | 31 | /* Example of Yelp search with more search options specified 32 | Business.searchWithTerm(term: "Restaurants", sort: .distance, categories: ["asianfusion", "burgers"]) { (businesses, error) in 33 | self.businesses = businesses 34 | for business in self.businesses { 35 | print(business.name!) 36 | print(business.address!) 37 | } 38 | } 39 | */ 40 | 41 | } 42 | 43 | override func didReceiveMemoryWarning() { 44 | super.didReceiveMemoryWarning() 45 | // Dispose of any resources that can be recreated. 46 | } 47 | 48 | /* 49 | // MARK: - Navigation 50 | 51 | // In a storyboard-based application, you will often want to do a little preparation before navigation 52 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 53 | // Get the new view controller using segue.destinationViewController. 54 | // Pass the selected object to the new view controller. 55 | } 56 | */ 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Yelp/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_0.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_0.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_0.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_0@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_0.imageset/regular_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_0.imageset/regular_0.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_0.imageset/regular_0@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_0.imageset/regular_0@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_0.imageset/stars_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_0.imageset/stars_0.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_1.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_1.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_1@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_1.imageset/regular_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_1.imageset/regular_1.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_1.imageset/regular_1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_1.imageset/regular_1@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_1.imageset/stars_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_1.imageset/stars_1.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_1half.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_1_half.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_1half.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_1_half@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_1half.imageset/regular_1_half.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_1half.imageset/regular_1_half.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_1half.imageset/regular_1_half@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_1half.imageset/regular_1_half@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_1half.imageset/stars_1half.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_1half.imageset/stars_1half.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_2.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_2.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_2@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_2.imageset/regular_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_2.imageset/regular_2.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_2.imageset/regular_2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_2.imageset/regular_2@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_2.imageset/stars_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_2.imageset/stars_2.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_2half.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_2_half.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_2half.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_2_half@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_2half.imageset/regular_2_half.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_2half.imageset/regular_2_half.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_2half.imageset/regular_2_half@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_2half.imageset/regular_2_half@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_2half.imageset/stars_2half.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_2half.imageset/stars_2half.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_3.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_3.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_3@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_3.imageset/regular_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_3.imageset/regular_3.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_3.imageset/regular_3@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_3.imageset/regular_3@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_3.imageset/stars_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_3.imageset/stars_3.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_3half.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_3_half.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_3half.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_3_half@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_3half.imageset/regular_3_half.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_3half.imageset/regular_3_half.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_3half.imageset/regular_3_half@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_3half.imageset/regular_3_half@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_3half.imageset/stars_3half.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_3half.imageset/stars_3half.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_4.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_4.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_4@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_4.imageset/regular_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_4.imageset/regular_4.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_4.imageset/regular_4@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_4.imageset/regular_4@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_4.imageset/stars_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_4.imageset/stars_4.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_4half.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_4_half.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_4half.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_4_half@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_4half.imageset/regular_4_half.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_4half.imageset/regular_4_half.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_4half.imageset/regular_4_half@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_4half.imageset/regular_4_half@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_4half.imageset/stars_4half.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_4half.imageset/stars_4half.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "regular_5.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "stars_5.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "regular_5@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_5.imageset/regular_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_5.imageset/regular_5.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_5.imageset/regular_5@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_5.imageset/regular_5@3x.png -------------------------------------------------------------------------------- /Yelp/Images.xcassets/stars_5.imageset/stars_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/ios_yelp_swift/3bd259997b12eb649af8f99bf88627109544c021/Yelp/Images.xcassets/stars_5.imageset/stars_5.png -------------------------------------------------------------------------------- /Yelp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | NSAppTransportSecurity 40 | 41 | NSAllowsArbitraryLoads 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Yelp/YelpClient.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YelpClient.swift 3 | // Yelp 4 | // 5 | // Created by Tejen Patel on 6/26/18. 6 | // Copyright (c) 2018 CodePath. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import AFNetworking 12 | import BDBOAuth1Manager 13 | 14 | // You can register for Yelp API keys here: https://www.yelp.com/developers/v3/manage_app 15 | let yelpAPIKey = "izCFqEx0usiPwAiv_ymJ4Sl2Lr_mpnN6U_VeEkn1iUyEUWLM2Rd76A6NlswCI-HlYVWYT2WYRFtNnD04lgageyBKPJkqDDA75C8UsJYwc7oXWMGDFSCRU93zoTBaW3Yx" 16 | 17 | enum YelpSortMode: String { 18 | case best_match, rating, review_count, distance 19 | } 20 | 21 | class YelpClient: AFHTTPRequestOperationManager { 22 | var apiKey: String! 23 | 24 | //MARK: Shared Instance 25 | 26 | static let sharedInstance = YelpClient(yelpAPIKey: yelpAPIKey) 27 | 28 | required init?(coder aDecoder: NSCoder) { 29 | super.init(coder: aDecoder) 30 | } 31 | 32 | init(yelpAPIKey: String) { 33 | self.apiKey = yelpAPIKey 34 | 35 | let baseUrl = URL(string: "https://api.yelp.com/v3/") 36 | super.init(baseURL: baseUrl) 37 | requestSerializer.setValue("Bearer \(self.apiKey!)", forHTTPHeaderField: "Authorization") 38 | } 39 | 40 | func searchWithTerm(_ term: String, completion: @escaping ([Business]?, Error?) -> Void) -> AFHTTPRequestOperation { 41 | return searchWithTerm(term, sort: nil, categories: nil, openNow: nil, completion: completion) 42 | } 43 | 44 | func searchWithTerm(_ term: String, sort: YelpSortMode?, categories: [String]?, openNow: Bool?, completion: @escaping ([Business]?, Error?) -> Void) -> AFHTTPRequestOperation { 45 | // For additional parameters, see https://www.yelp.com/developers/documentation/v3/business_search 46 | 47 | // Default the location to San Francisco 48 | var parameters: [String : AnyObject] = ["term": term as AnyObject, "location": "37.785771,-122.406165" as AnyObject] 49 | 50 | if sort != nil { 51 | parameters["sort_by"] = sort!.rawValue as AnyObject? 52 | } 53 | 54 | if categories != nil && categories!.count > 0 { 55 | parameters["categories"] = (categories!).joined(separator: ",") as AnyObject? 56 | } 57 | 58 | if openNow != nil { 59 | parameters["open_now"] = openNow! as AnyObject 60 | } 61 | 62 | print(parameters) 63 | 64 | return self.get("businesses/search", parameters: parameters, 65 | success: { (operation: AFHTTPRequestOperation, response: Any) -> Void in 66 | if let response = response as? [String: Any]{ 67 | let dictionaries = response["businesses"] as? [NSDictionary] 68 | if dictionaries != nil { 69 | completion(Business.businesses(array: dictionaries!), nil) 70 | } 71 | } 72 | }, 73 | failure: { (operation: AFHTTPRequestOperation?, error: Error) -> Void in 74 | completion(nil, error) 75 | })! 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /YelpTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /YelpTests/YelpTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YelpTests.swift 3 | // YelpTests 4 | // 5 | // Created by Timothy Lee on 9/19/14. 6 | // Copyright (c) 2014 Timothy Lee. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class YelpTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------