VKRequest Class Reference

Inherits from VKObject : NSObject
Declared in VKRequest.h
VKRequest.m

Overview

Class for execution API-requests

Other Methods

  progressBlock

Specify progress for uploading or downloading. Useless for text requests (because gzip encoding bytesTotal will always return -1)

@property (nonatomic, copy) void ( ^ ) ( VKProgressType progressType , long long bytesLoaded , long long bytesTotal ) progressBlock

Discussion

Specify progress for uploading or downloading. Useless for text requests (because gzip encoding bytesTotal will always return -1)

Declared In

VKRequest.h

  completeBlock

Specify completion block for request

@property (nonatomic, copy) void ( ^ ) ( VKResponse *response ) completeBlock

Discussion

Specify completion block for request

Declared In

VKRequest.h

  errorBlock

Specity error (HTTP or API) block for request.

@property (nonatomic, copy) void ( ^ ) ( NSError *error ) errorBlock

Discussion

Specity error (HTTP or API) block for request.

Declared In

VKRequest.h

  attempts

Specify attempts for request loading if caused HTTPerror. 0 for infinite

@property (nonatomic, assign) int attempts

Discussion

Specify attempts for request loading if caused HTTPerror. 0 for infinite

Declared In

VKRequest.h

  secure

Use HTTPS requests (by default is YES). If http-request is impossible (user denied no https access), SDK will load https version

@property (nonatomic, assign) BOOL secure

Discussion

Use HTTPS requests (by default is YES). If http-request is impossible (user denied no https access), SDK will load https version

Declared In

VKRequest.h

  useSystemLanguage

Sets current system language as default for API data

@property (nonatomic, assign) BOOL useSystemLanguage

Discussion

Sets current system language as default for API data

Declared In

VKRequest.h

  parseModel

Set to NO if you don’t need automatic model parsing

@property (nonatomic, assign) BOOL parseModel

Discussion

Set to NO if you don’t need automatic model parsing

Declared In

VKRequest.h

  debugTiming

Set to YES if you need info about request timing

@property (nonatomic, assign) BOOL debugTiming

Discussion

Set to YES if you need info about request timing

Declared In

VKRequest.h

  requestTimeout

Timeout for this request

@property (nonatomic, assign) NSInteger requestTimeout

Discussion

Timeout for this request

Declared In

VKRequest.h

  responseQueue

Sets dispatch queue for returning result

@property (nonatomic, assign) dispatch_queue_t responseQueue

Discussion

Sets dispatch queue for returning result

Declared In

VKRequest.h

  waitUntilDone

Set to YES if you need to freeze current thread for response

@property (nonatomic, assign) BOOL waitUntilDone

Discussion

Set to YES if you need to freeze current thread for response

Declared In

VKRequest.h

  methodName

Returns method for current request, e.g. users.get

@property (nonatomic, readonly) NSString *methodName

Discussion

Returns method for current request, e.g. users.get

Declared In

VKRequest.h

  httpMethod

Returns HTTP-method for current request

@property (nonatomic, readonly) NSString *httpMethod

Discussion

Returns HTTP-method for current request

Declared In

VKRequest.h

  methodParameters

Returns list of method parameters (without common parameters)

@property (nonatomic, readonly) NSDictionary *methodParameters

Discussion

Returns list of method parameters (without common parameters)

Declared In

VKRequest.h

  executionOperation

Returns http operation that can be enqueued

@property (nonatomic, readonly) NSOperation *executionOperation

Discussion

Returns http operation that can be enqueued

Declared In

VKRequest.h

  requestTiming

Returns info about request timings

@property (nonatomic, readonly) VKRequestTiming *requestTiming

Discussion

Returns info about request timings

Declared In

VKRequest.h

  isExecuting

Return YES if current request was started

@property (nonatomic, readonly) BOOL isExecuting

Discussion

Return YES if current request was started

Declared In

VKRequest.h

  preventThisErrorsHandling

Return YES if current request was started

@property (nonatomic, copy) NSArray *preventThisErrorsHandling

Discussion

Return YES if current request was started

Declared In

VKRequest.h

Preparing requests

+ requestWithMethod:andParameters:andHttpMethod:

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods (Deprecated: Use requestWithMethod:parameters: instead)

+ (instancetype)requestWithMethod:(NSString *)method andParameters:(NSDictionary *)parameters andHttpMethod:(NSString *)httpMethod

Parameters

method

API-method name, e.g. audio.get

parameters

method parameters

httpMethod

HTTP method for execution, e.g. GET, POST

Return Value

Complete request object for execute or configure method

Discussion

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods

Declared In

VKRequest.h

+ requestWithMethod:andParameters:

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods (Deprecated: Use requestWithMethod:parameters: instead)

+ (instancetype)requestWithMethod:(NSString *)method andParameters:(NSDictionary *)parameters

Parameters

method

API-method name, e.g. audio.get

parameters

method parameters

Return Value

Complete request object for execute or configure method

Discussion

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods

Declared In

VKRequest.h

+ requestWithMethod:andParameters:modelClass:

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods

+ (instancetype)requestWithMethod:(NSString *)method andParameters:(NSDictionary *)parameters modelClass:(Class)modelClass

Parameters

method

API-method name, e.g. audio.get

parameters

method parameters

modelClass

class for automatic parse

Return Value

Complete request object for execute or configure method

Discussion

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods

Declared In

VKRequest.h

+ requestWithMethod:andParameters:andHttpMethod:classOfModel:

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods (Deprecated: Use requestWithMethod:andParameters:modelClass: instead)

+ (instancetype)requestWithMethod:(NSString *)method andParameters:(NSDictionary *)parameters andHttpMethod:(NSString *)httpMethod classOfModel:(Class)modelClass

Parameters

method

API-method name, e.g. audio.get

parameters

method parameters

httpMethod

HTTP method for execution, e.g. GET, POST

modelClass

class for automatic parse

Return Value

Complete request object for execute or configure method

Discussion

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods

Declared In

VKRequest.h

+ requestWithMethod:parameters:

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods

+ (instancetype)requestWithMethod:(NSString *)method parameters:(NSDictionary *)parameters

Parameters

method

API-method name, e.g. audio.get

parameters

method parameters

Return Value

Complete request object for execute or configure method

Discussion

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods

Declared In

VKRequest.h

+ requestWithMethod:parameters:modelClass:

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods

+ (instancetype)requestWithMethod:(NSString *)method parameters:(NSDictionary *)parameters modelClass:(Class)modelClass

Parameters

method

API-method name, e.g. audio.get

parameters

method parameters

modelClass

class for automatic parse

Return Value

Complete request object for execute or configure method

Discussion

Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods

Declared In

VKRequest.h

+ photoRequestWithPostUrl:withPhotos:

Creates new request for upload image to url

+ (instancetype)photoRequestWithPostUrl:(NSString *)url withPhotos:(NSArray *)photoObjects

Parameters

url

url for upload, which was received from special methods

photoObjects

VKPhoto object describes photos

Return Value

Complete request object for execute

Discussion

Creates new request for upload image to url

Declared In

VKRequest.h

– getPreparedRequest

Prepares NSURLRequest and returns prepared url request for current vkrequest

- (NSURLRequest *)getPreparedRequest

Return Value

Prepared request used for loading

Discussion

Prepares NSURLRequest and returns prepared url request for current vkrequest

Declared In

VKRequest.h

Execution

– executeWithResultBlock:errorBlock:

Executes that request, and returns result to blocks

- (void)executeWithResultBlock:(void ( ^ ) ( VKResponse *response ))completeBlock errorBlock:(void ( ^ ) ( NSError *error ))errorBlock

Parameters

completeBlock

called if there were no HTTP or API errors, returns execution result.

errorBlock

called immediately if there was API error, or after attempts tries if there was an HTTP error

Discussion

Executes that request, and returns result to blocks

Declared In

VKRequest.h

– executeAfter:withResultBlock:errorBlock:

Register current request for execute after passed request, if passed request is successful. If it’s not, errorBlock will be called.

- (void)executeAfter:(VKRequest *)request withResultBlock:(void ( ^ ) ( VKResponse *response ))completeBlock errorBlock:(void ( ^ ) ( NSError *error ))errorBlock

Parameters

request

after which request must be called that request

completeBlock

called if there were no HTTP or API errors, returns execution result.

errorBlock

called immediately if there was API error, or after attempts tries if there was an HTTP error

Discussion

Register current request for execute after passed request, if passed request is successful. If it’s not, errorBlock will be called.

Declared In

VKRequest.h

– start

Starts loading of prepared request. You can use it instead of executeWithResultBlock

- (void)start

Discussion

Starts loading of prepared request. You can use it instead of executeWithResultBlock

Declared In

VKRequest.h

– createExecutionOperation

Creates loading operation for this request

- (NSOperation *)createExecutionOperation

Discussion

Creates loading operation for this request

Declared In

VKRequest.h

– repeat

Repeats this request with initial parameters and blocks. Used attempts will be set to 0.

- (void)repeat

Discussion

Repeats this request with initial parameters and blocks. Used attempts will be set to 0.

Declared In

VKRequest.h

– cancel

Cancel current request. Result will be not passed. errorBlock will be called with error code

- (void)cancel

Discussion

Cancel current request. Result will be not passed. errorBlock will be called with error code

Declared In

VKRequest.h

Operating with parameters

– addExtraParameters:

Adds additional parameters to that request

- (void)addExtraParameters:(NSDictionary *)extraParameters

Parameters

extraParameters

parameters supposed to be added

Discussion

Adds additional parameters to that request

Declared In

VKRequest.h

– setPreferredLang:

Specify language for API request

- (void)setPreferredLang:(NSString *)lang

Discussion

Specify language for API request

Declared In

VKRequest.h

Extension Methods

  preparedParameters

Method parametes with common parameters

@property (nonatomic, strong) OrderedDictionary *preparedParameters

Discussion

Method parametes with common parameters

Declared In

VKRequest.m

  uploadUrl

Url for uploading files

@property (nonatomic, strong) NSString *uploadUrl

Discussion

Url for uploading files

Declared In

VKRequest.m

  postRequestsQueue

Requests that should be called after current request.

@property (nonatomic, strong) NSMutableArray *postRequestsQueue

Discussion

Requests that should be called after current request.

Declared In

VKRequest.m

  modelClass

Class for model parsing

@property (nonatomic, strong) Class modelClass

Discussion

Class for model parsing

Declared In

VKRequest.m

  photoObjects

Paths to photos

@property (nonatomic, strong) NSArray *photoObjects

Discussion

Paths to photos

Declared In

VKRequest.m

  attemptsUsed

How much times request was loaded

@property (readwrite, assign) int attemptsUsed

Discussion

How much times request was loaded

Declared In

VKRequest.m

  response

This request response

@property (nonatomic, strong) VKResponse *response

Discussion

This request response

Declared In

VKRequest.m

  error

This request error

@property (nonatomic, strong) NSError *error

Discussion

This request error

Declared In

VKRequest.m

  requestLang

Language specified by user

@property (nonatomic, copy) NSString *requestLang

Discussion

Language specified by user

Declared In

VKRequest.m