GPKGPagination

Objective-C

@interface GPKGPagination : NSObject

Swift

class GPKGPagination : NSObject

Query pagination configuration

  • Find the pagination offset and limit from the SQL statement

    Declaration

    Objective-C

    + (GPKGPagination *)findInSQL:(NSString *)sql;

    Swift

    class func find(inSQL sql: String!) -> GPKGPagination!

    Parameters

    sql

    SQL statement

    Return Value

    pagination or null if not found

  • Replace the pagination limit and offset in the SQL statement

    Declaration

    Objective-C

    + (NSString *)replaceSQL:(NSString *)sql
              withPagination:(GPKGPagination *)pagination;

    Swift

    class func replaceSQL(_ sql: String!, with pagination: GPKGPagination!) -> String!

    Parameters

    sql

    SQL statement

    pagination

    pagination settings

    Return Value

    modified SQL statement

  • Limit

    Declaration

    Objective-C

    @property (nonatomic) int limit;

    Swift

    var limit: Int32 { get set }
  • Offset

    Declaration

    Objective-C

    @property (nonatomic, strong) NSNumber *offset;

    Swift

    var offset: NSNumber! { get set }
  • Initialize

    Declaration

    Objective-C

    - (instancetype)initWithLimit:(int)limit;

    Swift

    init!(limit: Int32)

    Parameters

    limit

    upper bound number of rows

    Return Value

    new pagination

  • Initialize

    Declaration

    Objective-C

    - (instancetype)initWithLimit:(int)limit andOffsetInt:(int)offset;

    Swift

    init!(limit: Int32, andOffsetInt offset: Int32)

    Parameters

    limit

    upper bound number of rows

    offset

    row result starting offset

    Return Value

    new pagination

  • Initialize

    Declaration

    Objective-C

    - (instancetype)initWithLimit:(int)limit andOffset:(NSNumber *)offset;

    Swift

    init!(limit: Int32, andOffset offset: NSNumber!)

    Parameters

    limit

    upper bound number of rows

    offset

    row result starting offset

    Return Value

    new pagination

  • Is there positive limit

    Declaration

    Objective-C

    - (BOOL)hasLimit;

    Swift

    func hasLimit() -> Bool

    Return Value

    true if limit above 0

  • Is there an offset

    Declaration

    Objective-C

    - (BOOL)hasOffset;

    Swift

    func hasOffset() -> Bool

    Return Value

    true if has an offset

  • If the limit is positive, increment the offset

    Declaration

    Objective-C

    - (void)incrementOffset;

    Swift

    func incrementOffset()
  • Increment the offset by the count

    Declaration

    Objective-C

    - (void)incrementOffsetByCount:(int)count;

    Swift

    func incrementOffset(byCount count: Int32)

    Parameters

    count

    count to increment

  • Replace the limit and offset in the SQL statement with the pagination values

    Declaration

    Objective-C

    - (NSString *)replaceSQL:(NSString *)sql;

    Swift

    func replaceSQL(_ sql: String!) -> String!

    Parameters

    sql

    SQL statement

    Return Value

    modified SQL statement