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
-
– generateBoundaryString
Generate random boundary string.
Instance Methods
generateBoundaryString
Generate random boundary string.
- (NSString *)generateBoundaryString
Return 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.h
mimeTypeForPath:
Determine mime type on basis of file extension
- (NSString *)mimeTypeForPath:(NSString *)path
Parameters
- path
The path of the file being uploaded
Return Value
NSString
of mime representation
Declared In
NetworkManager+HTTP.h
post:parameters:completion:
Prepare and initiate application/x-www-form-urlencoded request
- (NetworkDataTaskOperation *)post:(NSURL *)url parameters:(NSDictionary *)parameters completion:(void ( ^ ) ( id responseObject , NSError *error ))completion
Parameters
- url
URL to use for POST request.
- parameters
NSDictionary
for parameters to add to POST request; may benil
if no additional parameters. This acceptsNSString
,NSNumber
,NSDate
, andNSData
objects. 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.h
postUploadToURL: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 ))completion
Parameters
- url
URL to use for POST request.
- parameters
NSDictionary
for parameters to add to POST request; may benil
if no additional parameters.
- paths
NSArray
of paths of files to add to request; should be fully qualified file paths.
- fieldName
NSString
of 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