DAAsyncRequest

Overview

DAAsyncRequest objects present an ongoing or completed asynchronous request that a DARemoteDataAdapter is executing after one of its begin* methods was called. The DAAsyncRequest can be used to check the status of the request, assign a delegate (of type DAAsyncRequestDelegate to be informed of progress, success and failures.

Some overloads of the begin* methods on the DARemoteDataAdapter take a BOOL start parameter. When passing in YES, they will return a request that is already started, as do the overloads without start parameter. When passing in NO, the returned DAAsyncRequest has not been started yet and can be started by sending it a start or startInBackground message.

Please also refer to for a more general overview of asynchronous requests, and check out Remote Data Adapter and Data Tables (Xcode).

Location

 

adapter

Represents the instance of the DARemoteDataAdapter which is executing given request

@property (readonly) DARemoteDataAdapter *adapter

commandOutParameters

Represents dictionary which can contains output parameters with their values after completion of the ExecuteCommandEx request

@property (readonly) NSDictionary *commandOutParameters

commandResult

Represents result value of the executing ExecuteCommand or ExecuteCommandEx requests

@property (readonly) int commandResult

context  retain

Represents an any arbitrary object (id), which can be associated with request and later it allows you to identify the particular request object – this can be useful in case when you run several independent requests with the same delegate

@property (retain) id context

customParameters  retain

Represents a dictionary of any custom properties wich can be binded to the given request.

@property (retain) NSMutableDictionary *customParameters

delegate  assign

Represents a delegate object which will be informed with (and it can handle them) various callbacks: when the request succeeds or fails or the server requests authentication. If no delegate is assigned, the request automatically inherits the delegate from the DARemoteDataAdapter.

@property (assign) id<DAAsyncRequestDelegate> delegate

failureBlock  copy

Represents a block of code that will be executed in case of request failure. You can specify here any logic to inform user about of error and possible cause, release resources if necessary or clear request state.

@property (copy) void(^)(NSException *) failureBlock

initWithAsyncRequest:adapter:

Initializes a new DAAsyncRequest instance with the provided ROAsyncRequest instance and given DARemoteDataAdapter instance. In most cases you don't need to deal with this method directly.

- (id) initWithAsyncRequest:(ROAsyncRequest *)aRequest adapter:(DARemoteDataAdapter *)aAdapter

Parameters:

  • aRequest: base ROAsyncRequest
  • aAdapter: Instance of the base DARemoteDataAdapter that is in charge of handling given request

request

Represents the base ROAsyncRequest of the given DAAsyncRequest.

@property (readonly) ROAsyncRequest *request

schema

Represents a DASchema instance that can be available after executing beginGetSchema request.

@property (readonly) DASchema *schema

start

Starts the request, if it is not already running (see above). While the request itself will be executed in the background, the current thread will be considered the request's context, and any callbacks to the delegate will happen on the thread that sent the start message.

- (void) start

startInBackground

Starts the request, if it is not already running (see above). The request itself will be executed in the background, regardless how it was started. However, by starting a request with startInBackground, any callbacks to the delegate will happen on a background thread, and not the thread that started the request. The identity of this background thread is undefined and may depend on the underlying communication structure.

If startInBackground is sent to a request that is already running, an exception will be thrown.

- (void) startInBackground

startInBackgroundWithBlock:

Starts the request with the completion block. The request itself will be executed in the background, regardless how it was started. Also any callbacks to the delegate including completion block will happen on a background thread, and not the thread that started the request. The identity of this background thread is undefined and may depend on the underlying communication structure.

If startInBackground is sent to a request that is already running, an exception will be thrown.

- (void) startInBackgroundWithBlock:(void^)aBlock

Parameters:

  • aBlock: The completion handler block to execute

startWithBlock:

Runs given DAAsyncRequest with given completion handler block of code.

- (void) startWithBlock:(void^)block

Parameters:

  • block: The completion handler block to execute

tableNamed:

Returns DADataTable instance by given name. Useful incase you have requested data for several tables in the single request.

- (DADataTable *) tableNamed:(NSString *)name

Parameters:

  • name: Name of the data table you want to retrieve from succesful getData request

tables

Array of tables that can be available after succesful GetData request. In can be used in cases when you have requested data for several tables in the single request.

@property (readonly) NSArray *tables

type

Represents the type of the request (is it GetDataTable or GetSchema or any from other possible request types).

@property (readonly) enum DAAsyncRequestType type

 

adapter

Represents the instance of the DARemoteDataAdapter which is executing given request

@property (readonly) DARemoteDataAdapter *adapter

commandOutParameters

Represents dictionary which can contains output parameters with their values after completion of the ExecuteCommandEx request

@property (readonly) NSDictionary *commandOutParameters

commandResult

Represents result value of the executing ExecuteCommand or ExecuteCommandEx requests

@property (readonly) int commandResult

context  retain

Represents an any arbitrary object (id), which can be associated with request and later it allows you to identify the particular request object – this can be useful in case when you run several independent requests with the same delegate

@property (retain) id context

customParameters  retain

Represents a dictionary of any custom properties wich can be binded to the given request.

@property (retain) NSMutableDictionary *customParameters

delegate  assign

Represents a delegate object which will be informed with (and it can handle them) various callbacks: when the request succeeds or fails or the server requests authentication. If no delegate is assigned, the request automatically inherits the delegate from the DARemoteDataAdapter.

@property (assign) id<DAAsyncRequestDelegate> delegate

failureBlock  copy

Represents a block of code that will be executed in case of request failure. You can specify here any logic to inform user about of error and possible cause, release resources if necessary or clear request state.

@property (copy) void(^)(NSException *) failureBlock

request

Represents the base ROAsyncRequest of the given DAAsyncRequest.

@property (readonly) ROAsyncRequest *request

schema

Represents a DASchema instance that can be available after executing beginGetSchema request.

@property (readonly) DASchema *schema

tables

Array of tables that can be available after succesful GetData request. In can be used in cases when you have requested data for several tables in the single request.

@property (readonly) NSArray *tables

type

Represents the type of the request (is it GetDataTable or GetSchema or any from other possible request types).

@property (readonly) enum DAAsyncRequestType type

 

initWithAsyncRequest:adapter:

Initializes a new DAAsyncRequest instance with the provided ROAsyncRequest instance and given DARemoteDataAdapter instance. In most cases you don't need to deal with this method directly.

- (id) initWithAsyncRequest:(ROAsyncRequest *)aRequest adapter:(DARemoteDataAdapter *)aAdapter

Parameters:

  • aRequest: base ROAsyncRequest
  • aAdapter: Instance of the base DARemoteDataAdapter that is in charge of handling given request

start

Starts the request, if it is not already running (see above). While the request itself will be executed in the background, the current thread will be considered the request's context, and any callbacks to the delegate will happen on the thread that sent the start message.

- (void) start

startInBackground

Starts the request, if it is not already running (see above). The request itself will be executed in the background, regardless how it was started. However, by starting a request with startInBackground, any callbacks to the delegate will happen on a background thread, and not the thread that started the request. The identity of this background thread is undefined and may depend on the underlying communication structure.

If startInBackground is sent to a request that is already running, an exception will be thrown.

- (void) startInBackground

startInBackgroundWithBlock:

Starts the request with the completion block. The request itself will be executed in the background, regardless how it was started. Also any callbacks to the delegate including completion block will happen on a background thread, and not the thread that started the request. The identity of this background thread is undefined and may depend on the underlying communication structure.

If startInBackground is sent to a request that is already running, an exception will be thrown.

- (void) startInBackgroundWithBlock:(void^)aBlock

Parameters:

  • aBlock: The completion handler block to execute

startWithBlock:

Runs given DAAsyncRequest with given completion handler block of code.

- (void) startWithBlock:(void^)block

Parameters:

  • block: The completion handler block to execute

tableNamed:

Returns DADataTable instance by given name. Useful incase you have requested data for several tables in the single request.

- (DADataTable *) tableNamed:(NSString *)name

Parameters:

  • name: Name of the data table you want to retrieve from succesful getData request

See Also