├── HEAD ├── 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 │ │ ├── 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 ├── BuildHeaders │ ├── AFNetworking │ │ ├── AFHTTPRequestOperation.h │ │ ├── AFHTTPRequestOperationManager.h │ │ ├── AFHTTPSessionManager.h │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFURLConnectionOperation.h │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLSessionManager.h │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIAlertView+AFNetworking.h │ │ ├── UIButton+AFNetworking.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.h │ │ └── UIWebView+AFNetworking.h │ └── BDBOAuth1Manager │ │ ├── BDBOAuth1RequestOperationManager.h │ │ ├── BDBOAuth1RequestSerializer.h │ │ ├── BDBOAuth1SessionManager.h │ │ ├── NSDictionary+BDBOAuth1Manager.h │ │ └── NSString+BDBOAuth1Manager.h ├── Headers │ ├── AFNetworking │ │ ├── AFHTTPRequestOperation.h │ │ ├── AFHTTPRequestOperationManager.h │ │ ├── AFHTTPSessionManager.h │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFURLConnectionOperation.h │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLSessionManager.h │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIAlertView+AFNetworking.h │ │ ├── UIButton+AFNetworking.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.h │ │ └── UIWebView+AFNetworking.h │ └── BDBOAuth1Manager │ │ ├── BDBOAuth1RequestOperationManager.h │ │ ├── BDBOAuth1RequestSerializer.h │ │ ├── BDBOAuth1SessionManager.h │ │ ├── NSDictionary+BDBOAuth1Manager.h │ │ └── NSString+BDBOAuth1Manager.h ├── Manifest.lock ├── Pods-AFNetworking-Private.xcconfig ├── Pods-AFNetworking-dummy.m ├── Pods-AFNetworking-prefix.pch ├── Pods-AFNetworking.xcconfig ├── Pods-BDBOAuth1Manager-Private.xcconfig ├── Pods-BDBOAuth1Manager-dummy.m ├── Pods-BDBOAuth1Manager-prefix.pch ├── Pods-BDBOAuth1Manager.xcconfig ├── Pods-acknowledgements.markdown ├── Pods-acknowledgements.plist ├── Pods-dummy.m ├── Pods-environment.h ├── Pods-resources.sh ├── Pods.xcconfig └── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ └── ziyang0621.xcuserdatad │ └── xcschemes │ ├── Pods-AFNetworking.xcscheme │ ├── Pods-BDBOAuth1Manager.xcscheme │ ├── Pods.xcscheme │ └── xcschememanagement.plist ├── README.md ├── Twitter.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── ziyang0621.xcuserdatad │ └── xcschemes │ ├── Twitter.xcscheme │ └── xcschememanagement.plist ├── Twitter.xcworkspace ├── contents.xcworkspacedata ├── xcshareddata │ └── Twitter.xccheckout └── xcuserdata │ └── ziyang0621.xcuserdatad │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── Twitter ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── ContainerViewController.swift ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── favorite.imageset │ │ ├── Contents.json │ │ └── favorite.png │ ├── reply.imageset │ │ ├── Contents.json │ │ └── reply.png │ └── retweet.imageset │ │ ├── Contents.json │ │ └── retweet.png ├── Info.plist ├── MentionViewController.swift ├── MenuCell.swift ├── NewTweetViewController.swift ├── ProfileViewController.swift ├── SidePaneViewController.swift ├── Tweet.swift ├── TweetCell.swift ├── TweetCell.xib ├── TweetsViewController.swift ├── Twitter-Bridging-Header.h ├── TwitterClient.swift ├── TwitterExtensions.swift ├── User.swift └── ViewController.swift ├── TwitterTests ├── Info.plist └── TwitterTests.swift ├── config ├── description ├── hooks ├── applypatch-msg.sample ├── commit-msg.sample ├── post-update.sample ├── pre-applypatch.sample ├── pre-commit.sample ├── pre-push.sample ├── pre-rebase.sample ├── prepare-commit-msg.sample └── update.sample ├── info └── exclude ├── twitter-sidemenu.gif └── twitter.gif /HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, "8.0" 2 | 3 | pod "AFNetworking" 4 | pod "BDBOAuth1Manager" -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (2.4.1): 3 | - AFNetworking/NSURLConnection 4 | - AFNetworking/NSURLSession 5 | - AFNetworking/Reachability 6 | - AFNetworking/Security 7 | - AFNetworking/Serialization 8 | - AFNetworking/UIKit 9 | - AFNetworking/NSURLConnection (2.4.1): 10 | - AFNetworking/Reachability 11 | - AFNetworking/Security 12 | - AFNetworking/Serialization 13 | - AFNetworking/NSURLSession (2.4.1): 14 | - AFNetworking/Reachability 15 | - AFNetworking/Security 16 | - AFNetworking/Serialization 17 | - AFNetworking/Reachability (2.4.1) 18 | - AFNetworking/Security (2.4.1) 19 | - AFNetworking/Serialization (2.4.1) 20 | - AFNetworking/UIKit (2.4.1): 21 | - AFNetworking/NSURLConnection 22 | - AFNetworking/NSURLSession 23 | - BDBOAuth1Manager (1.4.1): 24 | - AFNetworking/NSURLConnection (~> 2.4.0) 25 | - AFNetworking/NSURLSession (~> 2.4.0) 26 | 27 | DEPENDENCIES: 28 | - AFNetworking 29 | - BDBOAuth1Manager 30 | 31 | SPEC CHECKSUMS: 32 | AFNetworking: 0aabc6fae66d6e5d039eeb21c315843c7aae51ab 33 | BDBOAuth1Manager: 0625ba20bd7d36461bbf6dc3d29276b5932b7409 34 | 35 | COCOAPODS: 0.33.1 36 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.h 2 | // 3 | // Copyright (c) 2013-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 | #import "AFURLConnectionOperation.h" 25 | 26 | /** 27 | `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. 28 | */ 29 | @interface AFHTTPRequestOperation : AFURLConnectionOperation 30 | 31 | ///------------------------------------------------ 32 | /// @name Getting HTTP URL Connection Information 33 | ///------------------------------------------------ 34 | 35 | /** 36 | The last HTTP response received by the operation's connection. 37 | */ 38 | @property (readonly, nonatomic, strong) NSHTTPURLResponse *response; 39 | 40 | /** 41 | 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. 42 | 43 | @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value 44 | */ 45 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 46 | 47 | /** 48 | 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. 49 | */ 50 | @property (readonly, nonatomic, strong) id responseObject; 51 | 52 | ///----------------------------------------------------------- 53 | /// @name Setting Completion Block Success / Failure Callbacks 54 | ///----------------------------------------------------------- 55 | 56 | /** 57 | 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. 58 | 59 | This method should be overridden in subclasses in order to specify the response object passed into the success block. 60 | 61 | @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. 62 | @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. 63 | */ 64 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 65 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /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 | #import "AFNetworkReachabilityManager.h" 33 | 34 | #import "AFURLConnectionOperation.h" 35 | #import "AFHTTPRequestOperation.h" 36 | #import "AFHTTPRequestOperationManager.h" 37 | 38 | #if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ 39 | ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) ) 40 | #import "AFURLSessionManager.h" 41 | #import "AFHTTPSessionManager.h" 42 | #endif 43 | 44 | #endif /* _AFNETWORKING_ */ 45 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | // AFSecurity.h 2 | // 3 | // Copyright (c) 2013-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 | #import 25 | 26 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { 27 | AFSSLPinningModeNone, 28 | AFSSLPinningModePublicKey, 29 | AFSSLPinningModeCertificate, 30 | }; 31 | 32 | /** 33 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. 34 | 35 | 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. 36 | */ 37 | @interface AFSecurityPolicy : NSObject 38 | 39 | /** 40 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. 41 | */ 42 | @property (nonatomic, assign) AFSSLPinningMode SSLPinningMode; 43 | 44 | /** 45 | Whether to evaluate an entire SSL certificate chain, or just the leaf certificate. Defaults to `YES`. 46 | */ 47 | @property (nonatomic, assign) BOOL validatesCertificateChain; 48 | 49 | /** 50 | 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. 51 | */ 52 | @property (nonatomic, strong) NSArray *pinnedCertificates; 53 | 54 | /** 55 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. 56 | */ 57 | @property (nonatomic, assign) BOOL allowInvalidCertificates; 58 | 59 | /** 60 | Whether or not to validate the domain name in the certificates CN field. Defaults to `YES` for `AFSSLPinningModePublicKey` or `AFSSLPinningModeCertificate`, otherwise `NO`. 61 | */ 62 | @property (nonatomic, assign) BOOL validatesDomainName; 63 | 64 | ///----------------------------------------- 65 | /// @name Getting Specific Security Policies 66 | ///----------------------------------------- 67 | 68 | /** 69 | Returns the shared default security policy, which does not accept invalid certificates, and does not validate against pinned certificates or public keys. 70 | 71 | @return The default security policy. 72 | */ 73 | + (instancetype)defaultPolicy; 74 | 75 | ///--------------------- 76 | /// @name Initialization 77 | ///--------------------- 78 | 79 | /** 80 | Creates and returns a security policy with the specified pinning mode. 81 | 82 | @param pinningMode The SSL pinning mode. 83 | 84 | @return A new security policy. 85 | */ 86 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; 87 | 88 | ///------------------------------ 89 | /// @name Evaluating Server Trust 90 | ///------------------------------ 91 | 92 | /** 93 | Whether or not the specified server trust should be accepted, based on the security policy. 94 | 95 | This method should be used when responding to an authentication challenge from a server. 96 | 97 | @param serverTrust The X.509 certificate trust of the server. 98 | 99 | @return Whether or not to trust the server. 100 | 101 | @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. 102 | */ 103 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; 104 | 105 | /** 106 | Whether or not the specified server trust should be accepted, based on the security policy. 107 | 108 | This method should be used when responding to an authentication challenge from a server. 109 | 110 | @param serverTrust The X.509 certificate trust of the server. 111 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 112 | 113 | @return Whether or not to trust the server. 114 | */ 115 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 116 | forDomain:(NSString *)domain; 117 | 118 | @end 119 | 120 | ///---------------- 121 | /// @name Constants 122 | ///---------------- 123 | 124 | /** 125 | ## SSL Pinning Modes 126 | 127 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. 128 | 129 | enum { 130 | AFSSLPinningModeNone, 131 | AFSSLPinningModePublicKey, 132 | AFSSLPinningModeCertificate, 133 | } 134 | 135 | `AFSSLPinningModeNone` 136 | Do not used pinned certificates to validate servers. 137 | 138 | `AFSSLPinningModePublicKey` 139 | Validate host certificates against public keys of pinned certificates. 140 | 141 | `AFSSLPinningModeCertificate` 142 | Validate host certificates against pinned certificates. 143 | */ 144 | -------------------------------------------------------------------------------- /Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // 3 | // Copyright (c) 2013-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 | /** 32 | `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. 33 | 34 | 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: 35 | 36 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 37 | 38 | By setting `isNetworkActivityIndicatorVisible` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. 39 | 40 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 41 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 42 | */ 43 | @interface AFNetworkActivityIndicatorManager : NSObject 44 | 45 | /** 46 | A Boolean value indicating whether the manager is enabled. 47 | 48 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 49 | */ 50 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 51 | 52 | /** 53 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. 54 | */ 55 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; 56 | 57 | /** 58 | Returns the shared network activity indicator manager object for the system. 59 | 60 | @return The systemwide network activity indicator manager. 61 | */ 62 | + (instancetype)sharedManager; 63 | 64 | /** 65 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 66 | */ 67 | - (void)incrementActivityCount; 68 | 69 | /** 70 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. 71 | */ 72 | - (void)decrementActivityCount; 73 | 74 | @end 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.m 2 | // 3 | // Copyright (c) 2013-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 "AFNetworkActivityIndicatorManager.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) 26 | 27 | #import "AFHTTPRequestOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; 34 | 35 | static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { 36 | if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) { 37 | return [(AFURLConnectionOperation *)[notification object] request]; 38 | } 39 | 40 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 41 | if ([[notification object] respondsToSelector:@selector(originalRequest)]) { 42 | return [(NSURLSessionTask *)[notification object] originalRequest]; 43 | } 44 | #endif 45 | 46 | return nil; 47 | } 48 | 49 | @interface AFNetworkActivityIndicatorManager () 50 | @property (readwrite, nonatomic, assign) NSInteger activityCount; 51 | @property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer; 52 | @property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 53 | 54 | - (void)updateNetworkActivityIndicatorVisibility; 55 | - (void)updateNetworkActivityIndicatorVisibilityDelayed; 56 | @end 57 | 58 | @implementation AFNetworkActivityIndicatorManager 59 | @dynamic networkActivityIndicatorVisible; 60 | 61 | + (instancetype)sharedManager { 62 | static AFNetworkActivityIndicatorManager *_sharedManager = nil; 63 | static dispatch_once_t oncePredicate; 64 | dispatch_once(&oncePredicate, ^{ 65 | _sharedManager = [[self alloc] init]; 66 | }); 67 | 68 | return _sharedManager; 69 | } 70 | 71 | + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { 72 | return [NSSet setWithObject:@"activityCount"]; 73 | } 74 | 75 | - (id)init { 76 | self = [super init]; 77 | if (!self) { 78 | return nil; 79 | } 80 | 81 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; 82 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; 83 | 84 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 85 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; 86 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; 87 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; 88 | #endif 89 | 90 | return self; 91 | } 92 | 93 | - (void)dealloc { 94 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 95 | 96 | [_activityIndicatorVisibilityTimer invalidate]; 97 | } 98 | 99 | - (void)updateNetworkActivityIndicatorVisibilityDelayed { 100 | if (self.enabled) { 101 | // Delay hiding of activity indicator for a short interval, to avoid flickering 102 | if (![self isNetworkActivityIndicatorVisible]) { 103 | [self.activityIndicatorVisibilityTimer invalidate]; 104 | self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO]; 105 | [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes]; 106 | } else { 107 | [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]]; 108 | } 109 | } 110 | } 111 | 112 | - (BOOL)isNetworkActivityIndicatorVisible { 113 | return self.activityCount > 0; 114 | } 115 | 116 | - (void)updateNetworkActivityIndicatorVisibility { 117 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; 118 | } 119 | 120 | - (void)setActivityCount:(NSInteger)activityCount { 121 | @synchronized(self) { 122 | _activityCount = activityCount; 123 | } 124 | 125 | dispatch_async(dispatch_get_main_queue(), ^{ 126 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 127 | }); 128 | } 129 | 130 | - (void)incrementActivityCount { 131 | [self willChangeValueForKey:@"activityCount"]; 132 | @synchronized(self) { 133 | _activityCount++; 134 | } 135 | [self didChangeValueForKey:@"activityCount"]; 136 | 137 | dispatch_async(dispatch_get_main_queue(), ^{ 138 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 139 | }); 140 | } 141 | 142 | - (void)decrementActivityCount { 143 | [self willChangeValueForKey:@"activityCount"]; 144 | @synchronized(self) { 145 | #pragma clang diagnostic push 146 | #pragma clang diagnostic ignored "-Wgnu" 147 | _activityCount = MAX(_activityCount - 1, 0); 148 | #pragma clang diagnostic pop 149 | } 150 | [self didChangeValueForKey:@"activityCount"]; 151 | 152 | dispatch_async(dispatch_get_main_queue(), ^{ 153 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 154 | }); 155 | } 156 | 157 | - (void)networkRequestDidStart:(NSNotification *)notification { 158 | if ([AFNetworkRequestFromNotification(notification) URL]) { 159 | [self incrementActivityCount]; 160 | } 161 | } 162 | 163 | - (void)networkRequestDidFinish:(NSNotification *)notification { 164 | if ([AFNetworkRequestFromNotification(notification) URL]) { 165 | [self decrementActivityCount]; 166 | } 167 | } 168 | 169 | @end 170 | 171 | #endif 172 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-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 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | 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. 35 | */ 36 | @interface UIActivityIndicatorView (AFNetworking) 37 | 38 | ///---------------------------------- 39 | /// @name Animating for Session Tasks 40 | ///---------------------------------- 41 | 42 | /** 43 | Binds the animating state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 46 | */ 47 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 48 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; 49 | #endif 50 | 51 | ///--------------------------------------- 52 | /// @name Animating for Request Operations 53 | ///--------------------------------------- 54 | 55 | /** 56 | Binds the animating state to the execution state of the specified operation. 57 | 58 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 59 | */ 60 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation; 61 | 62 | @end 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-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 "UIActivityIndicatorView+AFNetworking.h" 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 | @implementation UIActivityIndicatorView (AFNetworking) 34 | 35 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 36 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 37 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 38 | 39 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 40 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 41 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 42 | 43 | if (task) { 44 | if (task.state != NSURLSessionTaskStateCompleted) { 45 | if (task.state == NSURLSessionTaskStateRunning) { 46 | [self startAnimating]; 47 | } else { 48 | [self stopAnimating]; 49 | } 50 | 51 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; 52 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; 53 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; 54 | } 55 | } 56 | } 57 | #endif 58 | 59 | #pragma mark - 60 | 61 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { 62 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 63 | 64 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 65 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 66 | 67 | if (operation) { 68 | if (![operation isFinished]) { 69 | if ([operation isExecuting]) { 70 | [self startAnimating]; 71 | } else { 72 | [self stopAnimating]; 73 | } 74 | 75 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation]; 76 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation]; 77 | } 78 | } 79 | } 80 | 81 | #pragma mark - 82 | 83 | - (void)af_startAnimating { 84 | dispatch_async(dispatch_get_main_queue(), ^{ 85 | [self startAnimating]; 86 | }); 87 | } 88 | 89 | - (void)af_stopAnimating { 90 | dispatch_async(dispatch_get_main_queue(), ^{ 91 | [self stopAnimating]; 92 | }); 93 | } 94 | 95 | @end 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-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 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | 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. 35 | */ 36 | @interface UIAlertView (AFNetworking) 37 | 38 | ///------------------------------------- 39 | /// @name Showing Alert for Session Task 40 | ///------------------------------------- 41 | 42 | /** 43 | Shows an alert view with the error of the specified session task, if any. 44 | 45 | @param task The session task. 46 | @param delegate The alert view delegate. 47 | */ 48 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 49 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 50 | delegate:(id)delegate; 51 | #endif 52 | 53 | /** 54 | Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles. 55 | 56 | @param task The session task. 57 | @param delegate The alert view delegate. 58 | @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. 59 | @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`. 60 | */ 61 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 62 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 63 | delegate:(id)delegate 64 | cancelButtonTitle:(NSString *)cancelButtonTitle 65 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; 66 | #endif 67 | 68 | ///------------------------------------------ 69 | /// @name Showing Alert for Request Operation 70 | ///------------------------------------------ 71 | 72 | /** 73 | Shows an alert view with the error of the specified request operation, if any. 74 | 75 | @param operation The request operation. 76 | @param delegate The alert view delegate. 77 | */ 78 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 79 | delegate:(id)delegate; 80 | 81 | /** 82 | Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles. 83 | 84 | @param operation The request operation. 85 | @param delegate The alert view delegate. 86 | @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. 87 | @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`. 88 | */ 89 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 90 | delegate:(id)delegate 91 | cancelButtonTitle:(NSString *)cancelButtonTitle 92 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; 93 | 94 | @end 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-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 "UIAlertView+AFNetworking.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 26 | 27 | #import "AFURLConnectionOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) { 34 | if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) { 35 | *title = error.localizedDescription; 36 | 37 | if (error.localizedRecoverySuggestion) { 38 | *message = error.localizedRecoverySuggestion; 39 | } else { 40 | *message = error.localizedFailureReason; 41 | } 42 | } else if (error.localizedDescription) { 43 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 44 | *message = error.localizedDescription; 45 | } else { 46 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 47 | *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code]; 48 | } 49 | } 50 | 51 | @implementation UIAlertView (AFNetworking) 52 | 53 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 54 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 55 | delegate:(id)delegate 56 | { 57 | [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; 58 | } 59 | 60 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 61 | delegate:(id)delegate 62 | cancelButtonTitle:(NSString *)cancelButtonTitle 63 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 64 | { 65 | __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 66 | 67 | NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey]; 68 | if (error) { 69 | NSString *title, *message; 70 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 71 | 72 | [[[UIAlertView alloc] initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles, nil] show]; 73 | } 74 | 75 | [[NSNotificationCenter defaultCenter] removeObserver:observer name:AFNetworkingTaskDidCompleteNotification object:notification.object]; 76 | }]; 77 | } 78 | #endif 79 | 80 | #pragma mark - 81 | 82 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 83 | delegate:(id)delegate 84 | { 85 | [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlert View Cancel Button Title") otherButtonTitles:nil, nil]; 86 | } 87 | 88 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 89 | delegate:(id)delegate 90 | cancelButtonTitle:(NSString *)cancelButtonTitle 91 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 92 | { 93 | __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 94 | 95 | if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) { 96 | NSError *error = [(AFURLConnectionOperation *)notification.object error]; 97 | if (error) { 98 | NSString *title, *message; 99 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 100 | 101 | [[[UIAlertView alloc] initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles, nil] show]; 102 | } 103 | } 104 | 105 | [[NSNotificationCenter defaultCenter] removeObserver:observer name:AFNetworkingOperationDidFinishNotification object:notification.object]; 106 | }]; 107 | } 108 | 109 | @end 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /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 | #import 24 | 25 | #ifndef _UIKIT_AFNETWORKING_ 26 | #define _UIKIT_AFNETWORKING_ 27 | 28 | #import "AFNetworkActivityIndicatorManager.h" 29 | 30 | #import "UIActivityIndicatorView+AFNetworking.h" 31 | #import "UIAlertView+AFNetworking.h" 32 | #import "UIButton+AFNetworking.h" 33 | #import "UIImageView+AFNetworking.h" 34 | #import "UIKit+AFNetworking.h" 35 | #import "UIProgressView+AFNetworking.h" 36 | #import "UIRefreshControl+AFNetworking.h" 37 | #import "UIWebView+AFNetworking.h" 38 | #endif /* _UIKIT_AFNETWORKING_ */ 39 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-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 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | 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. 35 | */ 36 | @interface UIProgressView (AFNetworking) 37 | 38 | ///------------------------------------ 39 | /// @name Setting Session Task Progress 40 | ///------------------------------------ 41 | 42 | /** 43 | Binds the progress to the upload progress of the specified session task. 44 | 45 | @param task The session task. 46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 47 | */ 48 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 49 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 50 | animated:(BOOL)animated; 51 | #endif 52 | 53 | /** 54 | Binds the progress to the download progress of the specified session task. 55 | 56 | @param task The session task. 57 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 58 | */ 59 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 60 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 61 | animated:(BOOL)animated; 62 | #endif 63 | 64 | ///------------------------------------ 65 | /// @name Setting Session Task Progress 66 | ///------------------------------------ 67 | 68 | /** 69 | Binds the progress to the upload progress of the specified request operation. 70 | 71 | @param operation The request operation. 72 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 73 | */ 74 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation 75 | animated:(BOOL)animated; 76 | 77 | /** 78 | Binds the progress to the download progress of the specified request operation. 79 | 80 | @param operation The request operation. 81 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 82 | */ 83 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation 84 | animated:(BOOL)animated; 85 | 86 | @end 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /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 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically begining and ending refreshing depending on the loading state of a request operation or session task. 35 | */ 36 | @interface UIRefreshControl (AFNetworking) 37 | 38 | ///----------------------------------- 39 | /// @name Refreshing for Session Tasks 40 | ///----------------------------------- 41 | 42 | /** 43 | Binds the refreshing state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be diabled. 46 | */ 47 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 48 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 49 | #endif 50 | 51 | ///---------------------------------------- 52 | /// @name Refreshing for Request Operations 53 | ///---------------------------------------- 54 | 55 | /** 56 | Binds the refreshing state to the execution state of the specified operation. 57 | 58 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 59 | */ 60 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; 61 | 62 | @end 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /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 | 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 | @implementation UIRefreshControl (AFNetworking) 34 | 35 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 36 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 37 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 38 | 39 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 40 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 41 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 42 | 43 | if (task) { 44 | if (task.state != NSURLSessionTaskStateCompleted) { 45 | if (task.state == NSURLSessionTaskStateRunning) { 46 | [self beginRefreshing]; 47 | } else { 48 | [self endRefreshing]; 49 | } 50 | 51 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; 52 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; 53 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; 54 | } 55 | } 56 | } 57 | #endif 58 | 59 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { 60 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 61 | 62 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 63 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 64 | 65 | if (operation) { 66 | if (![operation isFinished]) { 67 | if ([operation isExecuting]) { 68 | [self beginRefreshing]; 69 | } else { 70 | [self endRefreshing]; 71 | } 72 | 73 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation]; 74 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation]; 75 | } 76 | } 77 | } 78 | 79 | #pragma mark - 80 | 81 | - (void)af_beginRefreshing { 82 | dispatch_async(dispatch_get_main_queue(), ^{ 83 | [self beginRefreshing]; 84 | }); 85 | } 86 | 87 | - (void)af_endRefreshing { 88 | dispatch_async(dispatch_get_main_queue(), ^{ 89 | [self endRefreshing]; 90 | }); 91 | } 92 | 93 | @end 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-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 | @class AFHTTPRequestSerializer, AFHTTPResponseSerializer; 32 | @protocol AFURLRequestSerialization, AFURLResponseSerialization; 33 | 34 | /** 35 | 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. 36 | 37 | @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. 38 | */ 39 | @interface UIWebView (AFNetworking) 40 | 41 | /** 42 | The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`. 43 | */ 44 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; 45 | 46 | /** 47 | The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`. 48 | */ 49 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 50 | 51 | /** 52 | Asynchronously loads the specified request. 53 | 54 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 55 | @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. 56 | @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. 57 | @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. 58 | */ 59 | - (void)loadRequest:(NSURLRequest *)request 60 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 61 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 62 | failure:(void (^)(NSError *error))failure; 63 | 64 | /** 65 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. 66 | 67 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 68 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. 69 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. 70 | @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. 71 | @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. 72 | @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. 73 | */ 74 | - (void)loadRequest:(NSURLRequest *)request 75 | MIMEType:(NSString *)MIMEType 76 | textEncodingName:(NSString *)textEncodingName 77 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 78 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 79 | failure:(void (^)(NSError *error))failure; 80 | 81 | @end 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-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 "UIWebView+AFNetworking.h" 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import "AFHTTPRequestOperation.h" 30 | #import "AFURLResponseSerialization.h" 31 | #import "AFURLRequestSerialization.h" 32 | 33 | @interface UIWebView (_AFNetworking) 34 | @property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation; 35 | @end 36 | 37 | @implementation UIWebView (_AFNetworking) 38 | 39 | - (AFHTTPRequestOperation *)af_HTTPRequestOperation { 40 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_HTTPRequestOperation)); 41 | } 42 | 43 | - (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation { 44 | objc_setAssociatedObject(self, @selector(af_HTTPRequestOperation), operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | } 46 | 47 | @end 48 | 49 | #pragma mark - 50 | 51 | @implementation UIWebView (AFNetworking) 52 | 53 | - (AFHTTPRequestSerializer *)requestSerializer { 54 | static AFHTTPRequestSerializer *_af_defaultRequestSerializer = nil; 55 | static dispatch_once_t onceToken; 56 | dispatch_once(&onceToken, ^{ 57 | _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer]; 58 | }); 59 | 60 | #pragma clang diagnostic push 61 | #pragma clang diagnostic ignored "-Wgnu" 62 | return objc_getAssociatedObject(self, @selector(requestSerializer)) ?: _af_defaultRequestSerializer; 63 | #pragma clang diagnostic pop 64 | } 65 | 66 | - (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { 67 | objc_setAssociatedObject(self, @selector(requestSerializer), requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 68 | } 69 | 70 | - (AFHTTPResponseSerializer *)responseSerializer { 71 | static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; 72 | static dispatch_once_t onceToken; 73 | dispatch_once(&onceToken, ^{ 74 | _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; 75 | }); 76 | 77 | #pragma clang diagnostic push 78 | #pragma clang diagnostic ignored "-Wgnu" 79 | return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; 80 | #pragma clang diagnostic pop 81 | } 82 | 83 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 84 | objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 85 | } 86 | 87 | #pragma mark - 88 | 89 | - (void)loadRequest:(NSURLRequest *)request 90 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 91 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 92 | failure:(void (^)(NSError *error))failure 93 | { 94 | [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { 95 | NSStringEncoding stringEncoding = NSUTF8StringEncoding; 96 | if (response.textEncodingName) { 97 | CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); 98 | if (encoding != kCFStringEncodingInvalidId) { 99 | stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); 100 | } 101 | } 102 | 103 | NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; 104 | if (success) { 105 | string = success(response, string); 106 | } 107 | 108 | return [string dataUsingEncoding:stringEncoding]; 109 | } failure:failure]; 110 | } 111 | 112 | - (void)loadRequest:(NSURLRequest *)request 113 | MIMEType:(NSString *)MIMEType 114 | textEncodingName:(NSString *)textEncodingName 115 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 116 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 117 | failure:(void (^)(NSError *error))failure 118 | { 119 | NSParameterAssert(request); 120 | 121 | if (self.af_HTTPRequestOperation) { 122 | [self.af_HTTPRequestOperation cancel]; 123 | } 124 | 125 | request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil]; 126 | 127 | self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 128 | self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer; 129 | 130 | __weak __typeof(self)weakSelf = self; 131 | [self.af_HTTPRequestOperation setDownloadProgressBlock:progress]; 132 | [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) { 133 | NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData; 134 | 135 | #pragma clang diagnostic push 136 | #pragma clang diagnostic ignored "-Wgnu" 137 | __strong __typeof(weakSelf) strongSelf = weakSelf; 138 | [strongSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]]; 139 | #pragma clang diagnostic pop 140 | } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) { 141 | if (failure) { 142 | failure(error); 143 | } 144 | }]; 145 | 146 | [self.af_HTTPRequestOperation start]; 147 | } 148 | 149 | @end 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestOperationManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1RequestOperationManager.h 3 | // 4 | // Copyright (c) 2014 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 "AFHTTPRequestOperationManager.h" 24 | #import "BDBOAuth1RequestSerializer.h" 25 | 26 | 27 | #pragma mark - 28 | @interface BDBOAuth1RequestOperationManager : AFHTTPRequestOperationManager 29 | 30 | @property (nonatomic, strong) BDBOAuth1RequestSerializer *requestSerializer; 31 | @property (nonatomic, assign, readonly, getter = isAuthorized) BOOL authorized; 32 | 33 | #pragma mark Initialization 34 | - (instancetype)initWithBaseURL:(NSURL *)url consumerKey:(NSString *)key consumerSecret:(NSString *)secret; 35 | 36 | #pragma mark Deauthorize 37 | - (BOOL)deauthorize; 38 | 39 | #pragma mark Authorization Flow 40 | - (void)fetchRequestTokenWithPath:(NSString *)requestPath 41 | method:(NSString *)method 42 | callbackURL:(NSURL *)callbackURL 43 | scope:(NSString *)scope 44 | success:(void (^)(BDBOAuthToken *requestToken))success 45 | failure:(void (^)(NSError *error))failure; 46 | 47 | - (void)fetchAccessTokenWithPath:(NSString *)accessPath 48 | method:(NSString *)method 49 | requestToken:(BDBOAuthToken *)requestToken 50 | success:(void (^)(BDBOAuthToken *accessToken))success 51 | failure:(void (^)(NSError *error))failure; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestOperationManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1RequestOperationManager.m 3 | // 4 | // Copyright (c) 2014 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 | #pragma mark Initialization 36 | - (instancetype)initWithBaseURL:(NSURL *)url consumerKey:(NSString *)key consumerSecret:(NSString *)secret 37 | { 38 | self = [super initWithBaseURL:url]; 39 | if (self) 40 | { 41 | self.requestSerializer = [BDBOAuth1RequestSerializer serializerForService:url.host withConsumerKey:key consumerSecret:secret]; 42 | } 43 | return self; 44 | } 45 | 46 | #pragma mark Access Token 47 | - (BOOL)isAuthorized 48 | { 49 | return (self.requestSerializer.accessToken && !self.requestSerializer.accessToken.expired); 50 | } 51 | 52 | - (BOOL)deauthorize 53 | { 54 | return [self.requestSerializer removeAccessToken]; 55 | } 56 | 57 | #pragma mark Authorization Flow 58 | - (void)fetchRequestTokenWithPath:(NSString *)requestPath 59 | method:(NSString *)method 60 | callbackURL:(NSURL *)callbackURL 61 | scope:(NSString *)scope 62 | success:(void (^)(BDBOAuthToken *requestToken))success 63 | failure:(void (^)(NSError *error))failure 64 | { 65 | self.requestSerializer.requestToken = nil; 66 | 67 | AFHTTPResponseSerializer *defaultSerializer = self.responseSerializer; 68 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 69 | 70 | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; 71 | parameters[BDBOAuth1OAuthCallbackParameter] = [callbackURL absoluteString]; 72 | if (scope && !self.requestSerializer.accessToken) 73 | parameters[@"scope"] = scope; 74 | 75 | NSString *URLString = [[NSURL URLWithString:requestPath relativeToURL:self.baseURL] absoluteString]; 76 | NSError *error; 77 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:URLString parameters:parameters error:&error]; 78 | 79 | if (error) 80 | { 81 | failure(error); 82 | return; 83 | } 84 | 85 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { 86 | self.responseSerializer = defaultSerializer; 87 | BDBOAuthToken *requestToken = [BDBOAuthToken tokenWithQueryString:operation.responseString]; 88 | self.requestSerializer.requestToken = requestToken; 89 | if (success) 90 | success(requestToken); 91 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 92 | self.responseSerializer = defaultSerializer; 93 | if (failure) 94 | failure(error); 95 | }]; 96 | 97 | [self.operationQueue addOperation:operation]; 98 | } 99 | 100 | - (void)fetchAccessTokenWithPath:(NSString *)accessPath 101 | method:(NSString *)method 102 | requestToken:(BDBOAuthToken *)requestToken 103 | success:(void (^)(BDBOAuthToken *accessToken))success 104 | failure:(void (^)(NSError *error))failure 105 | { 106 | if (requestToken.token && requestToken.verifier) 107 | { 108 | AFHTTPResponseSerializer *defaultSerializer = self.responseSerializer; 109 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 110 | 111 | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; 112 | parameters[BDBOAuth1OAuthTokenParameter] = requestToken.token; 113 | parameters[BDBOAuth1OAuthVerifierParameter] = requestToken.verifier; 114 | 115 | NSString *URLString = [[NSURL URLWithString:accessPath relativeToURL:self.baseURL] absoluteString]; 116 | NSError *error; 117 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:URLString parameters:parameters error:&error]; 118 | 119 | if (error) 120 | { 121 | failure(error); 122 | return; 123 | } 124 | 125 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { 126 | self.responseSerializer = defaultSerializer; 127 | self.requestSerializer.requestToken = nil; 128 | BDBOAuthToken *accessToken = [BDBOAuthToken tokenWithQueryString:operation.responseString]; 129 | [self.requestSerializer saveAccessToken:accessToken]; 130 | if (success) 131 | success(accessToken); 132 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 133 | self.responseSerializer = defaultSerializer; 134 | self.requestSerializer.requestToken = nil; 135 | if (failure) 136 | failure(error); 137 | }]; 138 | 139 | [self.operationQueue addOperation:operation]; 140 | } 141 | else 142 | { 143 | NSError *error = [[NSError alloc] initWithDomain:BDBOAuth1ErrorDomain 144 | code:NSURLErrorBadServerResponse 145 | userInfo:@{NSLocalizedFailureReasonErrorKey:@"Invalid OAuth response received from server."}]; 146 | failure(error); 147 | } 148 | } 149 | 150 | @end 151 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestSerializer.h: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1RequestSerializer.h 3 | // 4 | // Copyright (c) 2014 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 "AFURLRequestSerialization.h" 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 BDBOAuthToken : NSObject 38 | 39 | 40 | @property (nonatomic, copy, readonly) NSString *token; 41 | @property (nonatomic, copy, readonly) NSString *secret; 42 | @property (nonatomic, copy) NSString *verifier; 43 | 44 | @property (nonatomic, assign, readonly, getter = isExpired) BOOL expired; 45 | 46 | @property (nonatomic) NSDictionary *userInfo; 47 | 48 | #pragma mark Initialization 49 | + (instancetype)tokenWithToken:(NSString *)token secret:(NSString *)secret expiration:(NSDate *)expiration; 50 | + (instancetype)tokenWithQueryString:(NSString *)queryString; 51 | 52 | @end 53 | 54 | 55 | #pragma mark - 56 | @interface BDBOAuth1RequestSerializer : AFHTTPRequestSerializer 57 | 58 | @property (nonatomic, copy) BDBOAuthToken *requestToken; 59 | @property (nonatomic, copy, readonly) BDBOAuthToken *accessToken; 60 | 61 | #pragma mark Initialization 62 | + (instancetype)serializerForService:(NSString *)service withConsumerKey:(NSString *)key consumerSecret:(NSString *)secret; 63 | - (instancetype)initWithService:(NSString *)service consumerKey:(NSString *)key consumerSecret:(NSString *)secret; 64 | 65 | #pragma mark OAuth 66 | - (NSDictionary *)OAuthParameters; 67 | 68 | #pragma mark AccessToken 69 | - (BOOL)saveAccessToken:(BDBOAuthToken *)accessToken; 70 | - (BOOL)removeAccessToken; 71 | 72 | @end 73 | 74 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1SessionManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1SessionManager.h 3 | // 4 | // Copyright (c) 2014 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 "AFHTTPSessionManager.h" 24 | #import "BDBOAuth1RequestSerializer.h" 25 | 26 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) 27 | 28 | #pragma mark - 29 | @interface BDBOAuth1SessionManager : AFHTTPSessionManager 30 | 31 | @property (nonatomic, strong) BDBOAuth1RequestSerializer *requestSerializer; 32 | @property (nonatomic, assign, readonly, getter = isAuthorized) BOOL authorized; 33 | 34 | #pragma mark Initialization 35 | - (instancetype)initWithBaseURL:(NSURL *)url consumerKey:(NSString *)key consumerSecret:(NSString *)secret; 36 | 37 | #pragma mark Deauthorize 38 | - (BOOL)deauthorize; 39 | 40 | #pragma mark Authorization Flow 41 | - (void)fetchRequestTokenWithPath:(NSString *)requestPath 42 | method:(NSString *)method 43 | callbackURL:(NSURL *)callbackURL 44 | scope:(NSString *)scope 45 | success:(void (^)(BDBOAuthToken *requestToken))success 46 | failure:(void (^)(NSError *error))failure; 47 | 48 | - (void)fetchAccessTokenWithPath:(NSString *)accessPath 49 | method:(NSString *)method 50 | requestToken:(BDBOAuthToken *)requestToken 51 | success:(void (^)(BDBOAuthToken *accessToken))success 52 | failure:(void (^)(NSError *error))failure; 53 | 54 | @end 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1SessionManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // BDBOAuth1SessionManager.m 3 | // 4 | // Copyright (c) 2014 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_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) 27 | 28 | #pragma mark - 29 | @interface BDBOAuth1SessionManager () 30 | 31 | @end 32 | 33 | 34 | #pragma mark - 35 | @implementation BDBOAuth1SessionManager 36 | 37 | #pragma mark Initialization 38 | - (instancetype)initWithBaseURL:(NSURL *)url consumerKey:(NSString *)key consumerSecret:(NSString *)secret 39 | { 40 | self = [super initWithBaseURL:url]; 41 | if (self) 42 | { 43 | self.requestSerializer = [BDBOAuth1RequestSerializer serializerForService:url.host withConsumerKey:key consumerSecret:secret]; 44 | } 45 | return self; 46 | } 47 | 48 | #pragma mark Access Token 49 | - (BOOL)isAuthorized 50 | { 51 | return (self.requestSerializer.accessToken && !self.requestSerializer.accessToken.expired); 52 | } 53 | 54 | - (BOOL)deauthorize 55 | { 56 | return [self.requestSerializer removeAccessToken]; 57 | } 58 | 59 | #pragma mark Authorization Flow 60 | - (void)fetchRequestTokenWithPath:(NSString *)requestPath 61 | method:(NSString *)method 62 | callbackURL:(NSURL *)callbackURL 63 | scope:(NSString *)scope 64 | success:(void (^)(BDBOAuthToken *requestToken))success 65 | failure:(void (^)(NSError *error))failure 66 | { 67 | self.requestSerializer.requestToken = nil; 68 | 69 | AFHTTPResponseSerializer *defaultSerializer = self.responseSerializer; 70 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 71 | 72 | NSMutableDictionary *parameters = [[self.requestSerializer OAuthParameters] mutableCopy]; 73 | parameters[BDBOAuth1OAuthCallbackParameter] = [callbackURL absoluteString]; 74 | if (scope && !self.requestSerializer.accessToken) 75 | parameters[@"scope"] = scope; 76 | 77 | NSString *URLString = [[NSURL URLWithString:requestPath relativeToURL:self.baseURL] absoluteString]; 78 | NSError *error; 79 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:URLString parameters:parameters error:&error]; 80 | 81 | if (error) 82 | { 83 | failure(error); 84 | return; 85 | } 86 | 87 | NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { 88 | self.responseSerializer = defaultSerializer; 89 | if (!error) 90 | { 91 | BDBOAuthToken *requestToken = [BDBOAuthToken tokenWithQueryString:[[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]]; 92 | self.requestSerializer.requestToken = requestToken; 93 | if (success) 94 | success(requestToken); 95 | } 96 | else 97 | if (failure) 98 | failure(error); 99 | }]; 100 | 101 | [task resume]; 102 | } 103 | 104 | - (void)fetchAccessTokenWithPath:(NSString *)accessPath 105 | method:(NSString *)method 106 | requestToken:(BDBOAuthToken *)requestToken 107 | success:(void (^)(BDBOAuthToken *accessToken))success 108 | failure:(void (^)(NSError *error))failure 109 | { 110 | if (requestToken.token && requestToken.verifier) 111 | { 112 | AFHTTPResponseSerializer *defaultSerializer = self.responseSerializer; 113 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 114 | 115 | NSMutableDictionary *parameters = [[self.requestSerializer OAuthParameters] mutableCopy]; 116 | parameters[BDBOAuth1OAuthTokenParameter] = requestToken.token; 117 | parameters[BDBOAuth1OAuthVerifierParameter] = requestToken.verifier; 118 | 119 | NSString *URLString = [[NSURL URLWithString:accessPath relativeToURL:self.baseURL] absoluteString]; 120 | NSError *error; 121 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:URLString parameters:parameters error:&error]; 122 | 123 | if (error) 124 | { 125 | failure(error); 126 | return; 127 | } 128 | 129 | NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { 130 | self.responseSerializer = defaultSerializer; 131 | self.requestSerializer.requestToken = nil; 132 | if (!error) 133 | { 134 | BDBOAuthToken *accessToken = [BDBOAuthToken tokenWithQueryString:[[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]]; 135 | [self.requestSerializer saveAccessToken:accessToken]; 136 | if (success) 137 | success(accessToken); 138 | } 139 | else 140 | if (failure) 141 | failure(error); 142 | }]; 143 | 144 | [task resume]; 145 | } 146 | else 147 | { 148 | NSError *error = [[NSError alloc] initWithDomain:BDBOAuth1ErrorDomain 149 | code:NSURLErrorBadServerResponse 150 | userInfo:@{NSLocalizedFailureReasonErrorKey:@"Invalid OAuth response received from server."}]; 151 | failure(error); 152 | } 153 | } 154 | 155 | @end 156 | 157 | #endif 158 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSDictionary+BDBOAuth1Manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+BDBOAuth1Manager.h 3 | // 4 | // Copyright (c) 2014 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 | #pragma mark - 27 | @interface NSDictionary (BDBOAuth1Manager) 28 | 29 | + (instancetype)dictionaryFromQueryString:(NSString *)queryString; 30 | - (instancetype)bdb_initWithQueryString:(NSString *)queryString; 31 | 32 | - (NSString *)bdb_queryStringRepresentation; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSDictionary+BDBOAuth1Manager.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+BDBOAuth1Manager.m 3 | // 4 | // Copyright (c) 2014 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 | + (instancetype)dictionaryFromQueryString:(NSString *)queryString 31 | { 32 | return [[[self class] alloc] bdb_initWithQueryString:queryString]; 33 | } 34 | 35 | - (instancetype)bdb_initWithQueryString:(NSString *)queryString 36 | { 37 | NSArray *components = [queryString componentsSeparatedByString:@"&"]; 38 | NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; 39 | 40 | for (NSString *component in components) { 41 | NSArray *keyValue = [component componentsSeparatedByString:@"="]; 42 | 43 | dictionary[[keyValue[0] bdb_URLDecode]] = [keyValue[1] bdb_URLDecode]; 44 | } 45 | 46 | return [self initWithDictionary:dictionary]; 47 | } 48 | 49 | - (NSString *)bdb_queryStringRepresentation 50 | { 51 | NSMutableArray *paramArray = [NSMutableArray array]; 52 | [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { 53 | NSString *param = [NSString stringWithFormat:@"%@=%@", [key bdb_URLEncode], [obj bdb_URLEncode]]; 54 | [paramArray addObject:param]; 55 | }]; 56 | return [paramArray componentsJoinedByString:@"&"]; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSString+BDBOAuth1Manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+BDBOAuth1Manager.h 3 | // 4 | // Copyright (c) 2014 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 | #pragma mark - 27 | @interface NSString (BDBOAuth1Manager) 28 | 29 | - (NSString *)bdb_URLEncode; 30 | - (NSString *)bdb_URLDecode; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Pods/BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSString+BDBOAuth1Manager.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+BDBOAuth1Manager.m 3 | // 4 | // Copyright (c) 2014 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 | - (NSString *)bdb_URLEncode 32 | { 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 | { 43 | return (__bridge_transfer NSString *) 44 | CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, 45 | (__bridge CFStringRef)self, 46 | (__bridge CFStringRef)@"", 47 | kCFStringEncodingUTF8); 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /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/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperationManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLConnectionOperation.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/BDBOAuth1Manager/BDBOAuth1RequestOperationManager.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestOperationManager.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/BDBOAuth1Manager/BDBOAuth1RequestSerializer.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestSerializer.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/BDBOAuth1Manager/BDBOAuth1SessionManager.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1SessionManager.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/BDBOAuth1Manager/NSDictionary+BDBOAuth1Manager.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSDictionary+BDBOAuth1Manager.h -------------------------------------------------------------------------------- /Pods/BuildHeaders/BDBOAuth1Manager/NSString+BDBOAuth1Manager.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSString+BDBOAuth1Manager.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFHTTPRequestOperationManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFURLConnectionOperation.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLConnectionOperation.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/BDBOAuth1Manager/BDBOAuth1RequestOperationManager.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestOperationManager.h -------------------------------------------------------------------------------- /Pods/Headers/BDBOAuth1Manager/BDBOAuth1RequestSerializer.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1RequestSerializer.h -------------------------------------------------------------------------------- /Pods/Headers/BDBOAuth1Manager/BDBOAuth1SessionManager.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/BDBOAuth1SessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/BDBOAuth1Manager/NSDictionary+BDBOAuth1Manager.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSDictionary+BDBOAuth1Manager.h -------------------------------------------------------------------------------- /Pods/Headers/BDBOAuth1Manager/NSString+BDBOAuth1Manager.h: -------------------------------------------------------------------------------- 1 | ../../BDBOAuth1Manager/BDBOAuth1Manager/Categories/NSString+BDBOAuth1Manager.h -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (2.4.1): 3 | - AFNetworking/NSURLConnection 4 | - AFNetworking/NSURLSession 5 | - AFNetworking/Reachability 6 | - AFNetworking/Security 7 | - AFNetworking/Serialization 8 | - AFNetworking/UIKit 9 | - AFNetworking/NSURLConnection (2.4.1): 10 | - AFNetworking/Reachability 11 | - AFNetworking/Security 12 | - AFNetworking/Serialization 13 | - AFNetworking/NSURLSession (2.4.1): 14 | - AFNetworking/Reachability 15 | - AFNetworking/Security 16 | - AFNetworking/Serialization 17 | - AFNetworking/Reachability (2.4.1) 18 | - AFNetworking/Security (2.4.1) 19 | - AFNetworking/Serialization (2.4.1) 20 | - AFNetworking/UIKit (2.4.1): 21 | - AFNetworking/NSURLConnection 22 | - AFNetworking/NSURLSession 23 | - BDBOAuth1Manager (1.4.1): 24 | - AFNetworking/NSURLConnection (~> 2.4.0) 25 | - AFNetworking/NSURLSession (~> 2.4.0) 26 | 27 | DEPENDENCIES: 28 | - AFNetworking 29 | - BDBOAuth1Manager 30 | 31 | SPEC CHECKSUMS: 32 | AFNetworking: 0aabc6fae66d6e5d039eeb21c315843c7aae51ab 33 | BDBOAuth1Manager: 0625ba20bd7d36461bbf6dc3d29276b5932b7409 34 | 35 | COCOAPODS: 0.33.1 36 | -------------------------------------------------------------------------------- /Pods/Pods-AFNetworking-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-AFNetworking.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/AFNetworking" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" "${PODS_ROOT}/Headers/BDBOAuth1Manager" 4 | OTHER_LDFLAGS = -ObjC ${PODS_AFNETWORKING_OTHER_LDFLAGS} 5 | PODS_ROOT = ${SRCROOT} -------------------------------------------------------------------------------- /Pods/Pods-AFNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_AFNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_AFNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Pods-AFNetworking-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-environment.h" 6 | -------------------------------------------------------------------------------- /Pods/Pods-AFNetworking.xcconfig: -------------------------------------------------------------------------------- 1 | PODS_AFNETWORKING_OTHER_LDFLAGS = -framework CoreGraphics -framework MobileCoreServices -framework Security -framework SystemConfiguration -------------------------------------------------------------------------------- /Pods/Pods-BDBOAuth1Manager-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-BDBOAuth1Manager.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/BDBOAuth1Manager" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" "${PODS_ROOT}/Headers/BDBOAuth1Manager" 4 | OTHER_LDFLAGS = -ObjC 5 | PODS_ROOT = ${SRCROOT} -------------------------------------------------------------------------------- /Pods/Pods-BDBOAuth1Manager-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_BDBOAuth1Manager : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_BDBOAuth1Manager 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Pods-BDBOAuth1Manager-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-environment.h" 6 | -------------------------------------------------------------------------------- /Pods/Pods-BDBOAuth1Manager.xcconfig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziyang0621/Twitter-SideMenu-Swift/62cacba93e84a36708f13714584a48ebbcd1759f/Pods/Pods-BDBOAuth1Manager.xcconfig -------------------------------------------------------------------------------- /Pods/Pods-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com/) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | 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 - http://cocoapods.org 51 | -------------------------------------------------------------------------------- /Pods/Pods-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com/) 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | Title 38 | AFNetworking 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | 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 - http://cocoapods.org 73 | Title 74 | 75 | Type 76 | PSGroupSpecifier 77 | 78 | 79 | StringsTable 80 | Acknowledgements 81 | Title 82 | Acknowledgements 83 | 84 | 85 | -------------------------------------------------------------------------------- /Pods/Pods-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods : NSObject 3 | @end 4 | @implementation PodsDummy_Pods 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Pods-environment.h: -------------------------------------------------------------------------------- 1 | 2 | // To check if a library is compiled with CocoaPods you 3 | // can use the `COCOAPODS` macro definition which is 4 | // defined in the xcconfigs so it is available in 5 | // headers also when they are imported in the client 6 | // project. 7 | 8 | 9 | // AFNetworking 10 | #define COCOAPODS_POD_AVAILABLE_AFNetworking 11 | #define COCOAPODS_VERSION_MAJOR_AFNetworking 2 12 | #define COCOAPODS_VERSION_MINOR_AFNetworking 4 13 | #define COCOAPODS_VERSION_PATCH_AFNetworking 1 14 | 15 | // AFNetworking/NSURLConnection 16 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_NSURLConnection 17 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_NSURLConnection 2 18 | #define COCOAPODS_VERSION_MINOR_AFNetworking_NSURLConnection 4 19 | #define COCOAPODS_VERSION_PATCH_AFNetworking_NSURLConnection 1 20 | 21 | // AFNetworking/NSURLSession 22 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_NSURLSession 23 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_NSURLSession 2 24 | #define COCOAPODS_VERSION_MINOR_AFNetworking_NSURLSession 4 25 | #define COCOAPODS_VERSION_PATCH_AFNetworking_NSURLSession 1 26 | 27 | // AFNetworking/Reachability 28 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Reachability 29 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Reachability 2 30 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Reachability 4 31 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Reachability 1 32 | 33 | // AFNetworking/Security 34 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Security 35 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Security 2 36 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Security 4 37 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Security 1 38 | 39 | // AFNetworking/Serialization 40 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Serialization 41 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Serialization 2 42 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Serialization 4 43 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Serialization 1 44 | 45 | // AFNetworking/UIKit 46 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_UIKit 47 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_UIKit 2 48 | #define COCOAPODS_VERSION_MINOR_AFNetworking_UIKit 4 49 | #define COCOAPODS_VERSION_PATCH_AFNetworking_UIKit 1 50 | 51 | // BDBOAuth1Manager 52 | #define COCOAPODS_POD_AVAILABLE_BDBOAuth1Manager 53 | #define COCOAPODS_VERSION_MAJOR_BDBOAuth1Manager 1 54 | #define COCOAPODS_VERSION_MINOR_BDBOAuth1Manager 4 55 | #define COCOAPODS_VERSION_PATCH_BDBOAuth1Manager 1 56 | 57 | -------------------------------------------------------------------------------- /Pods/Pods-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 5 | > "$RESOURCES_TO_COPY" 6 | 7 | install_resource() 8 | { 9 | case $1 in 10 | *.storyboard) 11 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 12 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 13 | ;; 14 | *.xib) 15 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 16 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 17 | ;; 18 | *.framework) 19 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 21 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 22 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 23 | ;; 24 | *.xcdatamodel) 25 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 26 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 27 | ;; 28 | *.xcdatamodeld) 29 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 30 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 31 | ;; 32 | *.xcassets) 33 | ;; 34 | /*) 35 | echo "$1" 36 | echo "$1" >> "$RESOURCES_TO_COPY" 37 | ;; 38 | *) 39 | echo "${PODS_ROOT}/$1" 40 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 41 | ;; 42 | esac 43 | } 44 | 45 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 46 | if [[ "${ACTION}" == "install" ]]; then 47 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 48 | fi 49 | rm -f "$RESOURCES_TO_COPY" 50 | 51 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ `xcrun --find actool` ] && [ `find . -name '*.xcassets' | wc -l` -ne 0 ] 52 | then 53 | case "${TARGETED_DEVICE_FAMILY}" in 54 | 1,2) 55 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 56 | ;; 57 | 1) 58 | TARGET_DEVICE_ARGS="--target-device iphone" 59 | ;; 60 | 2) 61 | TARGET_DEVICE_ARGS="--target-device ipad" 62 | ;; 63 | *) 64 | TARGET_DEVICE_ARGS="--target-device mac" 65 | ;; 66 | esac 67 | find "${PWD}" -name "*.xcassets" -print0 | xargs -0 actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 68 | fi 69 | -------------------------------------------------------------------------------- /Pods/Pods.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" "${PODS_ROOT}/Headers/BDBOAuth1Manager" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers" -isystem "${PODS_ROOT}/Headers/AFNetworking" -isystem "${PODS_ROOT}/Headers/BDBOAuth1Manager" 4 | OTHER_LDFLAGS = -ObjC -framework CoreGraphics -framework MobileCoreServices -framework Security -framework SystemConfiguration 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/ziyang0621.xcuserdatad/xcschemes/Pods-AFNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/ziyang0621.xcuserdatad/xcschemes/Pods-BDBOAuth1Manager.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/ziyang0621.xcuserdatad/xcschemes/Pods.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/ziyang0621.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-AFNetworking.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods-BDBOAuth1Manager.xcscheme 13 | 14 | isShown 15 | 16 | 17 | Pods.xcscheme 18 | 19 | isShown 20 | 21 | 22 | 23 | SuppressBuildableAutocreation 24 | 25 | 52D67C2AA7ED4BEC903D72AD 26 | 27 | primary 28 | 29 | 30 | CBA2026A01DA49E2A9E722C9 31 | 32 | primary 33 | 34 | 35 | CCA7C63CE5F34BD3AEE24DB4 36 | 37 | primary 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Twitter-Swift 2 | ============= 3 | # Twitter Demo 4 | 5 | This is an iOS Swift demo application for displaying the Twitter home line and new tweet composition using the [Twitter API](https://dev.twitter.com/overview/documentation). 6 | 7 | Time spent: 12 hours spent in total 8 | 9 | Completed user stories: 10 | 11 | * [x] Required: Dragging anywhere in the view should reveal the menu. 12 | * [x] Required: The menu should include links to your profile, the home timeline, and the mentions view. 13 | * [x] Required: The menu can look similar to the LinkedIn menu below or feel free to take liberty with the UI 14 | * [x] Required: Contains the user header view 15 | * [x] Required: Contains a section with the users basic stats: # tweets, # following, # followers 16 | * [x] Required: Tapping on a user image should bring up that user's profile page 17 | * [x] Optional: Pulling down the profile page should blur and resize the header image. 18 | 19 | ![Video Walkthrough](twitter-sidemenu.gif) 20 | 21 | GIF created with [LiceCap](http://www.cockos.com/licecap/). 22 | 23 | -------------------------------------------------------------------------------- /Twitter.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Twitter.xcodeproj/xcuserdata/ziyang0621.xcuserdatad/xcschemes/Twitter.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /Twitter.xcodeproj/xcuserdata/ziyang0621.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Twitter.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 859C0EB419E324D60084F76F 16 | 17 | primary 18 | 19 | 20 | 859C0EC919E324D60084F76F 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Twitter.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Twitter.xcworkspace/xcshareddata/Twitter.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 2926A19D-3F37-4B45-94C9-5CD591727755 9 | IDESourceControlProjectName 10 | Twitter 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | C4816947464B1D951480393CD070C2C867D6433B 14 | github.com:ziyang0621/Twitter-Swift.git 15 | 16 | IDESourceControlProjectPath 17 | Twitter.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | C4816947464B1D951480393CD070C2C867D6433B 21 | .. 22 | 23 | IDESourceControlProjectURL 24 | github.com:ziyang0621/Twitter-Swift.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | C4816947464B1D951480393CD070C2C867D6433B 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | C4816947464B1D951480393CD070C2C867D6433B 36 | IDESourceControlWCCName 37 | Twitter 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Twitter/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/6/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let kThemeColor = UIColor.colorWithRGBHex(0x34AADC, alpha: 1.0) 12 | 13 | @UIApplicationMain 14 | class AppDelegate: UIResponder, UIApplicationDelegate { 15 | 16 | var window: UIWindow? 17 | 18 | var storyboard = UIStoryboard(name: "Main", bundle: nil) 19 | 20 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 21 | // Override point for customization after application launch. 22 | 23 | application.statusBarStyle = .LightContent 24 | 25 | let titleDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()] 26 | UINavigationBar.appearance().titleTextAttributes = titleDict 27 | 28 | UINavigationBar.appearance().tintColor = UIColor.whiteColor() 29 | UINavigationBar.appearance().setBackgroundImage(UIColor.imageWithColor(kThemeColor), forBarMetrics: UIBarMetrics.Default) 30 | UINavigationBar.appearance().shadowImage = UIColor.imageWithColor(kThemeColor) 31 | UINavigationBar.appearance().translucent = true 32 | 33 | NSNotificationCenter.defaultCenter().addObserver(self, selector: "userDidLogout", name: userDidLogoutNotificaiton, object: nil) 34 | 35 | if User.currentUser != nil { 36 | // Go to the logged in screen 37 | println("Current user detected: \(User.currentUser?.name)") 38 | let containerViewController = ContainerViewController() 39 | var homeNav = storyboard.instantiateViewControllerWithIdentifier("homeNav") as UINavigationController 40 | homeNav.viewControllers[0] = containerViewController 41 | homeNav.setNavigationBarHidden(true, animated: false) 42 | 43 | window?.rootViewController = homeNav 44 | } 45 | return true 46 | } 47 | 48 | func userDidLogout() { 49 | var vc = storyboard.instantiateInitialViewController() as UIViewController 50 | window?.rootViewController = vc 51 | } 52 | 53 | func applicationWillResignActive(application: UIApplication) { 54 | // 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. 55 | // 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. 56 | } 57 | 58 | func applicationDidEnterBackground(application: UIApplication) { 59 | // 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. 60 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 61 | } 62 | 63 | func applicationWillEnterForeground(application: UIApplication) { 64 | // 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. 65 | } 66 | 67 | func applicationDidBecomeActive(application: UIApplication) { 68 | // 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. 69 | } 70 | 71 | func applicationWillTerminate(application: UIApplication) { 72 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 73 | } 74 | 75 | func application(application: UIApplication, openURL url: NSURL, sourceApplication: String, annotation: AnyObject?) -> Bool { 76 | TwitterClient.sharedInstance.openURL(url) 77 | 78 | return true 79 | } 80 | 81 | } 82 | 83 | -------------------------------------------------------------------------------- /Twitter/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Twitter/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Twitter/Images.xcassets/favorite.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "favorite.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Twitter/Images.xcassets/favorite.imageset/favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziyang0621/Twitter-SideMenu-Swift/62cacba93e84a36708f13714584a48ebbcd1759f/Twitter/Images.xcassets/favorite.imageset/favorite.png -------------------------------------------------------------------------------- /Twitter/Images.xcassets/reply.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "reply.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Twitter/Images.xcassets/reply.imageset/reply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziyang0621/Twitter-SideMenu-Swift/62cacba93e84a36708f13714584a48ebbcd1759f/Twitter/Images.xcassets/reply.imageset/reply.png -------------------------------------------------------------------------------- /Twitter/Images.xcassets/retweet.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "retweet.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Twitter/Images.xcassets/retweet.imageset/retweet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziyang0621/Twitter-SideMenu-Swift/62cacba93e84a36708f13714584a48ebbcd1759f/Twitter/Images.xcassets/retweet.imageset/retweet.png -------------------------------------------------------------------------------- /Twitter/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIViewControllerBasedStatusBarAppearance 6 | 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | com.ziyang.$(PRODUCT_NAME:rfc1034identifier) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleURLTypes 24 | 25 | 26 | CFBundleTypeRole 27 | Editor 28 | CFBundleURLName 29 | com.ziyang.Twitter 30 | CFBundleURLSchemes 31 | 32 | cptwitterdemo 33 | 34 | 35 | 36 | CFBundleVersion 37 | 1 38 | LSRequiresIPhoneOS 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIMainStoryboardFile 43 | Main 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UISupportedInterfaceOrientations~ipad 55 | 56 | UIInterfaceOrientationPortrait 57 | UIInterfaceOrientationPortraitUpsideDown 58 | UIInterfaceOrientationLandscapeLeft 59 | UIInterfaceOrientationLandscapeRight 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Twitter/MentionViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MentionViewController.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/16/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc 12 | protocol MentionViewControllerDelegate { 13 | optional func toggleLeftPanel() 14 | } 15 | 16 | class MentionViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { 17 | 18 | var tweets: [Tweet]? 19 | 20 | var delegate: MentionViewControllerDelegate? 21 | 22 | @IBOutlet weak var tableView: UITableView! 23 | 24 | var refreshControl = UIRefreshControl() 25 | 26 | let formatter = NSDateFormatter() 27 | 28 | override func viewDidLoad() { 29 | super.viewDidLoad() 30 | 31 | self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Menu", style: UIBarButtonItemStyle.Plain, target: self, action: "onMenu") 32 | self.navigationItem.title = "Mention" 33 | 34 | tableView.delegate = self 35 | tableView.dataSource = self 36 | tableView.estimatedRowHeight = 125.0 37 | tableView.rowHeight = UITableViewAutomaticDimension 38 | tableView.registerNib(UINib(nibName: "TweetCell", bundle: nil), forCellReuseIdentifier: "tweetCell") 39 | 40 | formatter.dateFormat = "MM/dd/yy" 41 | 42 | refreshControl.addTarget(self, action: "refreshMentions", forControlEvents: UIControlEvents.ValueChanged) 43 | tableView.addSubview(refreshControl) 44 | 45 | refreshMentions() 46 | } 47 | 48 | func refreshMentions() { 49 | TwitterClient.sharedInstance.mentionTimeLineWithCompletionWithParams(nil, completion: { (tweets, error) -> () in 50 | self.tweets = tweets 51 | println(self.tweets?.count) 52 | self.tableView.reloadData() 53 | self.refreshControl.endRefreshing() 54 | }) 55 | } 56 | 57 | override func didReceiveMemoryWarning() { 58 | super.didReceiveMemoryWarning() 59 | // Dispose of any resources that can be recreated. 60 | } 61 | 62 | func onMenu() { 63 | if let d = delegate { 64 | d.toggleLeftPanel?() 65 | } 66 | } 67 | 68 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 69 | return tweets?.count ?? 0 70 | } 71 | 72 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 73 | var cell = tableView.dequeueReusableCellWithIdentifier("tweetCell") as TweetCell 74 | 75 | var tweet = self.tweets?[indexPath.row] 76 | var user = tweet?.user 77 | cell.nameLabel.text = user?.name 78 | if let screenName = user?.screenname { 79 | cell.screenLabel.text = "@\(screenName)" 80 | } else { 81 | cell.screenLabel.text = "" 82 | } 83 | var date = tweet?.createdAt 84 | cell.timeLabel.text = formatter.stringFromDate(date!) 85 | cell.tweetTextLabel.text = tweet?.text 86 | if let profileImageUrl = tweet?.user?.profileImageUrl { 87 | cell.profileImageView.setImageWithURL(NSURL(string: profileImageUrl)) 88 | } 89 | 90 | return cell 91 | } 92 | 93 | /* 94 | // MARK: - Navigation 95 | 96 | // In a storyboard-based application, you will often want to do a little preparation before navigation 97 | override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { 98 | // Get the new view controller using segue.destinationViewController. 99 | // Pass the selected object to the new view controller. 100 | } 101 | */ 102 | 103 | } 104 | -------------------------------------------------------------------------------- /Twitter/MenuCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MenuCell.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/15/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MenuCell: UITableViewCell { 12 | 13 | @IBOutlet weak var sectionName: UILabel! 14 | 15 | override func awakeFromNib() { 16 | super.awakeFromNib() 17 | sectionName.textColor = kThemeColor 18 | } 19 | 20 | override func setSelected(selected: Bool, animated: Bool) { 21 | super.setSelected(selected, animated: animated) 22 | 23 | // Configure the view for the selected state 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Twitter/NewTweetViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NewTweetViewController.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/8/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol NewTweetViewControllerDelegate { 12 | func sentNewTweet(controller:NewTweetViewController) 13 | } 14 | 15 | class NewTweetViewController: UIViewController,UINavigationBarDelegate { 16 | 17 | @IBOutlet weak var profileImageView: UIImageView! 18 | 19 | @IBOutlet weak var nameLabel: UILabel! 20 | 21 | @IBOutlet weak var screennameLabel: UILabel! 22 | 23 | @IBOutlet weak var statusTextView: UITextView! 24 | 25 | var delegate :NewTweetViewControllerDelegate! 26 | 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | 30 | self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.Plain, target: self, action: "cancelTweet") 31 | self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Tweet", style: UIBarButtonItemStyle.Plain, target: self, action: "sendTweet") 32 | 33 | nameLabel.text = User.currentUser?.name 34 | screennameLabel.text = User.currentUser?.screenname 35 | if let imageURL = User.currentUser?.profileImageUrl { 36 | profileImageView.setImageWithURL(NSURL(string: imageURL)) 37 | } 38 | 39 | statusTextView.becomeFirstResponder() 40 | } 41 | 42 | override func didReceiveMemoryWarning() { 43 | super.didReceiveMemoryWarning() 44 | // Dispose of any resources that can be recreated. 45 | } 46 | 47 | func positionForBar(bar: UIBarPositioning) -> UIBarPosition { 48 | return UIBarPosition.TopAttached 49 | } 50 | 51 | func cancelTweet() { 52 | dismissViewControllerAnimated(true, completion: nil) 53 | } 54 | 55 | func sendTweet() { 56 | var param = ["status" : statusTextView.text] 57 | TwitterClient.sharedInstance.composeCompletionWithParams(param, completion: { (tweets, error) -> () in 58 | if error != nil { 59 | println(error) 60 | } 61 | else { 62 | println("success") 63 | self.delegate.sentNewTweet(self) 64 | self.dismissViewControllerAnimated(true, completion: nil) 65 | } 66 | }) 67 | } 68 | 69 | 70 | /* 71 | // MARK: - Navigation 72 | 73 | // In a storyboard-based application, you will often want to do a little preparation before navigation 74 | override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { 75 | // Get the new view controller using segue.destinationViewController. 76 | // Pass the selected object to the new view controller. 77 | } 78 | */ 79 | 80 | } 81 | -------------------------------------------------------------------------------- /Twitter/ProfileViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ProfileViewController.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/15/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc 12 | protocol ProfileViewControllerDelegate { 13 | optional func toggleLeftPanel() 14 | } 15 | 16 | let kHeaderHeight:CGFloat = 200 17 | let kNavigatonBarPlusStatusBarHeight:CGFloat = 64 18 | 19 | class ProfileViewController: UIViewController, UIGestureRecognizerDelegate, UITableViewDelegate, UITableViewDataSource{ 20 | 21 | var userName: String = "" 22 | 23 | var userInfo: User? 24 | 25 | var delegate: ProfileViewControllerDelegate? 26 | 27 | var tweets: [Tweet]? 28 | 29 | var fromMenu = true 30 | 31 | let formatter = NSDateFormatter() 32 | 33 | @IBOutlet weak var tableView: UITableView! 34 | 35 | @IBOutlet weak var bannerImageView: UIImageView! 36 | 37 | @IBOutlet weak var profileImageView: UIImageView! 38 | 39 | @IBOutlet weak var nameLabel: UILabel! 40 | 41 | @IBOutlet weak var screenNameLabel: UILabel! 42 | 43 | @IBOutlet weak var tweetCountLabel: UILabel! 44 | 45 | @IBOutlet weak var followingCountLabel: UILabel! 46 | 47 | @IBOutlet weak var followerCountLabel: UILabel! 48 | 49 | @IBOutlet weak var headerView: UIView! 50 | 51 | var effectView: UIVisualEffectView! 52 | 53 | var viewDidAppear = false 54 | 55 | override func viewDidLoad() { 56 | super.viewDidLoad() 57 | 58 | if fromMenu { 59 | self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Menu", style: UIBarButtonItemStyle.Plain, target: self, action: "onMenu") 60 | } else { 61 | self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Close", style: UIBarButtonItemStyle.Plain, target: self, action: "onClose") 62 | } 63 | 64 | self.navigationItem.title = "Profile" 65 | 66 | formatter.dateFormat = "MM/dd/yy" 67 | 68 | tableView.delegate = self 69 | tableView.dataSource = self 70 | tableView.registerNib(UINib(nibName: "TweetCell", bundle: nil), forCellReuseIdentifier: "tweetCell") 71 | 72 | var effect = UIBlurEffect(style: .Light) 73 | effectView = UIVisualEffectView(effect: effect) 74 | effectView.alpha = 0 75 | 76 | refreshProfile() 77 | refreshUserInfo() 78 | } 79 | 80 | override func viewDidAppear(animated: Bool) { 81 | effectView.frame = bannerImageView.frame 82 | bannerImageView.addSubview(effectView) 83 | viewDidAppear = true 84 | } 85 | 86 | override func viewDidDisappear(animated: Bool) { 87 | viewDidAppear = false 88 | } 89 | 90 | 91 | func refreshProfile() { 92 | var param = ["screen_name" : userName] 93 | TwitterClient.sharedInstance.showUserCompletionWithParams(param, completion: { (user, error) -> () in 94 | 95 | self.nameLabel.text = user?.name 96 | if let screenName = user?.screenname { 97 | self.screenNameLabel.text = "@\(screenName)" 98 | } 99 | if let profileImageUrl = user?.profileImageUrl { 100 | self.profileImageView.setImageWithURL(NSURL(string: profileImageUrl)) 101 | } 102 | if let bannerImageUrl = user?.profileBannerUrl { 103 | self.bannerImageView.setImageWithURL(NSURL(string: bannerImageUrl)) 104 | } 105 | if let tweetCount = user?.statusesCount { 106 | self.tweetCountLabel.text = "\(tweetCount)" 107 | } 108 | if let followingCount = user?.followingCount { 109 | self.followingCountLabel.text = "\(followingCount)" 110 | } 111 | if let followerCount = user?.followerCount { 112 | self.followerCountLabel.text = "\(followerCount)" 113 | } 114 | }) 115 | } 116 | 117 | func refreshUserInfo() { 118 | var param = ["screen_name" : userName] 119 | TwitterClient.sharedInstance.userTimeLineWithCompletionWithParams(param, completion: { (tweets, error) -> () in 120 | self.tweets = tweets 121 | self.tableView.reloadData() 122 | }) 123 | } 124 | 125 | func scrollViewDidScroll(scrollView: UIScrollView) { 126 | let yPos: CGFloat = -scrollView.contentOffset.y 127 | 128 | if yPos > 0 && viewDidAppear { 129 | var imgRect = effectView.frame 130 | imgRect.origin.y = scrollView.contentOffset.y + kNavigatonBarPlusStatusBarHeight 131 | imgRect.size.height = kHeaderHeight+yPos 132 | effectView.frame = imgRect 133 | effectView.alpha = 1 134 | } 135 | } 136 | 137 | 138 | func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) { 139 | } 140 | 141 | func scrollViewDidEndDecelerating(scrollView: UIScrollView) { 142 | UIView.beginAnimations("fade in", context: nil) 143 | UIView.setAnimationDuration(0.5) 144 | effectView.alpha = 0 145 | UIView.commitAnimations() 146 | } 147 | 148 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 149 | return tweets?.count ?? 0 150 | } 151 | 152 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 153 | var cell = tableView.dequeueReusableCellWithIdentifier("tweetCell") as TweetCell 154 | 155 | var tweet = self.tweets?[indexPath.row] 156 | var user = tweet?.user 157 | cell.nameLabel.text = user?.name 158 | if let screenName = user?.screenname { 159 | cell.screenLabel.text = "@\(screenName)" 160 | } else { 161 | cell.screenLabel.text = "" 162 | } 163 | var date = tweet?.createdAt 164 | cell.timeLabel.text = formatter.stringFromDate(date!) 165 | cell.tweetTextLabel.text = tweet?.text 166 | if let profileImageUrl = tweet?.user?.profileImageUrl { 167 | cell.profileImageView.setImageWithURL(NSURL(string: profileImageUrl)) 168 | } 169 | 170 | return cell 171 | } 172 | 173 | override func didReceiveMemoryWarning() { 174 | super.didReceiveMemoryWarning() 175 | // Dispose of any resources that can be recreated. 176 | } 177 | 178 | func onMenu() { 179 | if let d = delegate { 180 | d.toggleLeftPanel?() 181 | } 182 | } 183 | 184 | func onClose() { 185 | dismissViewControllerAnimated(true, completion: nil) 186 | } 187 | 188 | 189 | /* 190 | // MARK: - Navigation 191 | 192 | // In a storyboard-based application, you will often want to do a little preparation before navigation 193 | override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { 194 | // Get the new view controller using segue.destinationViewController. 195 | // Pass the selected object to the new view controller. 196 | } 197 | */ 198 | 199 | } 200 | -------------------------------------------------------------------------------- /Twitter/SidePaneViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SidePaneViewController.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/15/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol SidePanelViewControllerDelegate { 12 | func menuSelected(index: Int) 13 | } 14 | 15 | class SidePaneViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 16 | 17 | @IBOutlet weak var profileImageView: UIImageView! 18 | 19 | @IBOutlet weak var tableView: UITableView! 20 | var delegate: SidePanelViewControllerDelegate? 21 | 22 | override func viewDidLoad() { 23 | super.viewDidLoad() 24 | 25 | tableView.delegate = self 26 | tableView.dataSource = self 27 | tableView.separatorStyle = .None 28 | 29 | if let profileImageUrl = User.currentUser?.profileImageUrl { 30 | profileImageView.setImageWithURL(NSURL(string: profileImageUrl)) 31 | } 32 | profileImageView.layer.cornerRadius = CGRectGetWidth(profileImageView.frame) / 2; 33 | profileImageView.clipsToBounds = true; 34 | profileImageView.layer.borderWidth = 1.0 35 | profileImageView.layer.borderColor = kThemeColor.CGColor 36 | } 37 | 38 | override func didReceiveMemoryWarning() { 39 | super.didReceiveMemoryWarning() 40 | // Dispose of any resources that can be recreated. 41 | 42 | } 43 | 44 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 45 | return 4 46 | } 47 | 48 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 49 | var cell = tableView.dequeueReusableCellWithIdentifier("menuCell") as MenuCell 50 | if indexPath.row == 0 { 51 | cell.sectionName.text = "Home" 52 | } else if indexPath.row == 1 { 53 | cell.sectionName.text = "Profile" 54 | } else if indexPath.row == 2 { 55 | cell.sectionName.text = "Mention" 56 | } 57 | else { 58 | cell.sectionName.text = "Sign Out" 59 | } 60 | return cell 61 | } 62 | 63 | func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 64 | if indexPath.row == 3 { 65 | User.currentUser?.logout() 66 | } else { 67 | self.delegate?.menuSelected(indexPath.row) 68 | } 69 | } 70 | 71 | 72 | /* 73 | // MARK: - Navigation 74 | 75 | // In a storyboard-based application, you will often want to do a little preparation before navigation 76 | override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { 77 | // Get the new view controller using segue.destinationViewController. 78 | // Pass the selected object to the new view controller. 79 | } 80 | */ 81 | 82 | } 83 | -------------------------------------------------------------------------------- /Twitter/Tweet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Tweet.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/6/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class Tweet: NSObject { 12 | var user: User? 13 | var text: String? 14 | var createdAtString: String? 15 | var createdAt: NSDate? 16 | let formatter = NSDateFormatter() 17 | 18 | init(dictionary: NSDictionary) { 19 | user = User(dictionary: dictionary["user"] as NSDictionary) 20 | text = dictionary["text"] as? String 21 | createdAtString = dictionary["created_at"] as? String 22 | 23 | formatter.dateFormat = "EEE MMM d HH:mm:ss Z y" 24 | createdAt = formatter.dateFromString(createdAtString!) 25 | } 26 | 27 | class func tweetsWithArray(array: [NSDictionary]) -> [Tweet] { 28 | var tweets = [Tweet]() 29 | 30 | for dictionary in array { 31 | tweets.append(Tweet(dictionary: dictionary)) 32 | } 33 | 34 | return tweets 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Twitter/TweetCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TweetCell.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/7/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol TweetCellDelegate { 12 | func cellSelected(screenName: String) 13 | } 14 | 15 | class TweetCell: UITableViewCell, UIGestureRecognizerDelegate { 16 | 17 | @IBOutlet weak var nameLabel: UILabel! 18 | 19 | @IBOutlet weak var screenLabel: UILabel! 20 | 21 | @IBOutlet weak var timeLabel: UILabel! 22 | 23 | @IBOutlet weak var tweetTextLabel: UILabel! 24 | 25 | @IBOutlet weak var profileImageView: UIImageView! 26 | 27 | var delegate: TweetCellDelegate? 28 | 29 | override func awakeFromNib() { 30 | super.awakeFromNib() 31 | // Initialization code 32 | profileImageView.layer.cornerRadius = 4 33 | profileImageView.clipsToBounds = true 34 | let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: "handleLongPressGesture:") 35 | profileImageView.addGestureRecognizer(longPressGestureRecognizer) 36 | } 37 | 38 | func handleLongPressGesture(recognizer: UIPanGestureRecognizer) { 39 | if recognizer.state == .Ended { 40 | println("long press") 41 | delegate?.cellSelected(self.screenLabel.text!) 42 | } 43 | } 44 | 45 | override func setSelected(selected: Bool, animated: Bool) { 46 | super.setSelected(selected, animated: animated) 47 | 48 | // Configure the view for the selected state 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Twitter/TweetsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TweetsViewController.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/6/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let kNewTweetSegue = "newTweetSegue" 12 | 13 | @objc 14 | protocol TweetsViewControllerDelegate { 15 | optional func toggleLeftPanel() 16 | } 17 | 18 | class TweetsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, NewTweetViewControllerDelegate, TweetCellDelegate { 19 | 20 | var tweets: [Tweet]? 21 | 22 | let formatter = NSDateFormatter() 23 | 24 | @IBOutlet weak var tableView: UITableView! 25 | 26 | var refreshControl = UIRefreshControl() 27 | 28 | var delegate: TweetsViewControllerDelegate? 29 | 30 | override func viewDidLoad() { 31 | super.viewDidLoad() 32 | 33 | self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Menu", style: UIBarButtonItemStyle.Plain, target: self, action: "onMenu") 34 | self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "New", style: UIBarButtonItemStyle.Plain, target: self, action: "newTweet") 35 | 36 | tableView.delegate = self 37 | tableView.dataSource = self 38 | 39 | tableView.estimatedRowHeight = 125.0 40 | tableView.rowHeight = UITableViewAutomaticDimension 41 | tableView.registerNib(UINib(nibName: "TweetCell", bundle: nil), forCellReuseIdentifier: "tweetCell") 42 | 43 | formatter.dateFormat = "MM/dd/yy" 44 | 45 | refreshControl.addTarget(self, action: "refreshTweets", forControlEvents: UIControlEvents.ValueChanged) 46 | tableView.addSubview(refreshControl) 47 | 48 | refreshTweets() 49 | } 50 | 51 | func refreshTweets() { 52 | TwitterClient.sharedInstance.homeTimeLineWithCompletionWithParams(nil, completion: { (tweets, error) -> () in 53 | self.tweets = tweets 54 | println(self.tweets?.count) 55 | self.tableView.reloadData() 56 | self.refreshControl.endRefreshing() 57 | }) 58 | } 59 | 60 | override func didReceiveMemoryWarning() { 61 | super.didReceiveMemoryWarning() 62 | // Dispose of any resources that can be recreated. 63 | } 64 | 65 | 66 | func sentNewTweet(controller: NewTweetViewController) { 67 | refreshTweets() 68 | } 69 | 70 | func newTweet() { 71 | performSegueWithIdentifier(kNewTweetSegue, sender: self) 72 | } 73 | 74 | func onMenu() { 75 | if let d = delegate { 76 | d.toggleLeftPanel?() 77 | } 78 | } 79 | 80 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 81 | if (segue.identifier == kNewTweetSegue) { 82 | let detailVC = segue.destinationViewController as UINavigationController 83 | var newTweetVC = detailVC.viewControllers[0] as NewTweetViewController 84 | newTweetVC.delegate = self 85 | } 86 | } 87 | 88 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 89 | return tweets?.count ?? 0 90 | } 91 | 92 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 93 | var cell = tableView.dequeueReusableCellWithIdentifier("tweetCell") as TweetCell 94 | 95 | var tweet = self.tweets?[indexPath.row] 96 | 97 | var user = tweet?.user 98 | cell.nameLabel.text = user?.name 99 | if let screenName = user?.screenname { 100 | cell.screenLabel.text = "@\(screenName)" 101 | } else { 102 | cell.screenLabel.text = "" 103 | } 104 | var date = tweet?.createdAt 105 | cell.timeLabel.text = formatter.stringFromDate(date!) 106 | cell.tweetTextLabel.text = tweet?.text 107 | if let profileImageUrl = tweet?.user?.profileImageUrl { 108 | cell.profileImageView.setImageWithURL(NSURL(string: profileImageUrl)) 109 | } 110 | 111 | cell.delegate = self 112 | 113 | return cell 114 | } 115 | 116 | func cellSelected(screenName: String) { 117 | let storyBoard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) 118 | let profileVC = storyBoard.instantiateViewControllerWithIdentifier("ProfileViewController") as ProfileViewController 119 | profileVC.userName = screenName 120 | profileVC.fromMenu = false 121 | let homeNav = UINavigationController(rootViewController: profileVC) 122 | presentViewController(homeNav, animated: false, completion: nil) 123 | } 124 | 125 | /* 126 | // MARK: - Navigation 127 | 128 | // In a storyboard-based application, you will often want to do a little preparation before navigation 129 | override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { 130 | // Get the new view controller using segue.destinationViewController. 131 | // Pass the selected object to the new view controller. 132 | } 133 | */ 134 | 135 | } 136 | -------------------------------------------------------------------------------- /Twitter/Twitter-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "BDBOAuth1RequestOperationManager.h" 6 | #import "UIImageView+AFNetworking.h" -------------------------------------------------------------------------------- /Twitter/TwitterClient.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TwitterClient.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/6/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let twitterConsumerKey = "QJxHwChx3tnwMeIrO9WdyuQWn" 12 | let twitterConsumerSecret = "mYhpVksXy80vPihwvncMWTY8FavyAohqA5O8YlSZflwmWXBH9i" 13 | let twitterBaseURL = NSURL(string: "https://api.twitter.com") 14 | 15 | class TwitterClient: BDBOAuth1RequestOperationManager { 16 | 17 | var loginCompletion: ((user: User?, error: NSError?) -> ())? 18 | 19 | class var sharedInstance: TwitterClient { 20 | struct Static { 21 | static let instance = TwitterClient(baseURL: twitterBaseURL, consumerKey: twitterConsumerKey, consumerSecret: twitterConsumerSecret) 22 | 23 | } 24 | return Static.instance 25 | } 26 | 27 | func homeTimeLineWithCompletionWithParams(params: NSDictionary?, completion: (tweets: [Tweet]?, error: NSError?) ->()) { 28 | GET("1.1/statuses/home_timeline.json", parameters: params, success: { (operation: AFHTTPRequestOperation!, response: AnyObject!) -> Void in 29 | println("home line: \(response[0])") 30 | 31 | var tweets = Tweet.tweetsWithArray(response as [NSDictionary]) 32 | 33 | //// for tweet in tweets { 34 | //// println("text: \(tweet.text), created: \(tweet.createdAt)") 35 | //// } 36 | completion(tweets: tweets, error: nil) 37 | }, failure: { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in 38 | println("error getting home timeline") 39 | completion(tweets: nil, error: error) 40 | }) 41 | } 42 | 43 | func userTimeLineWithCompletionWithParams(params: NSDictionary?, completion: (tweets: [Tweet]?, error: NSError?) ->()) { 44 | GET("1.1/statuses/user_timeline.json", parameters: params, success: { (operation: AFHTTPRequestOperation!, response: AnyObject!) -> Void in 45 | println("user time line: \(response[0])") 46 | 47 | var tweets = Tweet.tweetsWithArray(response as [NSDictionary]) 48 | 49 | completion(tweets: tweets, error: nil) 50 | }, failure: { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in 51 | println("error getting user timeline") 52 | completion(tweets: nil, error: error) 53 | }) 54 | } 55 | 56 | func mentionTimeLineWithCompletionWithParams(params: NSDictionary?, completion: (tweets: [Tweet]?, error: NSError?) ->()) { 57 | GET("1.1/statuses/mentions_timeline.json", parameters: params, success: { (operation: AFHTTPRequestOperation!, response: AnyObject!) -> Void in 58 | println("mention line: \(response[0])") 59 | 60 | var tweets = Tweet.tweetsWithArray(response as [NSDictionary]) 61 | 62 | completion(tweets: tweets, error: nil) 63 | }, failure: { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in 64 | println("error getting mention timeline") 65 | completion(tweets: nil, error: error) 66 | }) 67 | } 68 | 69 | func composeCompletionWithParams(params: NSDictionary?, completion: (tweets: [Tweet]?, error: NSError?) ->()) { 70 | POST("1.1/statuses/update.json", parameters: params, success: { (operation: AFHTTPRequestOperation!, response: AnyObject!) -> Void in 71 | println("new tweet: \(response)") 72 | 73 | completion(tweets: nil, error: nil) 74 | }, failure: { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in 75 | println("error composing new tweet") 76 | completion(tweets: nil, error: error) 77 | }) 78 | } 79 | 80 | 81 | func showUserCompletionWithParams(params: NSDictionary?, completion: (user: User?, error: NSError?) ->()) { 82 | GET("1.1/users/show.json", parameters: params, success: { (operation: AFHTTPRequestOperation!, response: AnyObject!) -> Void in 83 | println("show user tweet: \(response)") 84 | 85 | var returnUser = User(dictionary: response as NSDictionary) 86 | 87 | completion(user: returnUser, error: nil) 88 | }, failure: { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in 89 | println("error show user tweet") 90 | completion(user: nil, error: error) 91 | }) 92 | } 93 | 94 | 95 | func loginWithCompletion(completion: (user: User?, error: NSError?) -> ()) { 96 | loginCompletion = completion 97 | 98 | // Fetch request token & redirect to authorization page 99 | TwitterClient.sharedInstance.requestSerializer.removeAccessToken() 100 | TwitterClient.sharedInstance.fetchRequestTokenWithPath("oauth/request_token", method: "GET", callbackURL: NSURL(string: "cptwitterdemo://oauth"), scope: nil, success: {(requestToken: BDBOAuthToken!) -> Void in 101 | println("Got the request token") 102 | var authURL = NSURL(string:"https://api.twitter.com/oauth/authorize?oauth_token=\(requestToken.token)") 103 | UIApplication.sharedApplication().openURL(authURL) 104 | }) {(error: NSError!) -> Void in 105 | println("Failed to request token") 106 | self.loginCompletion?(user: nil, error: error) 107 | } 108 | 109 | } 110 | 111 | func openURL(url: NSURL) { 112 | 113 | TwitterClient.sharedInstance.fetchAccessTokenWithPath("oauth/access_token", method: "POST", requestToken: BDBOAuthToken(queryString: url.query), success: {(accessToken: BDBOAuthToken!) -> Void in 114 | print("Got the access token!") 115 | TwitterClient.sharedInstance.requestSerializer.saveAccessToken(accessToken) 116 | 117 | TwitterClient.sharedInstance.GET("1.1/account/verify_credentials.json", parameters: nil, success: {(operation:AFHTTPRequestOperation!, response: AnyObject!) -> Void in 118 | // println("user: \(response)") 119 | 120 | var user = User(dictionary: response as NSDictionary) 121 | User.currentUser = user 122 | 123 | // println("follower count: \(user.followingCount)") 124 | self.loginCompletion?(user: user, error: nil) 125 | }, failure: {(operation: AFHTTPRequestOperation!, error: NSError!) -> Void in 126 | println("error getting current user") 127 | self.loginCompletion?(user: nil, error: error) 128 | }) 129 | 130 | 131 | }) {(error: NSError!) -> Void in 132 | println("Fail to receive access token") 133 | self.loginCompletion?(user: nil, error: error) 134 | } 135 | 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /Twitter/TwitterExtensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TwitterExtensions.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/7/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension UIColor { 12 | class func imageWithColor(color :UIColor) -> UIImage { 13 | var rect = CGRectMake(0, 0, 1, 1) 14 | UIGraphicsBeginImageContextWithOptions(rect.size, false, 0) 15 | color.setFill() 16 | UIRectFill(rect) 17 | var image = UIGraphicsGetImageFromCurrentImageContext() 18 | UIGraphicsEndImageContext() 19 | return image 20 | } 21 | 22 | class func colorWithRGBHex(hex: Int, alpha: Float = 1.0) -> UIColor { 23 | let r = Float((hex >> 16) & 0xFF) 24 | let g = Float((hex >> 8) & 0xFF) 25 | let b = Float((hex) & 0xFF) 26 | 27 | return UIColor(red: CGFloat(r / 255.0), green: CGFloat(g / 255.0), blue:CGFloat(b / 255.0), alpha: CGFloat(alpha)) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Twitter/User.swift: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // User.swift 4 | // Twitter 5 | // 6 | // Created by Ziyang Tan on 10/6/14. 7 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 8 | // 9 | 10 | import UIKit 11 | 12 | var _currentUser: User? 13 | let currentUserKey = "kCurrentUserKey" 14 | let userDidLoginNotification = "userDidLoginNotification" 15 | let userDidLogoutNotificaiton = "userDidLogoutNotification" 16 | 17 | class User: NSObject { 18 | var name: String? 19 | var screenname: String? 20 | var profileImageUrl: String? 21 | var tagline: String? 22 | var dictionary: NSDictionary 23 | var followerCount: Int? 24 | var followingCount: Int? 25 | var statusesCount: Int? 26 | var profileBannerUrl: String? 27 | 28 | init(dictionary: NSDictionary) { 29 | self.dictionary = dictionary 30 | name = dictionary["name"] as? String 31 | screenname = dictionary["screen_name"] as? String 32 | profileImageUrl = dictionary["profile_image_url"] as? String 33 | tagline = dictionary["descrption"] as? String 34 | followerCount = dictionary["followers_count"] as? Int 35 | followingCount = dictionary["friends_count"] as? Int 36 | statusesCount = dictionary["statuses_count"] as? Int 37 | profileBannerUrl = dictionary["profile_banner_url"] as? String 38 | } 39 | 40 | func logout() { 41 | User.currentUser = nil 42 | TwitterClient.sharedInstance.requestSerializer.removeAccessToken() 43 | 44 | NSNotificationCenter.defaultCenter().postNotificationName(userDidLogoutNotificaiton, object: nil) 45 | } 46 | 47 | class var currentUser: User? { 48 | get { 49 | if _currentUser == nil { 50 | var data = NSUserDefaults.standardUserDefaults().objectForKey(currentUserKey) as? NSData 51 | if data != nil { 52 | var dictionary = NSJSONSerialization.JSONObjectWithData(data!, options: nil, error: nil) as NSDictionary 53 | _currentUser = User(dictionary: dictionary) 54 | } 55 | } 56 | return _currentUser 57 | } 58 | set(user) { 59 | _currentUser = user 60 | 61 | if _currentUser != nil { 62 | var data = NSJSONSerialization.dataWithJSONObject(user!.dictionary, options: nil, error: nil) 63 | NSUserDefaults.standardUserDefaults().setObject(data, forKey: currentUserKey) 64 | } else { 65 | NSUserDefaults.standardUserDefaults().setObject(nil, forKey: currentUserKey) 66 | } 67 | NSUserDefaults.standardUserDefaults().synchronize() 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Twitter/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Twitter 4 | // 5 | // Created by Ziyang Tan on 10/6/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let kLoginSegue = "loginSegue" 12 | 13 | class ViewController: UIViewController { 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | // Do any additional setup after loading the view, typically from a nib. 18 | 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | 26 | 27 | @IBAction func onLogin(sender: AnyObject) { 28 | TwitterClient.sharedInstance.loginWithCompletion() { 29 | (user: User?, error: NSError?) in 30 | if user != nil { 31 | // perform segue 32 | self.performSegueWithIdentifier(kLoginSegue, sender: self) 33 | } else { 34 | //handle login error 35 | } 36 | } 37 | 38 | } 39 | 40 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 41 | if (segue.identifier == kLoginSegue) { 42 | let homeNav = segue.destinationViewController as UINavigationController 43 | let containerViewController = ContainerViewController() 44 | homeNav.viewControllers[0] = containerViewController 45 | homeNav.setNavigationBarHidden(true, animated: false) 46 | } 47 | } 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /TwitterTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.ziyang.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /TwitterTests/TwitterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TwitterTests.swift 3 | // TwitterTests 4 | // 5 | // Created by Ziyang Tan on 10/6/14. 6 | // Copyright (c) 2014 Ziyang Tan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class TwitterTests: 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.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = true 5 | ignorecase = true 6 | precomposeunicode = true 7 | -------------------------------------------------------------------------------- /description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /hooks/applypatch-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to check the commit log message taken by 4 | # applypatch from an e-mail message. 5 | # 6 | # The hook should exit with non-zero status after issuing an 7 | # appropriate message if it wants to stop the commit. The hook is 8 | # allowed to edit the commit message file. 9 | # 10 | # To enable this hook, rename this file to "applypatch-msg". 11 | 12 | . git-sh-setup 13 | test -x "$GIT_DIR/hooks/commit-msg" && 14 | exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} 15 | : 16 | -------------------------------------------------------------------------------- /hooks/commit-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to check the commit log message. 4 | # Called by "git commit" with one argument, the name of the file 5 | # that has the commit message. The hook should exit with non-zero 6 | # status after issuing an appropriate message if it wants to stop the 7 | # commit. The hook is allowed to edit the commit message file. 8 | # 9 | # To enable this hook, rename this file to "commit-msg". 10 | 11 | # Uncomment the below to add a Signed-off-by line to the message. 12 | # Doing this in a hook is a bad idea in general, but the prepare-commit-msg 13 | # hook is more suited to it. 14 | # 15 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') 16 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" 17 | 18 | # This example catches duplicate Signed-off-by lines. 19 | 20 | test "" = "$(grep '^Signed-off-by: ' "$1" | 21 | sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { 22 | echo >&2 Duplicate Signed-off-by lines. 23 | exit 1 24 | } 25 | -------------------------------------------------------------------------------- /hooks/post-update.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to prepare a packed repository for use over 4 | # dumb transports. 5 | # 6 | # To enable this hook, rename this file to "post-update". 7 | 8 | exec git update-server-info 9 | -------------------------------------------------------------------------------- /hooks/pre-applypatch.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed 4 | # by applypatch from an e-mail message. 5 | # 6 | # The hook should exit with non-zero status after issuing an 7 | # appropriate message if it wants to stop the commit. 8 | # 9 | # To enable this hook, rename this file to "pre-applypatch". 10 | 11 | . git-sh-setup 12 | test -x "$GIT_DIR/hooks/pre-commit" && 13 | exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} 14 | : 15 | -------------------------------------------------------------------------------- /hooks/pre-commit.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed. 4 | # Called by "git commit" with no arguments. The hook should 5 | # exit with non-zero status after issuing an appropriate message if 6 | # it wants to stop the commit. 7 | # 8 | # To enable this hook, rename this file to "pre-commit". 9 | 10 | if git rev-parse --verify HEAD >/dev/null 2>&1 11 | then 12 | against=HEAD 13 | else 14 | # Initial commit: diff against an empty tree object 15 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 16 | fi 17 | 18 | # If you want to allow non-ASCII filenames set this variable to true. 19 | allownonascii=$(git config --bool hooks.allownonascii) 20 | 21 | # Redirect output to stderr. 22 | exec 1>&2 23 | 24 | # Cross platform projects tend to avoid non-ASCII filenames; prevent 25 | # them from being added to the repository. We exploit the fact that the 26 | # printable range starts at the space character and ends with tilde. 27 | if [ "$allownonascii" != "true" ] && 28 | # Note that the use of brackets around a tr range is ok here, (it's 29 | # even required, for portability to Solaris 10's /usr/bin/tr), since 30 | # the square bracket bytes happen to fall in the designated range. 31 | test $(git diff --cached --name-only --diff-filter=A -z $against | 32 | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 33 | then 34 | cat <<\EOF 35 | Error: Attempt to add a non-ASCII file name. 36 | 37 | This can cause problems if you want to work with people on other platforms. 38 | 39 | To be portable it is advisable to rename the file. 40 | 41 | If you know what you are doing you can disable this check using: 42 | 43 | git config hooks.allownonascii true 44 | EOF 45 | exit 1 46 | fi 47 | 48 | # If there are whitespace errors, print the offending file names and fail. 49 | exec git diff-index --check --cached $against -- 50 | -------------------------------------------------------------------------------- /hooks/pre-push.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # An example hook script to verify what is about to be pushed. Called by "git 4 | # push" after it has checked the remote status, but before anything has been 5 | # pushed. If this script exits with a non-zero status nothing will be pushed. 6 | # 7 | # This hook is called with the following parameters: 8 | # 9 | # $1 -- Name of the remote to which the push is being done 10 | # $2 -- URL to which the push is being done 11 | # 12 | # If pushing without using a named remote those arguments will be equal. 13 | # 14 | # Information about the commits which are being pushed is supplied as lines to 15 | # the standard input in the form: 16 | # 17 | # 18 | # 19 | # This sample shows how to prevent push of commits where the log message starts 20 | # with "WIP" (work in progress). 21 | 22 | remote="$1" 23 | url="$2" 24 | 25 | z40=0000000000000000000000000000000000000000 26 | 27 | IFS=' ' 28 | while read local_ref local_sha remote_ref remote_sha 29 | do 30 | if [ "$local_sha" = $z40 ] 31 | then 32 | # Handle delete 33 | : 34 | else 35 | if [ "$remote_sha" = $z40 ] 36 | then 37 | # New branch, examine all commits 38 | range="$local_sha" 39 | else 40 | # Update to existing branch, examine new commits 41 | range="$remote_sha..$local_sha" 42 | fi 43 | 44 | # Check for WIP commit 45 | commit=`git rev-list -n 1 --grep '^WIP' "$range"` 46 | if [ -n "$commit" ] 47 | then 48 | echo "Found WIP commit in $local_ref, not pushing" 49 | exit 1 50 | fi 51 | fi 52 | done 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /hooks/pre-rebase.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2006, 2008 Junio C Hamano 4 | # 5 | # The "pre-rebase" hook is run just before "git rebase" starts doing 6 | # its job, and can prevent the command from running by exiting with 7 | # non-zero status. 8 | # 9 | # The hook is called with the following parameters: 10 | # 11 | # $1 -- the upstream the series was forked from. 12 | # $2 -- the branch being rebased (or empty when rebasing the current branch). 13 | # 14 | # This sample shows how to prevent topic branches that are already 15 | # merged to 'next' branch from getting rebased, because allowing it 16 | # would result in rebasing already published history. 17 | 18 | publish=next 19 | basebranch="$1" 20 | if test "$#" = 2 21 | then 22 | topic="refs/heads/$2" 23 | else 24 | topic=`git symbolic-ref HEAD` || 25 | exit 0 ;# we do not interrupt rebasing detached HEAD 26 | fi 27 | 28 | case "$topic" in 29 | refs/heads/??/*) 30 | ;; 31 | *) 32 | exit 0 ;# we do not interrupt others. 33 | ;; 34 | esac 35 | 36 | # Now we are dealing with a topic branch being rebased 37 | # on top of master. Is it OK to rebase it? 38 | 39 | # Does the topic really exist? 40 | git show-ref -q "$topic" || { 41 | echo >&2 "No such branch $topic" 42 | exit 1 43 | } 44 | 45 | # Is topic fully merged to master? 46 | not_in_master=`git rev-list --pretty=oneline ^master "$topic"` 47 | if test -z "$not_in_master" 48 | then 49 | echo >&2 "$topic is fully merged to master; better remove it." 50 | exit 1 ;# we could allow it, but there is no point. 51 | fi 52 | 53 | # Is topic ever merged to next? If so you should not be rebasing it. 54 | only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` 55 | only_next_2=`git rev-list ^master ${publish} | sort` 56 | if test "$only_next_1" = "$only_next_2" 57 | then 58 | not_in_topic=`git rev-list "^$topic" master` 59 | if test -z "$not_in_topic" 60 | then 61 | echo >&2 "$topic is already up-to-date with master" 62 | exit 1 ;# we could allow it, but there is no point. 63 | else 64 | exit 0 65 | fi 66 | else 67 | not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` 68 | /usr/bin/perl -e ' 69 | my $topic = $ARGV[0]; 70 | my $msg = "* $topic has commits already merged to public branch:\n"; 71 | my (%not_in_next) = map { 72 | /^([0-9a-f]+) /; 73 | ($1 => 1); 74 | } split(/\n/, $ARGV[1]); 75 | for my $elem (map { 76 | /^([0-9a-f]+) (.*)$/; 77 | [$1 => $2]; 78 | } split(/\n/, $ARGV[2])) { 79 | if (!exists $not_in_next{$elem->[0]}) { 80 | if ($msg) { 81 | print STDERR $msg; 82 | undef $msg; 83 | } 84 | print STDERR " $elem->[1]\n"; 85 | } 86 | } 87 | ' "$topic" "$not_in_next" "$not_in_master" 88 | exit 1 89 | fi 90 | 91 | exit 0 92 | 93 | ################################################################ 94 | 95 | This sample hook safeguards topic branches that have been 96 | published from being rewound. 97 | 98 | The workflow assumed here is: 99 | 100 | * Once a topic branch forks from "master", "master" is never 101 | merged into it again (either directly or indirectly). 102 | 103 | * Once a topic branch is fully cooked and merged into "master", 104 | it is deleted. If you need to build on top of it to correct 105 | earlier mistakes, a new topic branch is created by forking at 106 | the tip of the "master". This is not strictly necessary, but 107 | it makes it easier to keep your history simple. 108 | 109 | * Whenever you need to test or publish your changes to topic 110 | branches, merge them into "next" branch. 111 | 112 | The script, being an example, hardcodes the publish branch name 113 | to be "next", but it is trivial to make it configurable via 114 | $GIT_DIR/config mechanism. 115 | 116 | With this workflow, you would want to know: 117 | 118 | (1) ... if a topic branch has ever been merged to "next". Young 119 | topic branches can have stupid mistakes you would rather 120 | clean up before publishing, and things that have not been 121 | merged into other branches can be easily rebased without 122 | affecting other people. But once it is published, you would 123 | not want to rewind it. 124 | 125 | (2) ... if a topic branch has been fully merged to "master". 126 | Then you can delete it. More importantly, you should not 127 | build on top of it -- other people may already want to 128 | change things related to the topic as patches against your 129 | "master", so if you need further changes, it is better to 130 | fork the topic (perhaps with the same name) afresh from the 131 | tip of "master". 132 | 133 | Let's look at this example: 134 | 135 | o---o---o---o---o---o---o---o---o---o "next" 136 | / / / / 137 | / a---a---b A / / 138 | / / / / 139 | / / c---c---c---c B / 140 | / / / \ / 141 | / / / b---b C \ / 142 | / / / / \ / 143 | ---o---o---o---o---o---o---o---o---o---o---o "master" 144 | 145 | 146 | A, B and C are topic branches. 147 | 148 | * A has one fix since it was merged up to "next". 149 | 150 | * B has finished. It has been fully merged up to "master" and "next", 151 | and is ready to be deleted. 152 | 153 | * C has not merged to "next" at all. 154 | 155 | We would want to allow C to be rebased, refuse A, and encourage 156 | B to be deleted. 157 | 158 | To compute (1): 159 | 160 | git rev-list ^master ^topic next 161 | git rev-list ^master next 162 | 163 | if these match, topic has not merged in next at all. 164 | 165 | To compute (2): 166 | 167 | git rev-list master..topic 168 | 169 | if this is empty, it is fully merged to "master". 170 | -------------------------------------------------------------------------------- /hooks/prepare-commit-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to prepare the commit log message. 4 | # Called by "git commit" with the name of the file that has the 5 | # commit message, followed by the description of the commit 6 | # message's source. The hook's purpose is to edit the commit 7 | # message file. If the hook fails with a non-zero status, 8 | # the commit is aborted. 9 | # 10 | # To enable this hook, rename this file to "prepare-commit-msg". 11 | 12 | # This hook includes three examples. The first comments out the 13 | # "Conflicts:" part of a merge commit. 14 | # 15 | # The second includes the output of "git diff --name-status -r" 16 | # into the message, just before the "git status" output. It is 17 | # commented because it doesn't cope with --amend or with squashed 18 | # commits. 19 | # 20 | # The third example adds a Signed-off-by line to the message, that can 21 | # still be edited. This is rarely a good idea. 22 | 23 | case "$2,$3" in 24 | merge,) 25 | /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; 26 | 27 | # ,|template,) 28 | # /usr/bin/perl -i.bak -pe ' 29 | # print "\n" . `git diff --cached --name-status -r` 30 | # if /^#/ && $first++ == 0' "$1" ;; 31 | 32 | *) ;; 33 | esac 34 | 35 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') 36 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" 37 | -------------------------------------------------------------------------------- /hooks/update.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to blocks unannotated tags from entering. 4 | # Called by "git receive-pack" with arguments: refname sha1-old sha1-new 5 | # 6 | # To enable this hook, rename this file to "update". 7 | # 8 | # Config 9 | # ------ 10 | # hooks.allowunannotated 11 | # This boolean sets whether unannotated tags will be allowed into the 12 | # repository. By default they won't be. 13 | # hooks.allowdeletetag 14 | # This boolean sets whether deleting tags will be allowed in the 15 | # repository. By default they won't be. 16 | # hooks.allowmodifytag 17 | # This boolean sets whether a tag may be modified after creation. By default 18 | # it won't be. 19 | # hooks.allowdeletebranch 20 | # This boolean sets whether deleting branches will be allowed in the 21 | # repository. By default they won't be. 22 | # hooks.denycreatebranch 23 | # This boolean sets whether remotely creating branches will be denied 24 | # in the repository. By default this is allowed. 25 | # 26 | 27 | # --- Command line 28 | refname="$1" 29 | oldrev="$2" 30 | newrev="$3" 31 | 32 | # --- Safety check 33 | if [ -z "$GIT_DIR" ]; then 34 | echo "Don't run this script from the command line." >&2 35 | echo " (if you want, you could supply GIT_DIR then run" >&2 36 | echo " $0 )" >&2 37 | exit 1 38 | fi 39 | 40 | if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then 41 | echo "usage: $0 " >&2 42 | exit 1 43 | fi 44 | 45 | # --- Config 46 | allowunannotated=$(git config --bool hooks.allowunannotated) 47 | allowdeletebranch=$(git config --bool hooks.allowdeletebranch) 48 | denycreatebranch=$(git config --bool hooks.denycreatebranch) 49 | allowdeletetag=$(git config --bool hooks.allowdeletetag) 50 | allowmodifytag=$(git config --bool hooks.allowmodifytag) 51 | 52 | # check for no description 53 | projectdesc=$(sed -e '1q' "$GIT_DIR/description") 54 | case "$projectdesc" in 55 | "Unnamed repository"* | "") 56 | echo "*** Project description file hasn't been set" >&2 57 | exit 1 58 | ;; 59 | esac 60 | 61 | # --- Check types 62 | # if $newrev is 0000...0000, it's a commit to delete a ref. 63 | zero="0000000000000000000000000000000000000000" 64 | if [ "$newrev" = "$zero" ]; then 65 | newrev_type=delete 66 | else 67 | newrev_type=$(git cat-file -t $newrev) 68 | fi 69 | 70 | case "$refname","$newrev_type" in 71 | refs/tags/*,commit) 72 | # un-annotated tag 73 | short_refname=${refname##refs/tags/} 74 | if [ "$allowunannotated" != "true" ]; then 75 | echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 76 | echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 77 | exit 1 78 | fi 79 | ;; 80 | refs/tags/*,delete) 81 | # delete tag 82 | if [ "$allowdeletetag" != "true" ]; then 83 | echo "*** Deleting a tag is not allowed in this repository" >&2 84 | exit 1 85 | fi 86 | ;; 87 | refs/tags/*,tag) 88 | # annotated tag 89 | if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 90 | then 91 | echo "*** Tag '$refname' already exists." >&2 92 | echo "*** Modifying a tag is not allowed in this repository." >&2 93 | exit 1 94 | fi 95 | ;; 96 | refs/heads/*,commit) 97 | # branch 98 | if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then 99 | echo "*** Creating a branch is not allowed in this repository" >&2 100 | exit 1 101 | fi 102 | ;; 103 | refs/heads/*,delete) 104 | # delete branch 105 | if [ "$allowdeletebranch" != "true" ]; then 106 | echo "*** Deleting a branch is not allowed in this repository" >&2 107 | exit 1 108 | fi 109 | ;; 110 | refs/remotes/*,commit) 111 | # tracking branch 112 | ;; 113 | refs/remotes/*,delete) 114 | # delete tracking branch 115 | if [ "$allowdeletebranch" != "true" ]; then 116 | echo "*** Deleting a tracking branch is not allowed in this repository" >&2 117 | exit 1 118 | fi 119 | ;; 120 | *) 121 | # Anything else (is there anything else?) 122 | echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 123 | exit 1 124 | ;; 125 | esac 126 | 127 | # --- Finished 128 | exit 0 129 | -------------------------------------------------------------------------------- /info/exclude: -------------------------------------------------------------------------------- 1 | # git ls-files --others --exclude-from=.git/info/exclude 2 | # Lines that start with '#' are comments. 3 | # For a project mostly in C, the following would be a good set of 4 | # exclude patterns (uncomment them if you want to use them): 5 | # *.[oa] 6 | # *~ 7 | -------------------------------------------------------------------------------- /twitter-sidemenu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziyang0621/Twitter-SideMenu-Swift/62cacba93e84a36708f13714584a48ebbcd1759f/twitter-sidemenu.gif -------------------------------------------------------------------------------- /twitter.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziyang0621/Twitter-SideMenu-Swift/62cacba93e84a36708f13714584a48ebbcd1759f/twitter.gif --------------------------------------------------------------------------------