SCDataFetchOptions

@interface SCDataFetchOptions : NSObject {
  BOOL _sort;
  NSString *_sortKey;
  BOOL _sortAscending;
  BOOL _filter;
  NSPredicate *_filterPredicate;
  NSUInteger _batchSize;
  NSUInteger _batchStartingOffset;
  NSUInteger _batchCurrentOffset;
}

This class is used to control how data is fetched from SCDataStore. SCDataFetchOptions can be configured to have the data sorted, filtered, and/or returned in batches.

Sample use: SCArrayOfObjectsModel *myObjectsModel = …; myObjectsModel.dataFetchOptions.sort = TRUE;

See also: SCDataStore, SCCoreDataFetchOptions, SCWebServiceFetchOptions

Creation and Initialization

  • Allocates and returns an initialized SCDataFetchOptions object.

    Declaration

    Objective-C

    + (instancetype)options;
  • Allocates and returns an initialized SCDataFetchOptions object given the sorting and filtering configuration.

    Declaration

    Objective-C

    + (instancetype)optionsWithSortKey:(NSString *)key
                         sortAscending:(BOOL)ascending
                       filterPredicate:(NSPredicate *)predicate;

    Parameters

    key

    The key that the data will be sorted against. Passing a non nil value for ‘key’ also sets the sort property to TRUE.

    predicate

    The NSPredicate that the data will be filtered against. Passing a non nil value for ‘predicate’ also sets the filter property to TRUE.

  • Returns an initialized SCDataFetchOptions object given the sorting and filtering configuration.

    Declaration

    Objective-C

    - (instancetype)initWithSortKey:(NSString *)key
                      sortAscending:(BOOL)ascending
                    filterPredicate:(NSPredicate *)predicate;

    Parameters

    key

    The key that the data will be sorted against. Passing a non nil value for ‘key’ also sets the sort property to TRUE.

    predicate

    The NSPredicate that the data will be filtered against. Passing a non nil value for ‘predicate’ also sets the filter property to TRUE.

Configuration

  • Set to TRUE to enable data sorting, otherwise set to FALSE. Default: FALSE.

    Note

    Only applicable when sortKey is set to a valid key.

    Declaration

    Objective-C

    @property (nonatomic) BOOL sort;
  • The key that the data will be sorted against. Default: nil.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *sortKey;
  • Set to TRUE to have the sorting done in ascending order, otherwise set to FALSE. Default: TRUE.

    Note

    Only applicable when sortKey is set to a valid key.

    Declaration

    Objective-C

    @property (nonatomic) BOOL sortAscending;
  • Set to TRUE to enable data filtering, otherwise set to FALSE. Default: TRUE.

    Note

    Only applicable when filterPredicate is set to a valid NSPredicate.

    Declaration

    Objective-C

    @property (nonatomic) BOOL filter;
  • The NSPredicate that the data will be filtered against. Default: nil.

    Declaration

    Objective-C

    @property (nonatomic, strong) NSPredicate *filterPredicate;
  • Set to the data batch size that should be retrieved. Setting this property to zero retrieves all avialable data. Default: 0.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger batchSize;

Internal Properties & Methods (should only used by the framework or when subclassing)

  • The offset of the batch that should be first retrieved. Default: 0.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger batchStartingOffset;
  • The current offset of the last retrieved batch.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSUInteger batchCurrentOffset;
  • The starting index for the next batch to be retrieved.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSUInteger nextBatchStartIndex;
  • Sets the current batch offset.

    Warning

    Reserved for internal framework use only.

    Declaration

    Objective-C

    - (void)setBatchOffset:(NSUInteger)offset;
  • Increments the current batch offset.

    Warning

    Reserved for internal framework use only.

    Declaration

    Objective-C

    - (void)incrementBatchOffset;
  • Resets the current batch offset.

    Warning

    Reserved for internal framework use only.

    Declaration

    Objective-C

    - (void)resetBatchOffset;
  • Returns an array of sort-descriptors based on the current sorting configuration.

    Declaration

    Objective-C

    - (NSArray *)sortDescriptors;
  • Sorts the given array based on the current sorting configuration.

    Declaration

    Objective-C

    - (void)sortMutableArray:(NSMutableArray *)array;
  • Filters the given array based on the current filtering configuration.

    Declaration

    Objective-C

    - (void)filterMutableArray:(NSMutableArray *)array;