PFQueryTableViewController

@interface PFQueryTableViewController
    : UITableViewController <UITableViewDataSource, UITableViewDelegate>

This class allows you to think about a one-to-one mapping between a PFObject and a UITableViewCell, rather than having to juggle index paths.

You also get the following features out of the box:

  • Pagination with a cell that can be tapped to load the next page.
  • Pull-to-refresh table view header.
  • Automatic downloading and displaying of remote images in cells.
  • Loading screen, shown before any data is loaded.
  • Automatic loading and management of the objects array.
  • Various methods that can be overridden to customize behavior at major events in the data cycle.
  • Initializes with a class name of the PFObject that will be associated with this table.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithStyle:(UITableViewStyle)style
                                className:(nullable NSString *)className;

    Parameters

    style

    The UITableViewStyle for the table

    className

    The class name of the instances of PFObject that this table will display.

    Return Value

    An initialized PFQueryTableViewController object or nil if the object couldn’t be created.

  • Initializes with a class name of the PFObjects that will be associated with this table.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithClassName:(nullable NSString *)className;

    Parameters

    className

    The class name of the instances of PFObject that this table will display.

    Return Value

    An initialized PFQueryTableViewController object or nil if the object couldn’t be created.

  • The class name of the PFObject this table will use as a datasource.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *parseClassName;
  • The key to use to display for the cell text label.

    This won’t apply if you override -tableView:cellForRowAtIndexPath:object:

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *textKey;
  • The key to use to display for the cell image view.

    This won’t apply if you override -tableView:cellForRowAtIndexPath:object:

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *imageKey;
  • The image to use as a placeholder for the cell images.

    This won’t apply if you override -tableView:cellForRowAtIndexPath:object:

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIImage *placeholderImage;
  • Whether the table should use the default loading view. Default - YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL loadingViewEnabled;
  • Whether the table should use the built-in pull-to-refresh feature. Default - YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL pullToRefreshEnabled;
  • Whether the table should use the built-in pagination feature. Default - YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL paginationEnabled;
  • The number of objects to show per page. Default - 25.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSUInteger objectsPerPage;
  • Whether the table is actively loading new data from the server.

    Declaration

    Objective-C

    @property (getter=isLoading, assign, readwrite, nonatomic) BOOL loading;
  • Called when objects will loaded from Parse. If you override this method, you must call [super objectsWillLoad] in your implementation.

    Declaration

    Objective-C

    - (void)objectsWillLoad;
  • Called when objects have loaded from Parse. If you override this method, you must call [super objectsDidLoad:] in your implementation. - parameter: error The Parse error from running the PFQuery, if there was any.

    Declaration

    Objective-C

    - (void)objectsDidLoad:(nullable NSError *)error;

    Parameters

    error

    The Parse error from running the PFQuery, if there was any.

  • The array of instances of PFObject that is used as a data source.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable)
        NSArray<__kindof PFObject *> *objects;
  • Returns an object at a particular indexPath.

    The default impementation returns the object at indexPath.row. If you want to return objects in a different indexPath order, like for sections, override this method.

    Declaration

    Objective-C

    - (nullable PFObject *)objectAtIndexPath:(nullable NSIndexPath *)indexPath;

    Parameters

    indexPath

    The indexPath.

    Return Value

    The object at the specified index

  • Removes an object at the specified index path, animated.

    Declaration

    Objective-C

    - (void)removeObjectAtIndexPath:(nullable NSIndexPath *)indexPath;
  • Removes an object at the specified index path, with or without animation.

    Declaration

    Objective-C

    - (void)removeObjectAtIndexPath:(nullable NSIndexPath *)indexPath
                           animated:(BOOL)animated;
  • Removes all objects at the specified index paths, animated.

    Declaration

    Objective-C

    - (void)removeObjectsAtIndexPaths:(nullable NSArray<NSIndexPath *> *)indexPaths;
  • Removes all objects at the specified index paths, with or without animation.

    Declaration

    Objective-C

    - (void)removeObjectsAtIndexPaths:(nullable NSArray<NSIndexPath *> *)indexPaths
                             animated:(BOOL)animated;
  • Clears the table of all objects.

    Declaration

    Objective-C

    - (void)clear;
  • Clears the table and loads the first page of objects.

    Declaration

    Objective-C

    - (nonnull BFTask<NSArray<__kindof PFObject *> *> *)loadObjects;

    Return Value

    An awaitable task that completes when the reload succeeds

  • Loads the objects of the className at the specified page and appends it to the objects already loaded and refreshes the table.

    Declaration

    Objective-C

    - (nonnull BFTask<NSArray<__kindof PFObject *> *> *)loadObjects:(NSInteger)page
                                                              clear:(BOOL)clear;

    Parameters

    page

    The page of objects to load.

    clear

    Whether to clear the table after receiving the objects

    Return Value

    An awaitable task that completes when the reload succeeds

  • Loads the next page of objects, appends to table, and refreshes.

    Declaration

    Objective-C

    - (void)loadNextPage;
  • Override to construct your own custom PFQuery to get the objects. @result PFQuery that loadObjects will use to the objects for this table.

    Declaration

    Objective-C

    - (nonnull PFQuery *)queryForTable;
  • Override this method to customize each cell given a PFObject that is loaded.

    If you don’t override this method, it will use a default style cell and display either the first data key from the object, or it will display the key as specified with textKey, imageKey.

    Warning

    The cell should inherit from PFTableViewCell which is a subclass of UITableViewCell.

    Declaration

    Objective-C

    - (nullable PFTableViewCell *)tableView:(nonnull UITableView *)tableView
                      cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
                                     object:(nullable PFObject *)object;

    Parameters

    tableView

    The table view object associated with this controller.

    indexPath

    The indexPath of the cell.

    object

    The PFObject that is associated with the cell.

    Return Value

    The cell that represents this object.

  • Override this method to customize the cell that allows the user to load the next page when pagination is turned on.

    Declaration

    Objective-C

    - (nullable PFTableViewCell *)tableView:(nonnull UITableView *)tableView
                 cellForNextPageAtIndexPath:(nonnull NSIndexPath *)indexPath;

    Parameters

    tableView

    The table view object associated with this controller.

    indexPath

    The indexPath of the cell.

    Return Value

    The cell that allows the user to paginate.