VKRequest Class Reference
Inherits from | NSObject |
Conforms to | NSCopying NSURLConnectionDataDelegate |
Declared in | VKRequest.h |
Tasks
Properties
-
delegate
Delegate
property -
signature
Request signature. Can be used as identifier for each request object.
property -
cacheLiveTime
Cache lifetime for current request. Defaults to one hour.
property -
offlineMode
Offline mode for current request. Current mode is used to return cache data even if its lifetime ended, no deletion occurs (use this mode if no internet connection exists).
property
Class methods
-
+ request:delegate:
Creates a VKRequest request
-
+ requestHTTPMethod:URL:headers:body:delegate:
Creates a VKRequest request
-
+ requestHTTPMethod:methodName:options:delegate:
Creates a VKRequest request
-
+ requestMethod:options:delegate:
Creates a VKRequest request
Instance methods
-
– initWithRequest:
Main method for VKRequest initialization
-
– initWithHTTPMethod:URL:headers:body:
Method for VKRequest initialization
-
– initWithMethod:options:
Method for VKRequest initialization
-
– start
Starts request
-
– cancel
Cancels request
Appending files
-
– appendAudioFile:name:field:
Content of an audio file is added
-
– appendVideoFile:name:field:
Content of a video file is added
-
– appendDocumentFile:name:field:
Content of a document file is added
-
– appendImageFile:name:field:
Content of an image file is added
Properties
cacheLiveTime
Cache lifetime for current request. Defaults to one hour.
@property (nonatomic, assign, readwrite) VKCacheLiveTime cacheLiveTime
Declared In
VKRequest.h
delegate
Delegate
@property (nonatomic, weak, readwrite) id<VKRequestDelegate> delegate
Declared In
VKRequest.h
Class Methods
request:delegate:
Creates a VKRequest request
+ (instancetype)request:(NSURLRequest *)request delegate:(id<VKRequestDelegate>)delegate
Parameters
- request
NSURLRequest which will be used as base for VKRequest
- delegate
delegate that will receive notifications (should conform to VKRequestDelegate protocol)
Return Value
VKRequest instance
Declared In
VKRequest.h
requestHTTPMethod:URL:headers:body:delegate:
Creates a VKRequest request
+ (instancetype)requestHTTPMethod:(NSString *)httpMethod URL:(NSURL *)url headers:(NSDictionary *)headers body:(NSData *)body delegate:(id<VKRequestDelegate>)delegate
Parameters
- httpMethod
GET/POST/PUT/DELETE
- url
NSURL on which a request will be performed
- headers
request headers
- body
request body
- delegate
delegate that will receive notifications (should conform to VKRequestDelegate protocol)
Return Value
VKRequest instance
Declared In
VKRequest.h
requestHTTPMethod:methodName:options:delegate:
Creates a VKRequest request
+ (instancetype)requestHTTPMethod:(NSString *)httpMethod methodName:(NSString *)methodName options:(NSDictionary *)options delegate:(id<VKRequestDelegate>)delegate
Parameters
- httpMethod
GET/POST/PUT/DELETE
- methodName
VK method name (users.get, wall.post etc)
- options
params which should be sent (key = value)
- delegate
delegate that will receive notifications (should conform to VKRequestDelegate protocol)
Return Value
VKRequest instance
Declared In
VKRequest.h
requestMethod:options:delegate:
Creates a VKRequest request
+ (instancetype)requestMethod:(NSString *)methodName options:(NSDictionary *)options delegate:(id<VKRequestDelegate>)delegate
Parameters
- methodName
VK method name (user.get, wall.post etc)
- options
params which should be sent (key = value)
- delegate
delegate that will receive notifications (should conform to VKRequestDelegate protocol)
Return Value
VKRequest instance
Declared In
VKRequest.h
Instance Methods
appendAudioFile:name:field:
Content of an audio file is added
- (void)appendAudioFile:(NSData *)file name:(NSString *)name field:(NSString *)field
Parameters
- file
audio file in byte representation
- name
audio file name
- field
HTML field name, which will be used to send (wrap) data
Declared In
VKRequest.h
appendDocumentFile:name:field:
Content of a document file is added
- (void)appendDocumentFile:(NSData *)file name:(NSString *)name field:(NSString *)field
Parameters
- file
document file in byte representation
- name
document file name
- field
HTML field name, which will be used to send (wrap) data
Declared In
VKRequest.h
appendImageFile:name:field:
Content of an image file is added
- (void)appendImageFile:(NSData *)file name:(NSString *)name field:(NSString *)field
Parameters
- file
image file in byte representation
- name
image file name
- field
HTML field name, which will be used to send (wrap) data
Declared In
VKRequest.h
appendVideoFile:name:field:
Content of a video file is added
- (void)appendVideoFile:(NSData *)file name:(NSString *)name field:(NSString *)field
Parameters
- file
video file in byte representation
- name
video file name
- field
HTML field name, which will be used to send (wrap) data
Declared In
VKRequest.h
initWithHTTPMethod:URL:headers:body:
Method for VKRequest initialization
- (instancetype)initWithHTTPMethod:(NSString *)httpMethod URL:(NSURL *)url headers:(NSDictionary *)headers body:(NSData *)body
Parameters
- httpMethod
GET/POST/PUT/DELETE
- url
NSURL on which a request will be performed
- headers
request headers
- body
request body
Return Value
VKRequest instance
Declared In
VKRequest.h
initWithMethod:options:
Method for VKRequest initialization
- (instancetype)initWithMethod:(NSString *)methodName options:(NSDictionary *)options
Parameters
- methodName
VK method name (users.get, wall.post etc)
- options
params that should be transmitted to VK method
Return Value
VKRequest instance
Discussion
Example:
VKRequest *request = [[VKRequest alloc] initWithMethod:@"users.get"
options:@{@"fields": @"nickname,bdate,status"}];
Declared In
VKRequest.h