The ATGMobileClient
project is a collection of managers, each having responsibility for a particular area of business logic.
Managers
The ATGRestManager
has the important responsibility of establishing a connection to the server. Each of the other managers uses the ATGRestManager
to make a request to the server via REST. The ATGRestManager
also includes a number of helper methods for frequently-performed tasks. For example, checkForError
checks a REST response for errors.
Managers encapsulate request creation and response management logic that ViewControllers
can use to handle the creation of requests for data, and the receipt of their responses. ATGManagerRequest
is a wrapper around ATGRestOperation
and is the base class for all other requests in CRS-IUA. ATGManagerRequest
gets a reference to the result of the call. For example, the ATGProfileManager.getProfile
method returns a reference to an ATGProfileRequest
, which contains the actual profile representation in its requestResults
property.
Each manager uses a corresponding subclass of ATGManagerRequest
for its server communication. For example, ATGProfileManager
uses ATGProfileRequest
. The definitions of the managers and their requests are located in the Managers
directory of the ATGMobileClient
project.
The following table shows the managers that are provided by CRS-IUA and a brief summary of their responsibilities.
Each manager is implemented as a singleton. Consequently, ViewControllers
use the appropriate manager’s singleton instance to request data from the server. Most importantly, when the ViewController
requests that the manager fetch data for it, it sets itself as the request delegate so that it will receive the appropriate callback, either a success or failure block, when the response to the asynchronous request is available. When a response is returned from the server, the manager executes the success or failure block.
Each manager includes a delegate protocol definition that identifies those callbacks that should be invoked for each response from the server. In the case of the ATGProfileManager
, this is the ATGProfileManagerDelegate
. For example:
@protocol ATGProfileManagerDelegate <NSObject>
The delegate
protocol defines callback methods for the manager. The protocol does not actually implement the method - they are implemented by other classes.
From within a delegate
callback, the ATGManagerRequest
handles the response by executing the success or failure block.