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

Properties

apiSession

The SCApiSession object used in creating SCPagedItems object.

@property (nonatomic, readonly) SCApiSession *apiSession

Discussion

The SCApiSession object used in creating SCPagedItems object.

Declared In

SCPagedItems.h

pageSize

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 pageSize

Discussion

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.h

Class Methods

pagedItemsWithApiSession:pageSize:query:

Creates SCPagedItems object.

+ (id)pagedItemsWithApiSession:(SCApiSession *)apiSession pageSize:(NSUInteger)pageSize query:(NSString *)query

Parameters

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.h

pagedItemsWithApiSession:request:

Creates SCPagedItems object.

+ (id)pagedItemsWithApiSession:(SCApiSession *)apiSession request:(SCReadItemsRequest *)request

Parameters

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.h

Instance Methods

itemForIndex:

Returns the SCItem object for the given index.

- (SCItem *)itemForIndex:(NSUInteger)index

Parameters

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.h

readItemOperationForIndex:

Used to load item for the given index.

- (SCAsyncOp)readItemOperationForIndex:(NSUInteger)index

Parameters

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:

Discussion

Used to load item for the given index.

Declared In

SCPagedItems.h

readItemsTotalCountOperation

Used to load expected item count for the given request.

- (SCAsyncOp)readItemsTotalCountOperation

Return 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:

Discussion

Used to load expected item count for the given request.

Declared In

SCPagedItems.h