SCSArticleQueryResultsController Class Reference
Inherits from | NSObject |
---|---|
Declared in | SCSArticleQueryResultsController.h |
Overview
This class is intended to efficiently manage the results of an article query to return an indexed list of articles to the caller.
You configure an instance of this controller with a specific query, and the fetches and pagination will automatically be handled for you. Any changes to the set of articles will be communicated through the use of the SCSArticleQueryResultsControllerDelegate, allowing UI state to be updated as needed.
query
The query to be performed. If a nil
value is supplied, this indicates that no articles should be returned from this controller. Assigning new values to this property will result in the set of articles returned being changed, with the appropriate delegate calls made to update the caller’s state.
@property (nullable, nonatomic, copy) SCSArticleQuery *query
Discussion
Note: When this property is changed, no network calls will be automatically made, only the locally-cached article information already stored will be returned immediately. If you wish for new information to be loaded that matches the supplied query, you must invoke loadNextPage:
manually.
Assigning a new query will result in the page loading to reset back to the first page of results.
Any in-flight network actions being performed to load new articles will immediately be cancelled when a new query is assigned.
Warning: Whenever the query is assigned, the result set must reside within the same knowledgeManager instance, including categories and all other properties. The behavior is undefined when this condition is not met.
Declared In
SCSArticleQueryResultsController.h
knowledgeManager
The SCSKnowledgeManager instance this query controller will observe. All queries assigned to this controller must be scoped by the same knowledge manager.
@property (nonatomic, strong, readonly) SCSKnowledgeManager *knowledgeManager
Declared In
SCSArticleQueryResultsController.h
loadingMore
Indicates whether or not this controller is performing a network operation to load more content.
@property (nonatomic, assign, readonly, getter=isLoadingMore) BOOL loadingMore
Declared In
SCSArticleQueryResultsController.h
canLoadMore
Indicates if there is any more content that can be loaded.
@property (nonatomic, assign, readonly) BOOL canLoadMore
Declared In
SCSArticleQueryResultsController.h
delegate
Delegate to receive updates about changes to the data set.
@property (nullable, nonatomic, weak) NSObject<SCSArticleQueryResultsControllerDelegate> *delegate
Declared In
SCSArticleQueryResultsController.h
– initWithQuery:knowledgeManager:
Initializes a new query controller with the given query and knowledge manager. The query may be nil, see the query
property for more information.
- (instancetype)initWithQuery:(nullable SCSArticleQuery *)query knowledgeManager:(SCSKnowledgeManager *)manager
Parameters
query |
The query to perform, or |
---|---|
manager |
The knowledge manager to scope the query searches within. |
Return Value
Initialized instance.
Declared In
SCSArticleQueryResultsController.h
– numberOfArticles
The number of articles currently available from this controller.
- (NSUInteger)numberOfArticles
Declared In
SCSArticleQueryResultsController.h
– articleAtIndex:
Returns the article at the given index, or nil
if the index is out-of-bounds.
- (nullable SCSArticle *)articleAtIndex:(NSUInteger)index
Declared In
SCSArticleQueryResultsController.h
– indexForArticle:
Returns the index within this controller where the supplied article can be found, or NSNotFound
is returned if the article cannot be found within this query controller.
- (NSUInteger)indexForArticle:(SCSArticle *)article
Declared In
SCSArticleQueryResultsController.h
– loadNextPage:
Requests that a network operation be performed to load the next page, if available.
- (void)loadNextPage:(nullable void ( ^ ) ( NSError *_Nullable error ))completion
Declared In
SCSArticleQueryResultsController.h