Skip to content

MagicV2ListInteractor

rpinto edited this page Jul 24, 2015 · 1 revision

Behaviour

This class is the link between your model (where datas are stored) and the Magic component (where datas are displayed). It's getting called at the right time to request datas (from network or coredata for example). It also store the current displayed datas.

Implementation

1) [Required] implement sendRequest methods to request datas (from an API, plist, ...). Use the self.page and self.perPage to retrieve the needed page datas.

  • Call didReceiveError if an error occures while requesting datas.
  • Call didReceiveResults: with the new items to add to the list (sorted) when you finished to request datas.

2) [Optional] implement loadLocalResults methods to retrieve datas (coredata for example). Use the self.page and self.perPage to retrieve the needed page datas.

  • Call didReceiveError if an error occures while requesting datas.
  • Call didReceiveResults: with the new items to add to the list (sorted) when you finished to request datas.

3) results is the MutableArray containing sorted NSObjects. Those are your results.

4) page is the current page.

5) perPage is the number of results requested at one time.

6) loadingType is an enum indicating if the interactor current requesting status : not loading, init (first request), pull to refresh, paging.

7) requestCallDeltaTime represent the duration between two calls of sendRequest. When you set this value you have to override the loadLocalResults and set a requestKey.

8) requestKey is an NSString that identify the request. It's used to store the last request call time for cached datas check. It need to be different for each page (2 differents member profile request MUST have 2 differents requestKey so you need to use the member id or username).

9) Override pagingTriggered method to get notified when the paging is triggered. Don't forget to call the super.

10) Override pullToRefreshTriggered method to get notified when the pull to refresh is triggered. Don't forget to call the super.

Clone this wiki locally