AWFObjectLoader Class Reference
Inherits from | NSObject |
---|---|
Conforms to | NSCopying |
Declared in | AWFObjectLoader.h |
Overview
AWFObjectLoader
is a concrete class that is responsible for handling all requests, data parsing, and object mapping for
a specific API endpoint. This class should not be used as is, but rather should be subclassed to provided the required configuration
for interacting with the API.
endpoint
The endpoint used for all data requests.
@property (nonatomic, readonly) NSString *endpoint
Declared In
AWFObjectLoader.h
options
The default request options used for all requests.
@property (nonatomic, strong) AWFRequestOptions *options
Declared In
AWFObjectLoader.h
objectClass
The model object class used when parsing requests into the associated objects.
@property (nonatomic, readonly) Class objectClass
Declared In
AWFObjectLoader.h
expires
The duration, in seconds, before the data loaded with this loader expires.
@property (nonatomic, readonly) NSTimeInterval expires
Declared In
AWFObjectLoader.h
isLoading
A Boolean value indicating if the object loader is currently requesting data.
@property (nonatomic, readonly) BOOL isLoading
Declared In
AWFObjectLoader.h
hasLoaded
A Boolean value indicating if the object loader has already loaded data at least once.
@property (nonatomic, readonly) BOOL hasLoaded
Declared In
AWFObjectLoader.h
delegate
The receiver’s delegate. (Deprecated: As of version 2.0. Use execution blocks instead.)
@property (nonatomic, weak) NSObject<AFObjectLoaderDelegate> *delegate
Discussion
An object loader sends messages to its delegate when requests have either completed successfully or failed.
Declared In
AWFObjectLoader.h
– initWithOptions:
Initializes and returns an object loader instance.
- (instancetype)initWithOptions:(AWFRequestOptions *)options
Parameters
options |
An |
---|
Return Value
The initialized object loader instance.
Discussion
If an options
value is provided, it will be stored with the object loader and used as the default for all requests.
Declared In
AWFObjectLoader.h
– sharedClient
The API client used for all requests.
- (AerisAPIClient *)sharedClient
Declared In
AWFObjectLoader.h
– getWithOptions:completion:
Requests all objects for the related endpoint. If additional options are provided, then the request will be filtered by those options.
- (void)getWithOptions:(AWFRequestOptions *)options completion:(AWFObjectLoaderCompletionBlock)completionBlock
Parameters
options |
An |
---|---|
completionBlock |
The block to be executed on the completion or failure of a request. This block has no return value and takes two arguments:
the array of |
Discussion
Note: If no objects were returned from the request, but the request did not contain any errors, then the completionBlock
block will still
be executed without errors. Your block handler should verify the total number of objects returned before trying to access them.
Declared In
AWFObjectLoader.h
– getWithOptions:expirationInterval:completion:
Requests all objects for the related endpoint using the specified expiration age for the request. If additional options are provided, then the request will be filtered by those options.
- (void)getWithOptions:(AWFRequestOptions *)options expirationInterval:(NSTimeInterval)expirationInterval completion:(AWFObjectLoaderCompletionBlock)completionBlock
Parameters
options |
An |
---|---|
expirationInterval |
The maximum age allowed to use previously cached data for the request. If the data is older than this value, new remote data will be requested. |
completionBlock |
The block to be executed on the completion or failure of a request. This block has no return value and takes two arguments:
the array of |
Discussion
Note: If no objects were returned from the request, but the request did not contain any errors, then the completionBlock
block will still
be executed without errors. Your block handler should verify the total number of objects returned before trying to access them.
Declared In
AWFObjectLoader.h
– getObject:withOptions:completion:
Requests data for the provided object. The object’s unique identifier will be used in the actual request.
- (void)getObject:(AWFObject *)object withOptions:(AWFRequestOptions *)options completion:(AWFObjectLoaderObjectCompletionBlock)completionBlock
Parameters
object |
The object to request |
---|---|
options |
An |
completionBlock |
The block to be executed on the completion or failure of a request. This block has no return value and takes two arguments:
the array of |
Discussion
This method is often used to update a previously loaded object that may have changed on the server, or to request additional data from a related endpoint using the same identifier.
Declared In
AWFObjectLoader.h
– getObject:withOptions:expirationInterval:completion:
Requests data for the provided object using the specified expiration age for the request. The object’s unique identifier will be used in the actual request.
- (void)getObject:(AWFObject *)object withOptions:(AWFRequestOptions *)options expirationInterval:(NSTimeInterval)expirationInterval completion:(AWFObjectLoaderObjectCompletionBlock)completionBlock
Parameters
object |
The object to request |
---|---|
options |
An |
expirationInterval |
The maximum age allowed to use previously cached data for the request. If the data is older than this value, new remote data will be requested. |
completionBlock |
The block to be executed on the completion or failure of a request. This block has no return value and takes two arguments:
the array of |
Discussion
This method is often used to update a previously loaded object that may have changed on the server, or to request additional data from a related endpoint using the same identifier.
Declared In
AWFObjectLoader.h
– getObjectWithId:withOptions:completion:
Requests data for a specific object based on that object’s unique identifier.
- (void)getObjectWithId:(NSString *)objectId withOptions:(AWFRequestOptions *)options completion:(AWFObjectLoaderObjectCompletionBlock)completionBlock
Parameters
objectId |
The identifier of the object to request. |
---|---|
options |
An |
completionBlock |
The block to be executed on the completion or failure of a request. This block has no return value and takes two arguments:
the array of |
Discussion
Note: If no objects were returned from the request, but the request did not contain any errors, then the completionBlock
block will still
be executed without errors. Your block handler should verify the total number of objects returned before trying to access them.
Declared In
AWFObjectLoader.h
– getObjectWithId:withOptions:expirationInterval:completion:
Requests data for a specific object based on that unique identifier and expiration interval.
- (void)getObjectWithId:(NSString *)objectId withOptions:(AWFRequestOptions *)options expirationInterval:(NSTimeInterval)expirationInterval completion:(AWFObjectLoaderObjectCompletionBlock)completionBlock
Parameters
objectId |
The identifier of the object to request. |
---|---|
options |
An |
expirationInterval |
The maximum age allowed to use previously cached data for the request. If the data is older than this value, new remote data will be requested. |
completionBlock |
The block to be executed on the completion or failure of a request. This block has no return value and takes two arguments:
the array of |
Declared In
AWFObjectLoader.h
– searchWithOptions:completion:
Requests data based on a specific search query and request options. This method requires a valid query
value on the provided
options instance.
- (void)searchWithOptions:(AWFRequestOptions *)options completion:(AWFObjectLoaderCompletionBlock)completionBlock
Parameters
options |
An |
---|---|
completionBlock |
The block to be executed on the completion or failure of a request. This block has no return value and takes two arguments:
the array of |
Discussion
Note: If no objects were returned from the request, but the request did not contain any errors, then the completionBlock
block will still
be executed without errors. Your block handler should verify the total number of objects returned before trying to access them.
Declared In
AWFObjectLoader.h
– cancel
Cancels any active request operations that have not yet completed.
- (void)cancel
Declared In
AWFObjectLoader.h
– reset
Cancels any active requests and restores the loader back to its original state before any data was requested.
- (void)reset
Declared In
AWFObjectLoader.h
– objectClassForDataType:
- (Class)objectClassForDataType:(NSString *)dataType
Parameters
dataType |
The data type key to return the object class for |
---|
Discussion
This is used specifically with the dataType
property on an object loader’s AWFRequestOptions
object if you need the loader to use a subendpoint
supported by its primary API endpoint.
Declared In
AWFObjectLoader.h
– requestWithSearchOptions:
Requests data based on the provided search options.
Using this method requires you to at least provide a value for the query
parameter in your options. (Deprecated: As of version 2.0, replaced by {@link #searchWithOptions:success:failure:})
- (void)requestWithSearchOptions:(NSDictionary *)options
Parameters
options |
An optional dictionary containing additional parameters to be used with the request. |
---|
Declared In
AWFObjectLoader.h