Inherits from NSObject
Conforms to NSCopying
NSURLConnectionDataDelegate
Declared in VKRequest.h

Overview

Current class allows to perform different kind of requests to VK servers.

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

Instance methods

Appending files

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

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 (nonatomic, assign, readwrite) BOOL offlineMode

Discussion

Defaults to NO.

Declared In

VKRequest.h

signature

Request signature. Can be used as identifier for each request object.

@property (nonatomic, strong, readwrite) id signature

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

cancel

Cancels request

- (void)cancel

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

initWithRequest:

Main method for VKRequest initialization

- (instancetype)initWithRequest:(NSURLRequest *)request

Parameters

request

NSURLRequest which will be used as a base request for VKRequest

Return Value

VKRequest instance

Declared In

VKRequest.h

start

Starts request

- (void)start

Declared In

VKRequest.h