SCPagedItems Class Reference
| Inherits from | NSObject |
| Declared in | SCPagedItems.h |
Overview
The SCPagedItems object provides methods for paged loading of the items, it is very usefull if it is expected a lot of items for the given request and the application try to safe the memory and time for reading them.
SCPagedItems object owns all the loaded items.
SCPagedItems instance has three general methods: first to get already loaded items, second - to load an expected count of the items and third - to load an item by the item’s position index.
All methods of this class is not thread safe and they should be called exceptionally from one thread (main thread suggested)
Tasks
-
apiSessionThe SCApiSession object used in creating SCPagedItems object.
property -
pageSizeThe size of the page used to load of items with paging, you can select any positive reasonable and convenient page size for your application.
property -
+ pagedItemsWithApiSession:pageSize:query:Creates SCPagedItems object.
-
+ pagedItemsWithApiSession:request:Creates SCPagedItems object.
-
– itemForIndex:Returns the SCItem object for the given index.
-
– readItemsTotalCountOperationUsed to load expected item count for the given request.
-
– readItemOperationForIndex:Used to load item for the given index.
Properties
apiSession
The SCApiSession object used in creating SCPagedItems object.
@property (nonatomic, readonly) SCApiSession *apiSessionDiscussion
The SCApiSession object used in creating SCPagedItems object.
Declared In
SCPagedItems.hpageSize
The size of the page used to load of items with paging, you can select any positive reasonable and convenient page size for your application.
@property (nonatomic, readonly) NSUInteger pageSizeDiscussion
The size of the page used to load of items with paging, you can select any positive reasonable and convenient page size for your application.
Declared In
SCPagedItems.hClass Methods
pagedItemsWithApiSession:pageSize:query:
Creates SCPagedItems object.
+ (id)pagedItemsWithApiSession:(SCApiSession *)apiSession pageSize:(NSUInteger)pageSize query:(NSString *)queryParameters
- apiSession
SCApiSession object which will be used to load items, should not be nil.
- pageSize
The size of the page used to load of items, you can select any positive reasonable and convenient page size for your application. Used at constructing SCReadItemsRequest object, see [SCReadItemsRequest pageSize].
- query
Query string used at constructing SCReadItemsRequest object, see [SCReadItemsRequest request] and [SCReadItemsRequest requestType] for details.
Return Value
SCPagedItems instance.
Discussion
Creates SCPagedItems object.
Declared In
SCPagedItems.hpagedItemsWithApiSession:request:
Creates SCPagedItems object.
+ (id)pagedItemsWithApiSession:(SCApiSession *)apiSession request:(SCReadItemsRequest *)requestParameters
- apiSession
SCApiSession object which will be used to load items, should not be nil.
- request
Request used to load items by pages. Please, do not forget to set up the pageSize for request.
Return Value
SCPagedItems instance.
Discussion
Creates SCPagedItems object.
Declared In
SCPagedItems.hInstance Methods
itemForIndex:
Returns the SCItem object for the given index.
- (SCItem *)itemForIndex:(NSUInteger)indexParameters
- index
item’s position index.
Return Value
SCItem object or nil if item was not loaded for the given index.
Discussion
Returns the SCItem object for the given index.
Declared In
SCPagedItems.hreadItemOperationForIndex:
Used to load item for the given index.
- (SCAsyncOp)readItemOperationForIndex:(NSUInteger)indexParameters
- index
item’s position index.
Return Value
SCAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is SCItem object or nil if error happens.
SCAsyncOpResult handler may return such errors:
SCNetworkError - if network errors happens.
SCInvalidResponseFormatError - response can not be processed
Discussion
Used to load item for the given index.
Declared In
SCPagedItems.hreadItemsTotalCountOperation
Used to load expected item count for the given request.
- (SCAsyncOp)readItemsTotalCountOperationReturn Value
SCAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is NSNumber object or nil if error happens.
SCAsyncOpResult handler may return such errors:
SCNetworkError - if network errors happens.
SCInvalidResponseFormatError - response can not be processed
Discussion
Used to load expected item count for the given request.
Declared In
SCPagedItems.h