NetworkManager(HTTP) Category Reference
| Declared in | NetworkManager+HTTP.h NetworkManager+HTTP.m |
Tasks
HTTP request utility methods
-
– postUploadToURL:parameters:paths:fieldName:completion:Prepare and initiate multipart/form-data request with files
-
– post:parameters:completion:Prepare and initiate application/x-www-form-urlencoded request
-
– mimeTypeForPath:Determine mime type on basis of file extension
-
– generateBoundaryStringGenerate random boundary string.
Instance Methods
generateBoundaryString
Generate random boundary string.
- (NSString *)generateBoundaryStringReturn Value
Random boundary string.
Discussion
Every time you call this method, you will receive new random boundary string, so call this method only once for each request.
Declared In
NetworkManager+HTTP.hmimeTypeForPath:
Determine mime type on basis of file extension
- (NSString *)mimeTypeForPath:(NSString *)pathParameters
- path
The path of the file being uploaded
Return Value
NSString of mime representation
Declared In
NetworkManager+HTTP.hpost:parameters:completion:
Prepare and initiate application/x-www-form-urlencoded request
- (NetworkDataTaskOperation *)post:(NSURL *)url parameters:(NSDictionary *)parameters completion:(void ( ^ ) ( id responseObject , NSError *error ))completionParameters
- url
URL to use for POST request.
- parameters
NSDictionaryfor parameters to add to POST request; may benilif no additional parameters. This acceptsNSString,NSNumber,NSDate, andNSDataobjects. If the object isNSData, it simply converts it to a UTF8 string. IfNSDate, this creates RFC 3339 date string (with milliseconds).
- completion
Block to be invoked when POST request completes (or fails).
Return Value
The operation that has been started.
Declared In
NetworkManager+HTTP.hpostUploadToURL:parameters:paths:fieldName:completion:
Prepare and initiate multipart/form-data request with files
- (NetworkUploadTaskOperation *)postUploadToURL:(NSURL *)url parameters:(NSDictionary *)parameters paths:(NSArray *)paths fieldName:(NSString *)fieldName completion:(void ( ^ ) ( id responseObject , NSError *error ))completionParameters
- url
URL to use for POST request.
- parameters
NSDictionaryfor parameters to add to POST request; may benilif no additional parameters.
- paths
NSArrayof paths of files to add to request; should be fully qualified file paths.
- fieldName
NSStringof field name to use for files specified inpaths.
- completion
Block to be invoked when POST request completes (or fails).
Return Value
The operation that has been started.
Declared In
NetworkManager+HTTP.h