Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

upgrade to v 1.3.0 of stackmob SDK

  • Loading branch information...
commit e0ae297b60c1432e0ea00f32df94509559230fe3 1 parent 9fcc1cb
Sidney Maestre authored

Showing 54 changed files with 6,180 additions and 117 deletions. Show diff stats Hide diff stats

  1. 136  mashery.activeSearchDemo/StackMob-v1.3.0/CHANGELOG.md
  2. 26  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFHTTPClient+StackMob.h
  3. 574  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFHTTPClient.h
  4. 133  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFHTTPRequestOperation.h
  5. 108  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFImageRequestOperation.h
  6. 66  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFJSONRequestOperation.h
  7. 75  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFNetworkActivityIndicatorManager.h
  8. 44  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFNetworking.h
  9. 68  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFPropertyListRequestOperation.h
  10. 295  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFURLConnectionOperation.h
  11. 89  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFXMLRequestOperation.h
  12. 17  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/Base64EncodedStringFromData.h
  13. 21  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/Common.h
  14. 41  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/KeychainWrapper.h
  15. 33  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/NSArray+Enumerable.h
  16. 48  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/NSDictionary+AtomicCounter.h
  17. 63  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/NSEntityDescription+StackMobSerialization.h
  18. 94  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/NSManagedObject+StackMobSerialization.h
  19. 254  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/NSManagedObjectContext+Concurrency.h
  20. 61  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMBinaryDataConversion.h
  21. 670  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMClient.h
  22. 227  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMCoreDataStore.h
  23. 112  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMCustomCodeRequest.h
  24. 88  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMDataStore+Protected.h
  25. 470  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMDataStore.h
  26. 66  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMError.h
  27. 175  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMGeoPoint.h
  28. 49  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMIncrementalStore+Query.h
  29. 68  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMIncrementalStore.h
  30. 23  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMIncrementalStoreNode.h
  31. 21  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMJSONRequestOperation.h
  32. 90  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMLocationManager.h
  33. 136  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMNetworkReachability.h
  34. 78  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMOAuth1Client.h
  35. 116  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMOAuth2Client.h
  36. 156  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMPredicate.h
  37. 231  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMPushClient.h
  38. 54  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMPushToken.h
  39. 254  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMQuery.h
  40. 154  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMRequestOptions.h
  41. 119  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMResponseBlocks.h
  42. 75  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMUserManagedObject.h
  43. 167  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMUserSession.h
  44. 17  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SMVersion.h
  45. 44  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/StackMob.h
  46. 18  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/StackMobPush.h
  47. 35  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/Synchronization.h
  48. 20  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/SystemInformation.h
  49. 76  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/UIImageView+AFNetworking.h
  50. BIN  mashery.activeSearchDemo/StackMob-v1.3.0/libstackmob-v1.3.0.a
  51. 236  mashery.activeSearchDemo/activeSearchDemo.xcodeproj/project.pbxproj
  52. BIN  ...mo/activeSearchDemo.xcodeproj/project.xcworkspace/xcuserdata/sid.xcuserdatad/UserInterfaceState.xcuserstate
  53. 4  mashery.activeSearchDemo/activeSearchDemo/Activity.xcdatamodeld/Activity.xcdatamodel/contents
  54. 2  mashery.activeSearchDemo/activeSearchDemo/Constants.h
136  mashery.activeSearchDemo/StackMob-v1.3.0/CHANGELOG.md
Source Rendered
... ...
@@ -0,0 +1,136 @@
  1
+<h2>StackMob iOS SDK Change Log</h2>
  2
+
  3
+<h3>v1.3.0 - February 14, 2013</h3>
  4
+
  5
+**Features**
  6
+
  7
+* Support for saving and querying geo points through the Core Data integration.  Be sure to include the `CoreLocation` framework in your project.
  8
+* `SMGeoPoint` class for easily working with geo points through StackMob.
  9
+* `SMLocationManager` class for abstracting out `CLLocationManager` boiler plate code when working with geo data.
  10
+* Save and Fetch methods with `SMRequestOptions` parameter (options) to allow for custom options per Core Data request - See `NSManagedObjectContext+Concurrency.h` for method details.
  11
+* New `globalRequestOptions` property in `SMCoreDataStore` to set default request options used globally during StackMob calls from Core Data.
  12
+* Additional support for building source code with OSX targets (issue #34).
  13
+* Gigya Integration - login methods can be found in `SMClient`.
  14
+
  15
+**Fixes**
  16
+
  17
+* Fix in internal cache fetch method.
  18
+* Predicates with `NSDate` values works properly (issue #30).
  19
+
  20
+
  21
+<h3>v1.2.0 - January 24, 2013</h3>
  22
+
  23
+All the details on the features of this release can be found in <a href="https://blog.stackmob.com/2013/01/ios-sdk-v1-2-0-released/">this blogpost</a>.
  24
+
  25
+**Features**
  26
+
  27
+* Caching system to allow for local fetching of objects which have previously been fetched from the server.  See SMCoreDataStore class reference for how to.
  28
+* Introduce additional methods for interacting with Core Data.  See new methods in SMCoreDataStore and NSManagedObjectContext+Concurrency class references.
  29
+* Update to internal network request algorithms for improved performance of Core Data saves and fetches.
  30
+* All NSDate attributes are saved on StackMob as integers in ms, rather than seconds.  This allows there not be a mismatch in translation when you also have attributes for createddate and lastmoddate.
  31
+* Every Datastore API method (SMDataStore class reference) now has an additional method definition which has parameter options for success and failure callback queues.  This is used a lot internally so callbacks are not run on the main thread, but is exposed so you can do the same.
  32
+
  33
+**Fixes**
  34
+  
  35
+* Fix in updateTwitterStatusWithMessage:onSuccess:onFailure method.
  36
+* Fix in createUserWithFacebookToken:username:onSuccess:onFailure: to properly send request as a POST operation.
  37
+* Fix in encoding query string parameters when logged in to ensure proper request signature.
  38
+
  39
+<h3>v1.1.3 - Nov 20, 2012</h3>
  40
+
  41
+**Features**
  42
+
  43
+* Integrate Push Notifications into core SDK.  Separate Push SDK still exists for those using StackMob only for push notifications.
  44
+* Expose [SMNetworkReachability](http://stackmob.github.com/stackmob-ios-sdk/Classes/SMNetworkReachability.html) interface for developers to manually monitor network status changes.
  45
+* Requests will return SMError with code -105 (SMNetworkNotReachable) when device has no network connection.
  46
+* Now dependent on SystemConfiguration and MobileCoreServices frameworks, make sure to add them to the "Link Binary With Libraries" section of your target's Build Phases as well as import them somewhere in your project (such as your .pch file).
  47
+
  48
+**Fixes**
  49
+
  50
+* Support nil success and failure blocks.
  51
+* Update to Core Data fetch algorithm to populate internal storage with retrieved attribute values.
  52
+* URL encode primary key values on read/update/delete to support special characters.
  53
+* Add expand depth support for queries.
  54
+
  55
+<h3>v1.1.2 - Oct 29, 2012</h3>
  56
+
  57
+**Features**
  58
+
  59
+* Updated SMQuery Geopoint method to take distance in kilometers instead of meters.  New method is _where:isWithin:kilometersOf:_.
  60
+* Add _optionsWithExpandDepth:_ and _optionsWithReturnedFieldsRestrictedTo:_ methods to SMRequestOptions class. 
  61
+* Provide error message when creating an object with null values for fields.  If you receive an error which states that a field was sent with a value of null and the type cannot be inferred, simply go online to the Manage Schemas section of your StackMob Dashboard and manually add the field with correct data type.  This happens occasionally when working with number types in Core Data.
  62
+
  63
+**Fixes**
  64
+
  65
+* Allow setting of Core Data relationships to nil.
  66
+* Add proper SMRequestOptions headers dictionary initialization.   
  67
+* Change default merge policy of SMCoreDataStore _managedObjectContext_ property to NSMergeByPropertyObjectTrumpMergePolicy.  This translates to "client wins" when there are conflicts for particular objects.  Feel free to change the merge policy at any time by calling the _setMergePolicy:_ method on the managed object context of your SMCoreDataStore instance.
  68
+
  69
+<h3>v1.1.1 - Oct 24, 2012</h3>
  70
+
  71
+**Features**
  72
+
  73
+* Full support for Core Data Boolean Data Types.  A Core Data Boolean attribute will map to a Boolean field on StackMob.
  74
+* Removal of 'sm_' prefix for NSManagedObject category helper methods.  Use [managedObject assignObjectId] and [managedObject primaryKeyField].
  75
+* Update SMClient user schema field property names. **userPrimaryKeyField** and **userPasswordField** describe the primary key and password field names for the user schema, respectively.
  76
+
  77
+**Fixes**
  78
+
  79
+* Update fetch request algorithm to support SMUserManagedObject change.
  80
+* Update Core Data object serialization algorithm.  Serialized dictionary sent in request now includes only fields which have been updated since insert or the last call to save.
  81
+* Update SMRequestOptions for proper headers dictionary initialization.
  82
+
  83
+<h3>v1.1.0 - Oct 17, 2012</h3>
  84
+
  85
+**Features**
  86
+
  87
+* Removal of SMModel Protocol.  
  88
+* Addition of SMUserManagedObject. Your managed object subclass corresponding to user objects should inherit from this class.  SMUserManagedObject provides methods to securely set passwords for user objects without storing them in Core Data attributes. For all the information on how to update your current code [see this blogpost](http://blog.stackmob.com/?p=3547).
  89
+* Built for armv7 and armv7s architectures.
  90
+
  91
+<h3>v1.0.1 - Oct 1, 2012</h3>
  92
+
  93
+**Features**
  94
+
  95
+* Can query whether fields are or are not nil. Thanks to combinatorial for the pull request.
  96
+
  97
+**Fixes**
  98
+
  99
+* Address error in serialization algorithm for one-to-one relationship camel cased attributes.
  100
+* Address error in request sent when reading from schemas with permissions set.
  101
+
  102
+<h3>v1.0.0 - Sep 26, 2012</h3>
  103
+
  104
+**Features**
  105
+
  106
+* Support for iOS preferred camelCase Core Data property names.
  107
+* Support non case-sensitive schema names in datastore API.
  108
+* Support Core Data Date attribute type.
  109
+* API version and public key provided to SMClient during initialization must be correct format and non-nil.
  110
+* Core Data integration debug logging available by setting SM\_CORE\_DATA\_DEBUG = YES. See the Debugging section on the main page of the iOS SDK Reference for more info.
  111
+
  112
+**Fixes**
  113
+
  114
+* Edits to dictionary serialization algorithms for improved performance.
  115
+* NewValueForRelationship incremental store method correctly returns empty array for to-many with no objects.
  116
+
  117
+<h3>v1.0.0beta.3 - Aug 24, 2012</h3>
  118
+
  119
+**Fixes** 
  120
+
  121
+* The method save: to the managed object context will return NO if StackMob calls fail.
  122
+* Fetch requests not returning errors.
  123
+
  124
+<h3>v1.0.0beta.2 - Aug 20, 2012</h3>
  125
+
  126
+**Features**
  127
+
  128
+* Performing custom code methods is now available through the `SMCustomCodeRequest` class.
  129
+* Binary Data can be converted into an NSString using the `SMBinaryDataConversion` class and persisted to a StackMob field with Binary Data type.
  130
+
  131
+
  132
+<h3>v1.0.0beta.1 - Aug 10, 2012</h3>
  133
+
  134
+**Features**
  135
+
  136
+* Initial release of new and improved iOS SDK.  Core Data integration serves as the biggest change to the way developers interact with the SDK. See [iOS SDK v1.0 beta](https://www.stackmob.com/devcenter/docs/iOS-SDK-v1.0-beta) for more information.
26  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFHTTPClient+StackMob.h
... ...
@@ -0,0 +1,26 @@
  1
+/*
  2
+ * Copyright 2012-2013 StackMob
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ * http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+#import "AFHTTPClient.h"
  18
+
  19
+@interface AFHTTPClient (StackMob)
  20
+
  21
+- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations
  22
+                       completionBlockQueue:(dispatch_queue_t)queue
  23
+                              progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
  24
+                            completionBlock:(void (^)(NSArray *operations))completionBlock;
  25
+
  26
+@end
574  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFHTTPClient.h
... ...
@@ -0,0 +1,574 @@
  1
+// AFHTTPClient.h
  2
+//
  3
+// Copyright (c) 2011 Gowalla (http://gowalla.com/)
  4
+// 
  5
+// Permission is hereby granted, free of charge, to any person obtaining a copy
  6
+// of this software and associated documentation files (the "Software"), to deal
  7
+// in the Software without restriction, including without limitation the rights
  8
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9
+// copies of the Software, and to permit persons to whom the Software is
  10
+// furnished to do so, subject to the following conditions:
  11
+// 
  12
+// The above copyright notice and this permission notice shall be included in
  13
+// all copies or substantial portions of the Software.
  14
+// 
  15
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21
+// THE SOFTWARE.
  22
+
  23
+#import <Foundation/Foundation.h>
  24
+
  25
+/**
  26
+ `AFHTTPClient` captures the common patterns of communicating with an web application over HTTP. It encapsulates information like base URL, authorization credentials, and HTTP headers, and uses them to construct and manage the execution of HTTP request operations.
  27
+ 
  28
+ ## Automatic Content Parsing
  29
+ 
  30
+ Instances of `AFHTTPClient` may specify which types of requests it expects and should handle by registering HTTP operation classes for automatic parsing. Registered classes will determine whether they can handle a particular request, and then construct a request operation accordingly in `enqueueHTTPRequestOperationWithRequest:success:failure`.
  31
+ 
  32
+ ## Subclassing Notes
  33
+ 
  34
+ In most cases, one should create an `AFHTTPClient` subclass for each website or web application that your application communicates with. It is often useful, also, to define a class method that returns a singleton shared HTTP client in each subclass, that persists authentication credentials and other configuration across the entire application.
  35
+ 
  36
+ ## Methods to Override
  37
+ 
  38
+ To change the behavior of all url request construction for an `AFHTTPClient` subclass, override `requestWithMethod:path:parameters`.
  39
+ 
  40
+ To change the behavior of all request operation construction for an `AFHTTPClient` subclass, override `HTTPRequestOperationWithRequest:success:failure`.
  41
+ 
  42
+ ## Default Headers
  43
+ 
  44
+ By default, `AFHTTPClient` sets the following HTTP headers:
  45
+ 
  46
+ - `Accept-Encoding: gzip`
  47
+ - `Accept-Language: (comma-delimited preferred languages), en-us;q=0.8`
  48
+ - `User-Agent: (generated user agent)`
  49
+ 
  50
+ You can override these HTTP headers or define new ones using `setDefaultHeader:value:`.
  51
+ 
  52
+ ## URL Construction Using Relative Paths
  53
+ 
  54
+ Both `-requestWithMethod:path:parameters:` and `-multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:` construct URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`. Below are a few examples of how `baseURL` and relative paths interact:
  55
+ 
  56
+    NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];  
  57
+    [NSURL URLWithString:@"foo" relativeToURL:baseURL];                  // http://example.com/v1/foo
  58
+    [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL];          // http://example.com/v1/foo?bar=baz
  59
+    [NSURL URLWithString:@"/foo" relativeToURL:baseURL];                 // http://example.com/foo
  60
+    [NSURL URLWithString:@"foo/" relativeToURL:baseURL];                 // http://example.com/v1/foo
  61
+    [NSURL URLWithString:@"/foo/" relativeToURL:baseURL];                // http://example.com/foo/
  62
+    [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
  63
+
  64
+ Also important to note is that a trailing slash will be added to any `baseURL` without one, which would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
  65
+
  66
+ ## NSCoding / NSCopying Conformance
  67
+ 
  68
+ `AFHTTPClient`  conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however:
  69
+ 
  70
+ - Archives and copies of HTTP clients will be initialized with an empty operation queue.
  71
+ - NSCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set.
  72
+ */
  73
+
  74
+#ifdef _SYSTEMCONFIGURATION_H
  75
+typedef enum {
  76
+    AFNetworkReachabilityStatusUnknown          = -1,
  77
+    AFNetworkReachabilityStatusNotReachable     = 0,
  78
+    AFNetworkReachabilityStatusReachableViaWWAN = 1,
  79
+    AFNetworkReachabilityStatusReachableViaWiFi = 2,
  80
+} AFNetworkReachabilityStatus;
  81
+#else
  82
+#warning "SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available."
  83
+#endif
  84
+
  85
+#ifndef __UTTYPE__
  86
+#warning "CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available."
  87
+#endif
  88
+
  89
+typedef enum {
  90
+    AFFormURLParameterEncoding,
  91
+    AFJSONParameterEncoding,
  92
+    AFPropertyListParameterEncoding,
  93
+} AFHTTPClientParameterEncoding;
  94
+
  95
+@class AFHTTPRequestOperation;
  96
+@protocol AFMultipartFormData;
  97
+
  98
+@interface AFHTTPClient : NSObject <NSCoding, NSCopying>
  99
+
  100
+///---------------------------------------
  101
+/// @name Accessing HTTP Client Properties
  102
+///---------------------------------------
  103
+
  104
+/**
  105
+ The url used as the base for paths specified in methods such as `getPath:parameters:success:failure`
  106
+ */
  107
+@property (readonly, nonatomic) NSURL *baseURL;
  108
+
  109
+/**
  110
+ The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default.
  111
+ */
  112
+@property (nonatomic, assign) NSStringEncoding stringEncoding;
  113
+
  114
+/**
  115
+ The `AFHTTPClientParameterEncoding` value corresponding to how parameters are encoded into a request body. This is `AFFormURLParameterEncoding` by default.
  116
+ */
  117
+@property (nonatomic, assign) AFHTTPClientParameterEncoding parameterEncoding;
  118
+
  119
+/**
  120
+ The operation queue which manages operations enqueued by the HTTP client.
  121
+ */
  122
+@property (readonly, nonatomic) NSOperationQueue *operationQueue;
  123
+
  124
+/**
  125
+ The reachability status from the device to the current `baseURL` of the `AFHTTPClient`.
  126
+
  127
+  @warning This property requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
  128
+ */
  129
+#ifdef _SYSTEMCONFIGURATION_H
  130
+@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
  131
+#endif
  132
+
  133
+///---------------------------------------------
  134
+/// @name Creating and Initializing HTTP Clients
  135
+///---------------------------------------------
  136
+
  137
+/**
  138
+ Creates and initializes an `AFHTTPClient` object with the specified base URL.
  139
+ 
  140
+ @param url The base URL for the HTTP client. This argument must not be `nil`.
  141
+  
  142
+ @return The newly-initialized HTTP client
  143
+ */
  144
++ (AFHTTPClient *)clientWithBaseURL:(NSURL *)url;
  145
+
  146
+/**
  147
+ Initializes an `AFHTTPClient` object with the specified base URL.
  148
+ 
  149
+ @param url The base URL for the HTTP client. This argument must not be `nil`.
  150
+ 
  151
+ @discussion This is the designated initializer.
  152
+  
  153
+ @return The newly-initialized HTTP client
  154
+ */
  155
+- (id)initWithBaseURL:(NSURL *)url;
  156
+
  157
+///-----------------------------------
  158
+/// @name Managing Reachability Status
  159
+///-----------------------------------
  160
+
  161
+/**
  162
+ Sets a callback to be executed when the network availability of the `baseURL` host changes.
  163
+ 
  164
+ @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
  165
+ 
  166
+ @warning This method requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
  167
+ */
  168
+#ifdef _SYSTEMCONFIGURATION_H
  169
+- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block;
  170
+#endif
  171
+
  172
+///-------------------------------
  173
+/// @name Managing HTTP Operations
  174
+///-------------------------------
  175
+
  176
+/**
  177
+ Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request.
  178
+ 
  179
+ @param operationClass The subclass of `AFHTTPRequestOperation` to register
  180
+ 
  181
+ @return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`.
  182
+ 
  183
+ @discussion When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list.
  184
+ */
  185
+- (BOOL)registerHTTPOperationClass:(Class)operationClass;
  186
+
  187
+/**
  188
+ Unregisters the specified subclass of `AFHTTPRequestOperation` from the chain of classes consulted when `-requestWithMethod:path:parameters` is called.
  189
+
  190
+ @param operationClass The subclass of `AFHTTPRequestOperation` to register 
  191
+ */
  192
+- (void)unregisterHTTPOperationClass:(Class)operationClass;
  193
+
  194
+///----------------------------------
  195
+/// @name Managing HTTP Header Values
  196
+///----------------------------------
  197
+
  198
+/**
  199
+ Returns the value for the HTTP headers set in request objects created by the HTTP client.
  200
+ 
  201
+ @param header The HTTP header to return the default value for
  202
+ 
  203
+ @return The default value for the HTTP header, or `nil` if unspecified
  204
+ */
  205
+- (NSString *)defaultValueForHeader:(NSString *)header;
  206
+
  207
+/**
  208
+ Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
  209
+ 
  210
+ @param header The HTTP header to set a default value for
  211
+ @param value The value set as default for the specified header, or `nil
  212
+ */
  213
+- (void)setDefaultHeader:(NSString *)header value:(NSString *)value;
  214
+
  215
+/**
  216
+ Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
  217
+ 
  218
+ @param username The HTTP basic auth username
  219
+ @param password The HTTP basic auth password
  220
+ */
  221
+- (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password;
  222
+
  223
+/**
  224
+ Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
  225
+ 
  226
+ @param token The authentication token
  227
+ */
  228
+- (void)setAuthorizationHeaderWithToken:(NSString *)token;
  229
+
  230
+/**
  231
+ Clears any existing value for the "Authorization" HTTP header.
  232
+ */
  233
+- (void)clearAuthorizationHeader;
  234
+
  235
+///-------------------------------
  236
+/// @name Creating Request Objects
  237
+///-------------------------------
  238
+
  239
+/**
  240
+ Creates an `NSMutableURLRequest` object with the specified HTTP method and path.
  241
+ 
  242
+ If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
  243
+ 
  244
+ @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
  245
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL. If `nil`, no path will be appended to the base URL.
  246
+ @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
  247
+  
  248
+ @return An `NSMutableURLRequest` object 
  249
+ */
  250
+- (NSMutableURLRequest *)requestWithMethod:(NSString *)method 
  251
+                                      path:(NSString *)path 
  252
+                                parameters:(NSDictionary *)parameters;
  253
+
  254
+/**
  255
+ Creates an `NSMutableURLRequest` object with the specified HTTP method and path, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
  256
+ 
  257
+ @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
  258
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
  259
+ @param parameters The parameters to be encoded and set in the request HTTP body.
  260
+ @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. This can be used to upload files, encode HTTP body as JSON or XML, or specify multiple values for the same parameter, as one might for array values.
  261
+  
  262
+ @discussion Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
  263
+  
  264
+ @return An `NSMutableURLRequest` object
  265
+ */
  266
+- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
  267
+                                                   path:(NSString *)path
  268
+                                             parameters:(NSDictionary *)parameters
  269
+                              constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block;
  270
+
  271
+///-------------------------------
  272
+/// @name Creating HTTP Operations
  273
+///-------------------------------
  274
+
  275
+/**
  276
+ Creates an `AFHTTPRequestOperation`.
  277
+ 
  278
+ In order to determine what kind of operation is created, each registered subclass conforming to the `AFHTTPClient` protocol is consulted (in reverse order of when they were specified) to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to generate an operation using `HTTPRequestOperationWithRequest:success:failure:`.
  279
+ 
  280
+ @param urlRequest The request object to be loaded asynchronously during execution of the operation.
  281
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
  282
+ @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 two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
  283
+ */
  284
+- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
  285
+                                                    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
  286
+                                                    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
  287
+
  288
+///----------------------------------------
  289
+/// @name Managing Enqueued HTTP Operations
  290
+///----------------------------------------
  291
+
  292
+/**
  293
+ Enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue.
  294
+ 
  295
+ @param operation The HTTP request operation to be enqueued.
  296
+ */
  297
+- (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation;
  298
+
  299
+/**
  300
+ Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path.
  301
+ 
  302
+ @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled. 
  303
+ @param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL.
  304
+ 
  305
+ @discussion This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property.
  306
+ */
  307
+- (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path;
  308
+
  309
+///---------------------------------------
  310
+/// @name Batching HTTP Request Operations
  311
+///---------------------------------------
  312
+
  313
+/**
  314
+ Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
  315
+ 
  316
+ @param urlRequests The `NSURLRequest` objects used to create and enqueue operations.
  317
+ @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
  318
+ @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. 
  319
+ 
  320
+ @discussion Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters.
  321
+ */
  322
+- (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests
  323
+                                          progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock 
  324
+                                        completionBlock:(void (^)(NSArray *operations))completionBlock;
  325
+
  326
+/**
  327
+ Enqueues the specified request operations into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
  328
+ 
  329
+ @param operations The request operations used to be batched and enqueued.
  330
+ @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
  331
+ @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. 
  332
+ */
  333
+- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations 
  334
+                              progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock 
  335
+                            completionBlock:(void (^)(NSArray *operations))completionBlock;
  336
+
  337
+///---------------------------
  338
+/// @name Making HTTP Requests
  339
+///---------------------------
  340
+
  341
+/**
  342
+ Creates an `AFHTTPRequestOperation` with a `GET` request, and enqueues it to the HTTP client's operation queue.
  343
+ 
  344
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
  345
+ @param parameters The parameters to be encoded and appended as the query string for the request URL.
  346
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
  347
+ @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 two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
  348
+ 
  349
+ @see -HTTPRequestOperationWithRequest:success:failure:
  350
+ */
  351
+- (void)getPath:(NSString *)path
  352
+     parameters:(NSDictionary *)parameters
  353
+        success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
  354
+        failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
  355
+
  356
+/**
  357
+ Creates an `AFHTTPRequestOperation` with a `POST` request, and enqueues it to the HTTP client's operation queue.
  358
+ 
  359
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
  360
+ @param parameters The parameters to be encoded and set in the request HTTP body.
  361
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
  362
+ @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 two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
  363
+ 
  364
+ @see -HTTPRequestOperationWithRequest:success:failure:
  365
+ */
  366
+- (void)postPath:(NSString *)path 
  367
+      parameters:(NSDictionary *)parameters 
  368
+         success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
  369
+         failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
  370
+
  371
+/**
  372
+ Creates an `AFHTTPRequestOperation` with a `PUT` request, and enqueues it to the HTTP client's operation queue.
  373
+ 
  374
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
  375
+ @param parameters The parameters to be encoded and set in the request HTTP body.
  376
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
  377
+ @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 two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
  378
+ 
  379
+ @see -HTTPRequestOperationWithRequest:success:failure:
  380
+ */
  381
+- (void)putPath:(NSString *)path 
  382
+     parameters:(NSDictionary *)parameters 
  383
+        success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
  384
+        failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
  385
+
  386
+/**
  387
+ Creates an `AFHTTPRequestOperation` with a `DELETE` request, and enqueues it to the HTTP client's operation queue.
  388
+ 
  389
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
  390
+ @param parameters The parameters to be encoded and appended as the query string for the request URL.
  391
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
  392
+ @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 two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
  393
+ 
  394
+ @see -HTTPRequestOperationWithRequest:success:failure:
  395
+ */
  396
+- (void)deletePath:(NSString *)path 
  397
+        parameters:(NSDictionary *)parameters 
  398
+           success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
  399
+           failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
  400
+
  401
+/**
  402
+ Creates an `AFHTTPRequestOperation` with a `PATCH` request, and enqueues it to the HTTP client's operation queue.
  403
+ 
  404
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
  405
+ @param parameters The parameters to be encoded and set in the request HTTP body.
  406
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
  407
+ @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 two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
  408
+ 
  409
+ @see -HTTPRequestOperationWithRequest:success:failure:
  410
+ */
  411
+- (void)patchPath:(NSString *)path
  412
+       parameters:(NSDictionary *)parameters 
  413
+          success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
  414
+          failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
  415
+@end
  416
+
  417
+///----------------
  418
+/// @name Constants
  419
+///----------------
  420
+
  421
+/**
  422
+ ### Network Reachability
  423
+ 
  424
+ The following constants are provided by `AFHTTPClient` as possible network reachability statuses. 
  425
+ 
  426
+ enum {
  427
+    AFNetworkReachabilityStatusUnknown,
  428
+    AFNetworkReachabilityStatusNotReachable,
  429
+    AFNetworkReachabilityStatusReachableViaWWAN,
  430
+    AFNetworkReachabilityStatusReachableViaWiFi,
  431
+ }
  432
+ 
  433
+ `AFNetworkReachabilityStatusUnknown`  
  434
+    The `baseURL` host reachability is not known.
  435
+ 
  436
+ `AFNetworkReachabilityStatusNotReachable`
  437
+    The `baseURL` host cannot be reached.
  438
+ 
  439
+ `AFNetworkReachabilityStatusReachableViaWWAN`
  440
+    The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
  441
+ 
  442
+ `AFNetworkReachabilityStatusReachableViaWiFi`
  443
+    The `baseURL` host can be reached via a Wi-Fi connection.
  444
+ 
  445
+ ### Keys for Notification UserInfo Dictionary
  446
+ 
  447
+ Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
  448
+ 
  449
+ `AFNetworkingReachabilityNotificationStatusItem`
  450
+    A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.  
  451
+    The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. 
  452
+ 
  453
+ ### Parameter Encoding
  454
+ 
  455
+ The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values.
  456
+
  457
+ enum {
  458
+    AFFormURLParameterEncoding,
  459
+    AFJSONParameterEncoding,
  460
+    AFPropertyListParameterEncoding,
  461
+ }
  462
+ 
  463
+ `AFFormURLParameterEncoding`
  464
+    Parameters are encoded into field/key pairs in the URL query string for `GET` `HEAD` and `DELETE` requests, and in the message body otherwise.
  465
+ 
  466
+ `AFJSONParameterEncoding`
  467
+    Parameters are encoded into JSON in the message body.
  468
+ 
  469
+ `AFPropertyListParameterEncoding`  
  470
+    Parameters are encoded into a property list in the message body.
  471
+ */
  472
+
  473
+///----------------
  474
+/// @name Functions
  475
+///----------------
  476
+
  477
+/**
  478
+ Returns a query string constructed by a set of parameters, using the specified encoding.
  479
+ 
  480
+ @param parameters The parameters used to construct the query string
  481
+ @param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs.
  482
+ 
  483
+ @discussion Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&".
  484
+ 
  485
+ If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component.
  486
+ 
  487
+ @return A percent-escaped query string
  488
+ */
  489
+extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding);
  490
+
  491
+///--------------------
  492
+/// @name Notifications
  493
+///--------------------
  494
+
  495
+/**
  496
+ Posted when network reachability changes.
  497
+ This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
  498
+ 
  499
+ @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
  500
+ */
  501
+#ifdef _SYSTEMCONFIGURATION_H
  502
+extern NSString * const AFNetworkingReachabilityDidChangeNotification;
  503
+extern NSString * const AFNetworkingReachabilityNotificationStatusItem;
  504
+#endif
  505
+
  506
+#pragma mark -
  507
+
  508
+extern NSUInteger const kAFUploadStream3GSuggestedPacketSize;
  509
+extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
  510
+
  511
+/**
  512
+ The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPClient -multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:`.
  513
+ */
  514
+@protocol AFMultipartFormData
  515
+
  516
+/**
  517
+ Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
  518
+ 
  519
+ @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
  520
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
  521
+ @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
  522
+ 
  523
+ @return `YES` if the file data was successfully appended, otherwise `NO`.
  524
+ 
  525
+ @discussion The filename and MIME type for this data in the form will be automatically generated, using `NSURLResponse` `-suggestedFilename` and `-MIMEType`, respectively.
  526
+ */
  527
+- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
  528
+                         name:(NSString *)name
  529
+                        error:(NSError * __autoreleasing *)error;
  530
+
  531
+/**
  532
+ Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
  533
+ 
  534
+ @param data The data to be encoded and appended to the form data.
  535
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
  536
+ @param filename The filename to be associated with the specified data. This parameter must not be `nil`.
  537
+ @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
  538
+ */
  539
+- (void)appendPartWithFileData:(NSData *)data
  540
+                          name:(NSString *)name
  541
+                      fileName:(NSString *)fileName
  542
+                      mimeType:(NSString *)mimeType;
  543
+
  544
+/**
  545
+ Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
  546
+ 
  547
+ @param data The data to be encoded and appended to the form data.
  548
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
  549
+ */
  550
+
  551
+- (void)appendPartWithFormData:(NSData *)data
  552
+                          name:(NSString *)name;
  553
+
  554
+/**
  555
+ Appends HTTP headers, followed by the encoded data and the multipart form boundary.
  556
+ 
  557
+ @param headers The HTTP headers to be appended to the form data.
  558
+ @param body The data to be encoded and appended to the form data.
  559
+ */
  560
+- (void)appendPartWithHeaders:(NSDictionary *)headers
  561
+                         body:(NSData *)body;
  562
+
  563
+/**
  564
+ Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
  565
+ 
  566
+ @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb.
  567
+ @param delay Duration of delay each time a packet is read. By default, no delay is set.
  568
+ 
  569
+ @discussion When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
  570
+ */
  571
+- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
  572
+                                  delay:(NSTimeInterval)delay;
  573
+
  574
+@end
133  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFHTTPRequestOperation.h
... ...
@@ -0,0 +1,133 @@
  1
+// AFHTTPRequestOperation.h
  2
+//
  3
+// Copyright (c) 2011 Gowalla (http://gowalla.com/)
  4
+// 
  5
+// Permission is hereby granted, free of charge, to any person obtaining a copy
  6
+// of this software and associated documentation files (the "Software"), to deal
  7
+// in the Software without restriction, including without limitation the rights
  8
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9
+// copies of the Software, and to permit persons to whom the Software is
  10
+// furnished to do so, subject to the following conditions:
  11
+// 
  12
+// The above copyright notice and this permission notice shall be included in
  13
+// all copies or substantial portions of the Software.
  14
+// 
  15
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21
+// THE SOFTWARE.
  22
+
  23
+#import <Foundation/Foundation.h>
  24
+#import "AFURLConnectionOperation.h"
  25
+
  26
+/**
  27
+ `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.
  28
+ */
  29
+@interface AFHTTPRequestOperation : AFURLConnectionOperation
  30
+
  31
+///----------------------------------------------
  32
+/// @name Getting HTTP URL Connection Information
  33
+///----------------------------------------------
  34
+
  35
+/**
  36
+ The last HTTP response received by the operation's connection.
  37
+ */
  38
+@property (readonly, nonatomic, strong) NSHTTPURLResponse *response;
  39
+
  40
+///----------------------------------------------------------
  41
+/// @name Managing And Checking For Acceptable HTTP Responses
  42
+///----------------------------------------------------------
  43
+
  44
+/**
  45
+ A Boolean value that corresponds to whether the status code of the response is within the specified set of acceptable status codes. Returns `YES` if `acceptableStatusCodes` is `nil`.
  46
+ */
  47
+@property (readonly) BOOL hasAcceptableStatusCode;
  48
+
  49
+/**
  50
+ A Boolean value that corresponds to whether the MIME type of the response is among the specified set of acceptable content types. Returns `YES` if `acceptableContentTypes` is `nil`.
  51
+ */
  52
+@property (readonly) BOOL hasAcceptableContentType;
  53
+
  54
+/** 
  55
+ The callback dispatch queue on success. If `NULL` (default), the main queue is used.
  56
+ */
  57
+@property (nonatomic, assign) dispatch_queue_t successCallbackQueue;
  58
+
  59
+/** 
  60
+ The callback dispatch queue on failure. If `NULL` (default), the main queue is used.
  61
+ */
  62
+@property (nonatomic, assign) dispatch_queue_t failureCallbackQueue;
  63
+
  64
+///------------------------------------------------------------
  65
+/// @name Managing Acceptable HTTP Status Codes & Content Types
  66
+///------------------------------------------------------------
  67
+
  68
+/**
  69
+ Returns an `NSIndexSet` object containing the ranges of acceptable HTTP status codes. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
  70
+ 
  71
+ By default, this is the range 200 to 299, inclusive.
  72
+ */
  73
++ (NSIndexSet *)acceptableStatusCodes;
  74
+
  75
+/**
  76
+ Adds status codes to the set of acceptable HTTP status codes returned by `+acceptableStatusCodes` in subsequent calls by this class and its descendants.
  77
+ 
  78
+ @param statusCodes The status codes to be added to the set of acceptable HTTP status codes
  79
+ */
  80
++ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes;
  81
+
  82
+/**
  83
+ Returns an `NSSet` object containing the acceptable MIME types. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 
  84
+ 
  85
+ By default, this is `nil`.
  86
+ */
  87
++ (NSSet *)acceptableContentTypes;
  88
+
  89
+/**
  90
+ Adds content types to the set of acceptable MIME types returned by `+acceptableContentTypes` in subsequent calls by this class and its descendants.
  91
+
  92
+ @param contentTypes The content types to be added to the set of acceptable MIME types
  93
+ */
  94
++ (void)addAcceptableContentTypes:(NSSet *)contentTypes;
  95
+
  96
+
  97
+///-----------------------------------------------------
  98
+/// @name Determining Whether A Request Can Be Processed
  99
+///-----------------------------------------------------
  100
+
  101
+/**
  102
+ A Boolean value determining whether or not the class can process the specified request. For example, `AFJSONRequestOperation` may check to make sure the content type was `application/json` or the URL path extension was `.json`.
  103
+ 
  104
+ @param urlRequest The request that is determined to be supported or not supported for this class.
  105
+ */
  106
++ (BOOL)canProcessRequest:(NSURLRequest *)urlRequest;
  107
+
  108
+///-----------------------------------------------------------
  109
+/// @name Setting Completion Block Success / Failure Callbacks
  110
+///-----------------------------------------------------------
  111
+
  112
+/**
  113
+ Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed.
  114
+ 
  115
+ @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.
  116
+ @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.
  117
+ 
  118
+ @discussion This method should be overridden in subclasses in order to specify the response object passed into the success block.
  119
+ */
  120
+- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
  121
+                              failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
  122
+
  123
+@end
  124
+
  125
+///----------------
  126
+/// @name Functions
  127
+///----------------
  128
+
  129
+/**
  130
+ Returns a set of MIME types detected in an HTTP `Accept` or `Content-Type` header.
  131
+ */
  132
+extern NSSet * AFContentTypesFromHTTPHeader(NSString *string);
  133
+
108  mashery.activeSearchDemo/StackMob-v1.3.0/Headers/AFImageRequestOperation.h
... ...
@@ -0,0 +1,108 @@
  1
+// AFImageRequestOperation.h
  2
+//
  3
+// Copyright (c) 2011 Gowalla (http://gowalla.com/)
  4
+// 
  5
+// Permission is hereby granted, free of charge, to any person obtaining a copy
  6
+// of this software and associated documentation files (the "Software"), to deal
  7
+// in the Software without restriction, including without limitation the rights
  8
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9
+// copies of the Software, and to permit persons to whom the Software is
  10
+// furnished to do so, subject to the following conditions:
  11
+// 
  12
+// The above copyright notice and this permission notice shall be included in
  13
+// all copies or substantial portions of the Software.
  14
+// 
  15
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21
+// THE SOFTWARE.
  22
+
  23
+#import <Foundation/Foundation.h>
  24
+#import "AFHTTPRequestOperation.h"
  25
+
  26
+#import <Availability.h>
  27
+
  28
+#if __IPHONE_OS_VERSION_MIN_REQUIRED
  29
+#import <UIKit/UIKit.h>
  30
+#elif __MAC_OS_X_VERSION_MIN_REQUIRED 
  31
+#import <Cocoa/Cocoa.h>
  32
+#endif
  33
+
  34
+/**
  35
+ `AFImageRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading an processing images.
  36
+ 
  37
+ ## Acceptable Content Types
  38
+ 
  39
+ By default, `AFImageRequestOperation` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:
  40
+ 
  41
+ - `image/tiff`
  42
+ - `image/jpeg`
  43
+ - `image/gif`
  44
+ - `image/png`
  45
+ - `image/ico`
  46
+ - `image/x-icon`
  47
+ - `image/bmp`
  48
+ - `image/x-bmp`
  49
+ - `image/x-xbitmap`
  50
+ - `image/x-win-bitmap`
  51
+ */
  52
+@interface AFImageRequestOperation : AFHTTPRequestOperation
  53
+
  54
+/**
  55
+ An image constructed from the response data. If an error occurs during the request, `nil` will be returned, and the `error` property will be set to the error.
  56
+ */
  57
+#if __IPHONE_OS_VERSION_MIN_REQUIRED
  58
+@property (readonly, nonatomic, strong) UIImage *responseImage;
  59
+#elif __MAC_OS_X_VERSION_MIN_REQUIRED
  60
+@property (readonly, nonatomic, strong) NSImage *responseImage;
  61
+#endif
  62
+
  63
+#if __IPHONE_OS_VERSION_MIN_REQUIRED
  64
+/**
  65
+ The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance.
  66
+ */
  67
+@property (nonatomic, assign) CGFloat imageScale;
  68
+#endif
  69
+
  70
+/**
  71
+ Creates and returns an `AFImageRequestOperation` object and sets the specified success callback.
  72
+ 
  73
+ @param urlRequest The request object to be loaded asynchronously during execution of the operation.
  74
+ @param success A block object to be executed when the request finishes successfully. This block has no return value and takes a single arguments, the image created from the response data of the request.
  75
+ 
  76
+ @return A new image request operation
  77
+ */
  78
+#if __IPHONE_OS_VERSION_MIN_REQUIRED
  79
++ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest                
  80
+                                                      success:(void (^)(UIImage *image))success;
  81
+#elif __MAC_OS_X_VERSION_MIN_REQUIRED
  82
++ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest                
  83
+                                                      success:(void (^)(NSImage *image))success;
  84
+#endif
  85
+
  86
+/**
  87
+ Creates and returns an `AFImageRequestOperation` object and sets the specified success callback.
  88
+ 
  89
+ @param urlRequest The request object to be loaded asynchronously during execution of the operation.
  90
+ @param imageProcessingBlock A block object to be executed after the image request finishes successfully, but before the image is returned in the `success` block. This block takes a single argument, the image loaded from the response body, and returns the processed image.
  91
+ @param success A block object to be executed when the request finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the image created from the response data.
  92
+ @param failure A block object to be executed when the request finishes unsuccessfully. This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the error associated with the cause for the unsuccessful operation.
  93
+ 
  94
+ @return A new image request operation
  95
+ */
  96
+#if __IPHONE_OS_VERSION_MIN_REQUIRED
  97
++ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
  98
+                                         imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock