ASTableNode Class Reference
Inherits from | ASDisplayNode : ASDealloc2MainObject |
---|---|
Conforms to | ASRangeControllerUpdateRangeProtocol |
Declared in | ASTableNode.h |
Overview
ASTableNode is a node based class that wraps an ASTableView. It can be used as a subnode of another node, and provide room for many (great) features and improvements later on.
– init
Designated initializer.
- (instancetype)init
Return Value
An ASDisplayNode instance whose view will be a subclass that enables asynchronous rendering, and passes through -layout and touch handling methods.
Declared In
ASDisplayNode.h
view
Returns a view.
@property (strong, nonatomic, readonly) ASTableView *view
Discussion
The view property is lazily initialized, similar to UIViewController. To go the other direction, use ASViewToDisplayNode() in ASDisplayNodeExtras.h.
Warning: The first access to it must be on the main thread, and should only be used on the main thread thereafter as well.
Declared In
ASDisplayNode.h
– tuningParametersForRangeType:
Tuning parameters for a range type in full mode.
- (ASRangeTuningParameters)tuningParametersForRangeType:(ASLayoutRangeType)rangeType
Parameters
rangeType |
The range type to get the tuning parameters for. |
---|
Return Value
A tuning parameter value for the given range type in full mode.
Declared In
ASTableNode.h
– setTuningParameters:forRangeType:
Set the tuning parameters for a range type in full mode.
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType
Parameters
tuningParameters |
The tuning parameters to store for a range type. |
---|---|
rangeType |
The range type to set the tuning parameters for. |
Declared In
ASTableNode.h
– tuningParametersForRangeMode:rangeType:
Tuning parameters for a range type in the specified mode.
- (ASRangeTuningParameters)tuningParametersForRangeMode:(ASLayoutRangeMode)rangeMode rangeType:(ASLayoutRangeType)rangeType
Parameters
rangeMode |
The range mode to get the running parameters for. |
---|---|
rangeType |
The range type to get the tuning parameters for. |
Return Value
A tuning parameter value for the given range type in the given mode.
Declared In
ASTableNode.h
– setTuningParameters:forRangeMode:rangeType:
Set the tuning parameters for a range type in the specified mode.
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeMode:(ASLayoutRangeMode)rangeMode rangeType:(ASLayoutRangeType)rangeType
Parameters
tuningParameters |
The tuning parameters to store for a range type. |
---|---|
rangeMode |
The range mode to set the running parameters for. |
rangeType |
The range type to set the tuning parameters for. |
Declared In
ASTableNode.h
– scrollToRowAtIndexPath:atScrollPosition:animated:
Scrolls the table to the given row.
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
Parameters
indexPath |
The index path of the row. |
---|---|
scrollPosition |
Where the row should end up after the scroll. |
animated |
Whether the scroll should be animated or not. This method must be called on the main thread. |
Declared In
ASTableNode.h
– reloadDataWithCompletion:
Reload everything from scratch, destroying the working range and all cached nodes.
- (void)reloadDataWithCompletion:(nullable void ( ^ ) ( ))completion
Parameters
completion |
block to run on completion of asynchronous loading or nil. If supplied, the block is run on the main thread. |
---|
Discussion
Warning: This method is substantially more expensive than UITableView’s version.
Declared In
ASTableNode.h
– reloadData
Reload everything from scratch, destroying the working range and all cached nodes.
- (void)reloadData
Discussion
Warning: This method is substantially more expensive than UITableView’s version.
Declared In
ASTableNode.h
– relayoutItems
Triggers a relayout of all nodes.
- (void)relayoutItems
Discussion
This method invalidates and lays out every cell node in the table view.
Declared In
ASTableNode.h
– performBatchAnimated:updates:completion:
Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread. The data source must be updated to reflect the changes before the update block completes.
- (void)performBatchAnimated:(BOOL)animated updates:(nullable __attribute ( ( noescape ) ) void ( ^ ) ( ))updates completion:(nullable void ( ^ ) ( BOOL finished ))completion
Parameters
animated |
NO to disable animations for this batch |
---|---|
updates |
The block that performs the relevant insert, delete, reload, or move operations. |
completion |
A completion handler block to execute when all of the operations are finished. This block takes a single Boolean parameter that contains the value YES if all of the related animations completed successfully or NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. |
Declared In
ASTableNode.h
– performBatchUpdates:completion:
Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread. The data source must be updated to reflect the changes before the update block completes.
- (void)performBatchUpdates:(nullable __attribute ( ( noescape ) ) void ( ^ ) ( ))updates completion:(nullable void ( ^ ) ( BOOL finished ))completion
Parameters
updates |
The block that performs the relevant insert, delete, reload, or move operations. |
---|---|
completion |
A completion handler block to execute when all of the operations are finished. This block takes a single Boolean parameter that contains the value YES if all of the related animations completed successfully or NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. |
Declared In
ASTableNode.h
– waitUntilAllUpdatesAreCommitted
Blocks execution of the main thread until all section and row updates are committed. This method must be called from the main thread.
- (void)waitUntilAllUpdatesAreCommitted
Declared In
ASTableNode.h
– insertSections:withRowAnimation:
Inserts one or more sections, with an option to animate the insertion.
- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
Parameters
sections |
An index set that specifies the sections to insert. |
---|---|
animation |
A constant that indicates how the insertion is to be animated. See UITableViewRowAnimation. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASTableNode.h
– deleteSections:withRowAnimation:
Deletes one or more sections, with an option to animate the deletion.
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
Parameters
sections |
An index set that specifies the sections to delete. |
---|---|
animation |
A constant that indicates how the deletion is to be animated. See UITableViewRowAnimation. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASTableNode.h
– reloadSections:withRowAnimation:
Reloads the specified sections using a given animation effect.
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
Parameters
sections |
An index set that specifies the sections to reload. |
---|---|
animation |
A constant that indicates how the reloading is to be animated. See UITableViewRowAnimation. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASTableNode.h
– moveSection:toSection:
Moves a section to a new location.
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection
Parameters
section |
The index of the section to move. |
---|---|
newSection |
The index that is the destination of the move for the section. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASTableNode.h
– insertRowsAtIndexPaths:withRowAnimation:
Inserts rows at the locations identified by an array of index paths, with an option to animate the insertion.
- (void)insertRowsAtIndexPaths:(NSArray<NSIndexPath*> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
Parameters
indexPaths |
An array of NSIndexPath objects, each representing a row index and section index that together identify a row. |
---|---|
animation |
A constant that indicates how the insertion is to be animated. See UITableViewRowAnimation. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASTableNode.h
– deleteRowsAtIndexPaths:withRowAnimation:
Deletes the rows specified by an array of index paths, with an option to animate the deletion.
- (void)deleteRowsAtIndexPaths:(NSArray<NSIndexPath*> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
Parameters
indexPaths |
An array of NSIndexPath objects identifying the rows to delete. |
---|---|
animation |
A constant that indicates how the deletion is to be animated. See UITableViewRowAnimation. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASTableNode.h
– reloadRowsAtIndexPaths:withRowAnimation:
Reloads the specified rows using a given animation effect.
- (void)reloadRowsAtIndexPaths:(NSArray<NSIndexPath*> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
Parameters
indexPaths |
An array of NSIndexPath objects identifying the rows to reload. |
---|---|
animation |
A constant that indicates how the reloading is to be animated. See UITableViewRowAnimation. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASTableNode.h
– moveRowAtIndexPath:toIndexPath:
Moves the row at a specified location to a destination location.
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath
Parameters
indexPath |
The index path identifying the row to move. |
---|---|
newIndexPath |
The index path that is the destination of the move for the row. |
Discussion
This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes before this method is called.
Declared In
ASTableNode.h
– selectRowAtIndexPath:animated:scrollPosition:
Selects a row in the table view identified by index path, optionally scrolling the row to a location in the table view. This method does not cause any selection-related delegate methods to be called.
- (void)selectRowAtIndexPath:(nullable NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition
Parameters
indexPath |
An index path identifying a row in the table view. |
---|---|
animated |
Specify YES to animate the change in the selection or NO to make the change without animating it. |
scrollPosition |
A constant that identifies a relative position in the table view (top, middle, bottom) for the row when scrolling concludes. See |
Discussion
This method must be called from the main thread.
Declared In
ASTableNode.h
– numberOfRowsInSection:
Retrieves the number of rows in the given section.
- (NSInteger)numberOfRowsInSection:(NSInteger)section
Parameters
section |
The section. |
---|
Return Value
The number of rows.
Declared In
ASTableNode.h
numberOfSections
The number of sections in the table node.
@property (nonatomic, readonly) NSInteger numberOfSections
Declared In
ASTableNode.h
visibleNodes
Similar to -visibleCells.
@property (nonatomic, readonly) NSArray<__kindofASCellNode*> *visibleNodes
Return Value
an array containing the nodes being displayed on screen. This must be called on the main thread.
Declared In
ASTableNode.h
– nodeForRowAtIndexPath:
Retrieves the node for the row at the given index path.
- (nullable __kindof ASCellNode *)nodeForRowAtIndexPath:(NSIndexPath *)indexPath
Declared In
ASTableNode.h
– indexPathForNode:
Similar to -indexPathForCell:.
- (nullable NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode
Parameters
cellNode |
a node for a row. |
---|
Return Value
The index path to this row, if it exists.
Discussion
This method will return @c nil for a node that is still being displayed in the table view, if the data source has deleted the row. That is, the node is visible but it no longer corresponds to any item in the data source and will be removed soon.
Declared In
ASTableNode.h
– rectForRowAtIndexPath:
Similar to -[UITableView rectForRowAtIndexPath:]
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath
Parameters
indexPath |
An index path identifying a row in the table view. |
---|
Return Value
A rectangle defining the area in which the table view draws the row or CGRectZero if indexPath is invalid.
Discussion
This method must be called from the main thread.
Declared In
ASTableNode.h
– cellForRowAtIndexPath:
Similar to -[UITableView cellForRowAtIndexPath:]
- (nullable __kindof UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath
Parameters
indexPath |
An index path identifying a row in the table view. |
---|
Return Value
An object representing a cell of the table, or nil if the cell is not visible or indexPath is out of range.
Discussion
This method must be called from the main thread.
Declared In
ASTableNode.h
indexPathForSelectedRow
Similar to UITableView.indexPathForSelectedRow
@property (nonatomic, readonly, nullable) NSIndexPath *indexPathForSelectedRow
Return Value
The value of this property is an index path identifying the row and section indexes of the selected row, or nil if the index path is invalid. If there are multiple selections, this property contains the first index-path object in the array of row selections; this object has the lowest index values for section and row.
Discussion
This method must be called from the main thread.
Declared In
ASTableNode.h
– indexPathForRowAtPoint:
Similar to -[UITableView indexPathForRowAtPoint:]
- (nullable NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point
Parameters
point |
A point in the local coordinate system of the table view (the table view’s bounds). |
---|
Return Value
An index path representing the row and section associated with point, or nil if the point is out of the bounds of any row.
Discussion
This method must be called from the main thread.
Declared In
ASTableNode.h
– indexPathsForRowsInRect:
Similar to -[UITableView indexPathsForRowsInRect:]
- (nullable NSArray<NSIndexPath*> *)indexPathsForRowsInRect:(CGRect)rect
Parameters
rect |
A rectangle defining an area of the table view in local coordinates. |
---|
Return Value
An array of NSIndexPath objects each representing a row and section index identifying a row within rect. Returns an empty array if there aren’t any rows to return.
Discussion
This method must be called from the main thread.
Declared In
ASTableNode.h
– indexPathsForVisibleRows
Similar to -[UITableView indexPathsForVisibleRows]
- (NSArray<NSIndexPath*> *)indexPathsForVisibleRows
Return Value
The value of this property is an array of NSIndexPath objects each representing a row index and section index that together identify a visible row in the table view. If no rows are visible, the value is nil.
Discussion
This method must be called from the main thread.
Declared In
ASTableNode.h