### Setup RealmStorage for Realm Data in Swift Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Datasources.md Shows how to set up RealmStorage for managing data models from Realm. It involves fetching objects from Realm and adding them to a section in the storage. ```swift let results = try! Realm().objects(Dog) let storage = RealmStorage() storage.addSection(with:results) ``` -------------------------------- ### Start Managing Table View Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewManager.html Starts managing the table view with the provided delegate. This method should be called before modifying storage or registering cells if the UITableView instance is created after the manager. ```Swift open func startManaging(withDelegate delegate: DTTableViewManageable) ``` -------------------------------- ### Setup SingleSectionEquatableStorage with Differ in Swift Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Datasources.md Illustrates setting up SingleSectionEquatableStorage, which manages data for a single section and calculates UI updates using a provided differ. It shows initialization with items and a differ, setting items, and adding new items. ```swift let storage = SingleSectionEquatableStorage(items: arrayOfPosts, differ: ChangesetDiffer()) storage.setItems(startingItems) manager.storage = storage storage.addItems(newItems) ``` -------------------------------- ### New Event Registration System with Method Pointers Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/CHANGELOG.md Implements a new system for registering events using method pointers, which automatically breaks retain cycles. This example shows cell selection handling. Other events like cellConfiguration, headerConfiguration, and footerConfiguration are also supported. ```swift manager.cellSelection(PostsViewController.selectedCell) func selectedCell(cell: PostCell, post: Post, indexPath: NSIndexPath) { // Do something, push controller probably? } ``` ```swift manager.cellSelection(self.dynamicType.selectedCell) ``` -------------------------------- ### Customizing Hosting Cell Appearance and Selection Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/SwiftUI.md Provides examples of customizing the appearance and selection behavior of `HostingTableViewCell`. This includes setting background colors for the cell, its content view, and the hosted SwiftUI view. It also shows how to enable default cell selection style. ```swift mapping.configuration.backgroundColor = customColor mapping.configuration.contentViewBackgroundColor = customColor mapping.configuration.hostingViewBackgroundColor = customColor mapping.configuration.selectionStyle = .default ``` -------------------------------- ### CocoaPods Installation for DTTableViewManager Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/README.md This code snippet shows the command to install the DTTableViewManager library using CocoaPods. It specifies the version to be installed, ensuring compatibility with other project dependencies. ```bash pod 'DTTableViewManager', '~> 11.0.0' ``` -------------------------------- ### Registering Cells from Code Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Registration.md Provides examples of registering UITableViewCell subclasses directly from code. ```APIDOC ## Registering Cells from Code ### Description Register `UITableViewCell` subclasses to be dequeued from code. If a XIB file with the same name as the cell class exists, it will be used by default. To ensure creation from code, explicitly set `xibName` to `nil` in the mapping closure. ### Method `register(_:)` or `register(_:for:mapping:handler:)` ### Endpoint N/A (This is a programmatic API call) ### Parameters N/A ### Request Example ```swift // Registering a cell class directly manager.register(TableViewCell.self) // Registering a cell class for a specific model, with a handler manager.register(UITableViewCell.self, for: Model.self) { cell, model, indexPath in // cell configuration logic } // Explicitly disabling XIB loading for a cell manager.register(TableViewCell.self) { mapping in mapping.xibName = nil } ``` ### Response N/A ``` -------------------------------- ### Implementing DTTableViewManageable in a View Controller Source: https://context7.com/dentelezhkin/dttableviewmanager/llms.txt Demonstrates how to adopt the DTTableViewManageable protocol in a UITableViewController to automate datasource and delegate management. It shows the basic setup of registering a cell and populating the memory storage with data models. ```swift import DTTableViewManager class PostsViewController: UITableViewController, DTTableViewManageable { override func viewDidLoad() { super.viewDidLoad() manager.register(PostCell.self) manager.memoryStorage.setItems([ Post(title: "Hello World", author: "John"), Post(title: "Swift Tips", author: "Jane") ]) } } class PostCell: UITableViewCell, ModelTransfer { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var authorLabel: UILabel! func update(with model: Post) { titleLabel.text = model.title authorLabel.text = model.author } } struct Post { let title: String let author: String } ``` -------------------------------- ### Swift: Replacing Deprecated Registration Methods Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/8.0 Migration Guide.md Provides examples of how to replace deprecated cell registration methods with the new unified 'register' method. This includes migrating from 'registerNibless' and 'registerNibNamed' to the more versatile registration API. ```swift // Old manager.registerNibless(PostCell.self) // New manager.register(PostCell.self) // Old manager.registerNibNamed("FooCell", for: PostCell.self) // New manager.register(PostCell.self) { mapping in mapping.xibName = "FooCell" } ``` -------------------------------- ### Setting TableViewUpdater Animation and Update Callbacks Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/5.0 migration guide.md Illustrates how to configure animation options and define callbacks for the start and end of content updates within a TableViewUpdater. This provides hooks for custom logic before and after the table view is updated. ```swift updater.insertRowAnimation = UITableViewRowAnimation.automatic updater.willUpdateContent = { update in // prepare for updating } updater.didUpdateContent = { update in // update finished } ``` -------------------------------- ### Configure Context Menu and Preview Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewManager.html Methods to set up context menu configurations and preview providers for table view cells. These methods allow for custom interactions when a user interacts with a cell. ```Swift open func contextMenuConfiguration(for cellClass: Cell.Type, _ closure: @escaping (CGPoint, Cell, Cell.ModelType, IndexPath) -> UIContextMenuConfiguration?) where Cell: UITableViewCell open func previewForHighlightingContextMenu(_ closure: @escaping (UIContextMenuConfiguration) -> UITargetedPreview?) open func previewForDismissingContextMenu(_ closure: @escaping (UIContextMenuConfiguration) -> UITargetedPreview?) ``` -------------------------------- ### Registering UIHostingConfiguration for iOS 16+ Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/SwiftUI.md Demonstrates the recommended approach for integrating SwiftUI views with table and collection views on iOS 16 and later using `UIHostingConfiguration`. This method is officially supported by Apple and provides a more robust integration. ```swift manager.registerHostingConfiguration(for: Post.self) { cell, post, indexPath in UIHostingConfiguration { PostView(post: post) } } ``` -------------------------------- ### Get Core Data Updater Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewManager.html Returns a TableViewUpdater configured for CoreDataStorage and NSFetchResultsController updates. This is useful for handling Core Data changes. ```Swift open func coreDataUpdater() -> TableViewUpdater ``` -------------------------------- ### UITableViewDelegate: didBeginMultipleSelectionInteractionAt Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewDelegate.html Handles the beginning of multiple selection interaction. This method is part of the UITableViewDelegate protocol and is called when multiple row selections have started. ```Swift open func tableView(_ tableView: UITableView, didBeginMultipleSelectionInteractionAt indexPath: IndexPath) ``` -------------------------------- ### Initializing DTTableViewManager Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/4.0 Migration Guide.md Shows how to integrate the manager into a UIViewController using the DTTableViewManageable protocol and initializing it in viewDidLoad. ```swift class PostsViewController: UITableViewController, DTTableViewManageable {} override func viewDidLoad() { super.viewDidLoad() manager.startManagingWithDelegate(self) manager.registerCellClass(PostCell) manager.memoryStorage.addItems(posts) } ``` -------------------------------- ### Register Drag Session Will Begin Handler (Swift) Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewManager.html Registers a closure to be executed when the UITableViewDragDelegate.tableView(_:dragSessionWillBegin:) method is called. This handler is invoked just before a drag session starts. ```Swift open func dragSessionWillBegin(_ closure: @escaping (UIDragSession) -> Void) ``` -------------------------------- ### Get Update Cell Closure Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewManager.html Returns a closure that updates a cell at a given indexPath. This is used by the coreDataUpdater method for silently updating cells without reload animations. ```Swift open func updateCellClosure() -> (IndexPath, Any) -> Void ``` -------------------------------- ### Registering Views from XIB Files Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Registration.md Explains how to register views using XIB files, where the XIB name defaults to the class name. Custom XIB names can be specified within the mapping closure. ```swift manager.register(PostCell.self) manager.register(PostCell.self) { mapping in mapping.xibName = "CustomPostCell" } ``` -------------------------------- ### Registering Cells, Headers, and Footers from Code Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Registration.md Shows how to register table view cells, headers, and footers when they are defined in code. It also demonstrates how to force code-based creation by setting xibName to nil. ```swift manager.register(TableViewCell.self) manager.register(UITableViewCell.self, for: Model.self) { cell, model, indexPath in } manager.registerHeader(HeaderView.self) manager.registerHeader(UITableViewHeaderFooterView.self, for: Model.self) { view, model, indexPath in } manager.registerFooter(FooterView.self) manager.registerFooter(UITableViewHeaderFooterView.self, for: Model.self) { view, model, indexPath in } manager.register(TableViewCell.self) { mapping in mapping.xibName = nil } ``` -------------------------------- ### Register Drag Session Lifecycle Callbacks Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/docsets/DTTableViewManager.docset/Contents/Resources/Documents/Classes/DTTableViewManager.html Methods to register closures for various drag session lifecycle events including start, end, move operations, and application restrictions. ```Swift open func dragSessionWillBegin(_ closure: @escaping (UIDragSession) -> Void) open func dragSessionDidEnd(_ closure: @escaping (UIDragSession) -> Void) open func dragSessionAllowsMoveOperation(_ closure: @escaping (UIDragSession) -> Bool) open func dragSessionIsRestrictedToDraggingApplication(_ closure: @escaping (UIDragSession) -> Bool) ``` -------------------------------- ### Configuration Methods Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/docsets/DTTableViewManager.docset/Contents/Resources/Documents/Classes/DTTableViewManager.html Methods for configuring cells, headers, and footers with their respective models. ```APIDOC ## configure ### Description Configures a cell class with a closure that provides the cell, its model, and the index path. ### Method Swift Function ### Parameters - **cellClass** (T.Type) - Required - The class of the cell. - **closure** (Closure) - Required - The configuration block: (T, T.ModelType, IndexPath) -> Void ### Request Example manager.configure(MyCell.self) { cell, model, indexPath in cell.update(with: model) } ``` -------------------------------- ### Access Supplementary Storage in Swift Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Datasources.md Provides an example of accessing the supplementary storage in DTTableViewManager to set section header models. This accessor works with any storage implementing the SupplementaryStorage protocol. ```swift manager.supplementaryStorage?.setSectionHeaderModels([1]) ``` -------------------------------- ### Registering Headers/Footers from Code Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Registration.md Shows how to register UITableViewHeaderFooterView subclasses from code. ```APIDOC ## Registering Headers/Footers from Code ### Description Register `UITableViewHeaderFooterView` subclasses to be dequeued from code. Similar to cells, XIB files are automatically considered if they match the class name. ### Method `registerHeader(_:)`, `registerHeader(_:for:mapping:handler:)`, `registerFooter(_:)`, `registerFooter(_:for:mapping:handler:)` ### Endpoint N/A (This is a programmatic API call) ### Parameters N/A ### Request Example ```swift // Registering a header view class manager.registerHeader(HeaderView.self) // Registering a header view for a specific model, with a handler manager.registerHeader(UITableViewHeaderFooterView.self, for: Model.self) { view, model, indexPath in // view configuration logic } // Registering a footer view class manager.registerFooter(FooterView.self) // Registering a footer view for a specific model, with a handler manager.registerFooter(UITableViewHeaderFooterView.self, for: Model.self) { view, model, indexPath in // view configuration logic } ``` ### Response N/A ``` -------------------------------- ### Handling MemoryStorageError in DTTableViewManager Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/5.0 migration guide.md Demonstrates the new error handling model in DTTableViewManager 5.x, which adopts SE-0112 for NSError bridging. This example shows how to catch and handle specific MemoryStorageError exceptions. ```swift do { try manager.memoryStorage.insertItem("Foo", at: NSIndexPath(item:0,section:0))} catch let error as MemoryStorageError { print(error.localizedDescription) } ``` -------------------------------- ### Context Menu Configurations Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewManager.html Methods for configuring context menus for cells, including previewing and dismissing. ```APIDOC ## previewForHighlightingContextMenu(_:) ### Description Configures a preview for highlighting a context menu. ### Method `open func previewForHighlightingContextMenu(_ closure: @escaping (UIContextMenuConfiguration) -> UITargetedPreview?)` ### Endpoint N/A (Method within a class) ### Parameters - **closure** ( (UIContextMenuConfiguration) -> UITargetedPreview? ) - Required - A closure that returns a `UITargetedPreview` for highlighting. ## previewForDismissingContextMenu(_:) ### Description Configures a preview for dismissing a context menu. ### Method `open func previewForDismissingContextMenu(_ closure: @escaping (UIContextMenuConfiguration) -> UITargetedPreview?)` ### Endpoint N/A (Method within a class) ### Parameters - **closure** ( (UIContextMenuConfiguration) -> UITargetedPreview? ) - Required - A closure that returns a `UITargetedPreview` for dismissing. ``` -------------------------------- ### Configuration Properties Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/docsets/DTTableViewManager.docset/Contents/Resources/Documents/Structs/TableViewConfiguration.html API documentation for managing table view header and footer height configurations. ```APIDOC ## Property: semanticFooterHeight ### Description Controls whether self-sizing table view footers are used. Set to false to improve performance when using estimated footer heights. ### Type Bool ## Property: minimalHeaderHeightForTableView ### Description Defines the minimal header height to hide the header when a section is empty. ### Type (UITableView) -> CGFloat ## Property: minimalFooterHeightForTableView ### Description Defines the minimal footer height to hide the footer when a section is empty. ### Type (UITableView) -> CGFloat ``` -------------------------------- ### Registering Custom Cells in Swift Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/README.md This snippet demonstrates how to create a custom UITableViewCell subclass that conforms to the ModelTransfer protocol and how to register it with DTTableViewManager in a view controller. It shows the basic setup for displaying custom cells with data. ```swift class PostCell : UITableViewCell, ModelTransfer { func update(with model: Post) { // Fill your cell with actual data } } class PostsViewController: UITableViewController, DTTableViewManageable { override func viewDidLoad() { super.viewDidLoad() // Register PostCell to be used with this controller's table view manager.register(PostCell.self) // Populate datasource manager.memoryStorage.setItems(posts) } } ``` -------------------------------- ### Integrate SwiftUI with UIHostingConfiguration in UITableView (Swift) Source: https://context7.com/dentelezhkin/dttableviewmanager/llms.txt Demonstrates integrating SwiftUI views into `UITableView` cells using `UIHostingConfiguration` for iOS 16+. It shows both basic configuration and advanced usage with cell state management (selection, highlighting) and interaction callbacks. Requires the `dttableviewmanager` library. ```swift @available(iOS 16.0, *) class HostingConfigurationViewController: UIViewController, DTTableViewManageable { @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() // Basic hosting configuration manager.registerHostingConfiguration(for: Task.self) { cell, task, indexPath in UIHostingConfiguration { TaskRowView(task: task) } .margins(.horizontal, 16) } // With cell configuration state (selection, highlighting, etc.) manager.registerHostingConfiguration(for: Task.self) { state, cell, task, indexPath in UIHostingConfiguration { TaskRowView( task: task, isSelected: state.isSelected, isHighlighted: state.isHighlighted ) } .margins(.all, 12) .background { RoundedRectangle(cornerRadius: 8) .fill(state.isSelected ? Color.blue.opacity(0.1) : Color.clear) } } mapping: { mapping.didSelect { cell, task, indexPath in print("Selected task: \(task.title)") } } manager.memoryStorage.setItems(tasks) } } struct TaskRowView: View { let task: Task var isSelected: Bool = false var isHighlighted: Bool = false var body: some View { HStack { Image(systemName: task.isCompleted ? "checkmark.circle.fill" : "circle") .foregroundColor(task.isCompleted ? .green : .gray) VStack(alignment: .leading) { Text(task.title) .strikethrough(task.isCompleted) Text(task.dueDate, style: .date) .font(.caption) .foregroundColor(.secondary) } } } } ``` -------------------------------- ### Handling Events Without View Instances Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Events.md Illustrates how to handle delegate methods where the cell or view is not yet created, using a signature that only includes the model and index path. ```swift mapping.heightForCell { model, indexPath in return 44 } ``` -------------------------------- ### Registering Views from Storyboard Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Registration.md Details how to register views designed in a Storyboard. ```APIDOC ## Registering Views from Storyboard ### Description Register reusable views that are designed within a Storyboard. The syntax for registration is the same as for code-based or XIB-based registrations. ### Method `register(_:)`, `register(_:for:mapping:handler:)`, `registerHeader(_:)`, etc. ### Endpoint N/A (This is a programmatic API call) ### Parameters N/A ### Request Example ```swift // Assuming 'MyCell' is a cell prototype in a storyboard with the identifier 'MyCell' // DTTableViewManager will automatically handle loading from the storyboard if configured correctly. // The exact mechanism might depend on how the storyboard is loaded into the table view. // Typically, you'd register the cell class and ensure the storyboard is loaded and the cell identifier matches. manager.register(MyCell.self) // For headers/footers, similar principles apply if they are set up as prototypes in a storyboard. manager.registerHeader(MyHeaderView.self) ``` ### Response N/A ``` -------------------------------- ### Swift: Unified Cell Registration with Handler Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/8.0 Migration Guide.md Demonstrates the new unified cell registration method in Swift, which supports both xib-less and xib-based registration. It includes a handler closure for cell configuration, replacing the deprecated 'configureCell' closure. ```swift manager.register(PostCell.self) { mapping in // customize mapping } handler: { cell, model, indexPath in // configure cell with model. } ``` -------------------------------- ### static func dt_loadFromXib() Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Extensions/UIView.html Loads a view from a XIB file using the class name as the XIB name. ```APIDOC ## static func dt_loadFromXib() ### Description Loads a view from a XIB file using the String representation of the class name in the bundle for the current class. ### Method Static Function ### Response - **UIView?** - Returns the loaded UIView instance if successful, otherwise nil. ``` -------------------------------- ### Handling Matching Reuse Identifiers with Custom Identifiers (Swift) Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Conditional mappings.md This example addresses a limitation where multiple mappings for the same cell class might use the same reuse identifier, causing conflicts. It demonstrates the fix by assigning a custom `reuseIdentifier` to differentiate mappings targeting different sections with potentially different cell designs. ```swift manager.register(PostCell.self) { mapping in mapping.condition = .section(0) } mapping.register(PostCell.self) { mapping in mapping.condition = .section(1) mapping.xibName = "CustomPostCell" mapping.reuseIdentifier = "custom-post-cell" } ``` -------------------------------- ### Swift: Inserting Items into MemoryStorage Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/8.0 Migration Guide.md Shows how to use the new 'insertItems(_:at:)' method in MemoryStorage to insert a collection of items at a specific index path. This is useful for dynamic content loading, such as inserting new pages of data. ```swift try? manager.memoryStorage.insertItems(newPosts, at: IndexPath(item: self.numberOfItems - 1, section: 0)) ``` -------------------------------- ### Register Headers and Footers Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Mapping.md Demonstrates how to register header or footer views with or without the ModelTransfer protocol. ```swift manager.registerHeader(HeaderFooterView.self, ofKind: "Header") manager.registerHeader(UITableViewHeaderFooterView.self, for: String.self) { header, model, indexPath in } ``` -------------------------------- ### Configure Context Menus for Table View Rows Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/docsets/DTTableViewManager.docset/Contents/Resources/Documents/Classes/DTTableViewDelegate.html Implements methods for configuring and previewing context menus for table view rows: `tableView(_:contextMenuConfigurationForRowAt:point:)`, `tableView(_:previewForHighlightingContextMenuWithConfiguration:)`, and `tableView(_:previewForDismissingContextMenuWithConfiguration:)`. These allow for rich, interactive menus to be displayed on row interaction. ```Swift open func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? ``` ```Swift open func tableView(_ tableView: UITableView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? ``` ```Swift open func tableView(_ tableView: UITableView, previewForDismissingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? ``` -------------------------------- ### Customize UIHostingController for SwiftUI Cells Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/SwiftUI.md Shows how to create a custom UIHostingController subclass to override default behaviors like navigation bar appearance, and how to inject it into the DTTableViewManager mapping configuration. ```swift class ControlledNavigationHostingController: UIHostingController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) navigationController?.isNavigationBarHidden = true } } manager.registerHostingCell(for: Post.self) { model, _ in PostSwiftUICell(model: model) } mapping: { mapping in mapping.configuration.hostingControllerMaker = { ControlledNavigationHostingController(rootView: $0) } } ``` -------------------------------- ### Update Cell Event Registration (Deprecated vs. Recommended) Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/CHANGELOG.md Demonstrates the shift from direct cell event registration to using mapping closures for event handling. The recommended approach ensures compatibility with SwiftUI cells and future delegate method additions. ```swift manager.register(PostCell.self) manager.didSelect(PostCell.self) { postCell, post, indexPath in } ``` ```swift manager.register(PostCell.self) { mapping in mapping.didSelect { postCell, post, indexPath in } } ``` -------------------------------- ### Configure TableViewManager settings Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/4.0 Migration Guide.md Demonstrates how to access and modify configuration properties like displayHeaderOnEmptySection through the manager's configuration property. ```swift manager.configuration.displayHeaderOnEmptySection = false ``` -------------------------------- ### Configure Anomaly Handler Actions Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewManagerAnomalyHandler.html Demonstrates how to access and modify the default and instance-specific anomaly handling actions in Swift. ```swift // Set a global default action for all anomalies DTTableViewManagerAnomalyHandler.defaultAction = { anomaly in print("Global Anomaly Detected: \(anomaly)") } // Initialize and customize a specific handler instance let handler = DTTableViewManagerAnomalyHandler() handler.anomalyAction = { anomaly in // Custom logic for handling specific anomalies print("Instance specific handling: \(anomaly)") } ``` -------------------------------- ### Implementing UITableViewDelegate Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Events.md How to conform to UITableViewDelegate and implement methods within a DTTableViewManageable controller. ```APIDOC ## Implementing UITableViewDelegate ### Description To use standard delegate methods, simply conform your view controller to `UITableViewDelegate` and implement the required methods. DTTableViewManager will automatically detect these and redirect calls to your implementation. ### Usage ```swift class PostsViewController: UIViewController, DTTableViewManageable, UITableViewDelegate { override func viewDidLoad() { super.viewDidLoad() manager.register(PostCell.self) manager.memoryStorage.setItems(posts) } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { // React to cell selection } } ``` ### Priority Logic 1. Execute event if cell and model type satisfy requirements. 2. Call delegate or datasource method on `DTTableViewManageable` instance. 3. Fallback to default `UITableView` behavior. ``` -------------------------------- ### UITableViewDelegate: previewForHighlightingContextMenu Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewDelegate.html Provides a preview for highlighting the context menu. This method is part of the UITableViewDelegate protocol and is used to customize the visual appearance of the context menu when it's highlighted. ```Swift open func tableView(_ tableView: UITableView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? ``` -------------------------------- ### static func dt_loadFromXibNamed(_:) Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Extensions/UIView.html Loads a view from a specific XIB file name located in the bundle of the current class. ```APIDOC ## static func dt_loadFromXibNamed(_:) ### Description Loads a view from a XIB file with the specified name in the bundle for the current class. ### Method Static Function ### Parameters #### Arguments - **xibName** (String) - Required - The name of the XIB file to load. ### Response - **UIView?** - Returns the loaded UIView instance if successful, otherwise nil. ``` -------------------------------- ### Context Menu Configuration Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/docsets/DTTableViewManager.docset/Contents/Resources/Documents/Classes/DTTableViewManager.html Methods for handling UIContextMenuConfiguration for table view cells. ```APIDOC ## contextMenuConfiguration ### Description Sets up a context menu configuration for a specific cell class. ### Method Swift Function ### Parameters - **cellClass** (Cell.Type) - Required - The class of the cell. - **closure** (Closure) - Required - The configuration block returning UIContextMenuConfiguration. ``` -------------------------------- ### Implement UITableViewDelegate Methods Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewDelegate.html A collection of standard UITableViewDelegate methods for managing row interactions, display lifecycle, and swipe configurations. ```Swift open func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool open func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) open func tableView(_ tableView: UITableView, didEndDisplayingHeaderView view: UIView, forSection section: Int) open func tableView(_ tableView: UITableView, didEndDisplayingFooterView view: UIView, forSection section: Int) open func tableView(_ tableView: UITableView, shouldShowMenuForRowAt indexPath: IndexPath) -> Bool open func tableView(_ tableView: UITableView, canPerformAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) -> Bool open func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) open func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool open func tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath) open func tableView(_ tableView: UITableView, didUnhighlightRowAt indexPath: IndexPath) open func tableView(_ tableView: UITableView, canFocusRowAt indexPath: IndexPath) -> Bool open func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? open func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? ``` -------------------------------- ### Configure View Models and Events Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewManager.html Methods to bind model data to cells, headers, and footers, and to configure event handlers for specific view types. ```Swift func configure(_ cellClass: T.Type, _ closure: @escaping (T, T.ModelType, IndexPath) -> Void) where T : UITableViewCell, T : ModelTransfer func configureHeader(_ headerClass: T.Type, _ closure: @escaping (T, T.ModelType, Int) -> Void) where T : UIView, T : ModelTransfer func configureFooter(_ footerClass: T.Type, _ closure: @escaping (T, T.ModelType, Int) -> Void) where T : UIView, T : ModelTransfer func configureEvents(for klass: T.Type, _ closure: (T.Type, T.ModelType.Type) -> Void) where T : ModelTransfer ``` -------------------------------- ### Event Handling with Closures Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/4.0 Migration Guide.md Explains the new event handling API using closures for cell configuration, selection, and content updates. ```APIDOC ## Reacting to Events ### Description Introduces the event handling API in `DTTableViewManager` 4.x, which uses closures to manage various table view events, replacing the `DTTableViewControllerEvents` protocol. ### Cell Configuration: ```swift manager.configureCell(PostCell.self) { postCell, post, indexPath in // Configure PostCell at concrete indexPath } ``` ### Cell Selection: ```swift manager.whenSelected(PostCell.self) { postCell, post, indexPath in // Some action } ``` ### Combined Registration and Selection: ```swift manager.registerCellClass(PostCell.self, whenSelected: { postCell, post, indexPath in }) ``` ### Content Update Events: ```swift manager.beforeContentUpdate {} manager.afterContentUpdate {} ``` **Important:** Remember to use `weak self` in capture lists for closures to avoid retain cycles. ``` -------------------------------- ### Registering Views with DTTableViewManager Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Registration.md Demonstrates the basic registration syntax for views with and without the ModelTransfer protocol. The mapping closure allows for customization of registration parameters like XIB names. ```swift manager.register(View.self) { mapping in } handler: { view, model, indexPath in } manager.register(View.self, for: Model.self) { mapping in } handler: { view, model, indexPath in } ``` -------------------------------- ### Configure TableView Swipe Actions Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/docsets/DTTableViewManager.docset/Contents/Resources/Documents/Classes/DTTableViewDelegate.html Provides configurations for leading and trailing swipe actions on table view rows. ```swift open func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? open func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? ``` -------------------------------- ### Implementing Conditional Cell Mappings Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/6.0 Migration Guide.md Demonstrates how to register cells with specific conditions based on sections or custom logic to replace legacy mapping protocols. ```swift manager.register(FirstSectionCell.self) { mapping in mapping.condition = .section(0) } manager.register(SectionSectionCell.self) { mapping in mapping.condition = .section(1) } ``` -------------------------------- ### Registration Methods Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/docsets/DTTableViewManager.docset/Contents/Resources/Documents/Classes/DTTableViewManager.html Methods for registering nibs and classes for table view cells, headers, and footers. ```APIDOC ## registerNibNamed ### Description Registers a nib for a specific cell, header, or footer class. ### Method Swift Function ### Parameters - **nibName** (String) - Required - The name of the nib file. - **cellClass** (T.Type) - Required - The class of the cell. - **mapping** (Closure) - Optional - Configuration mapping for the view model. ### Request Example manager.registerNibNamed("MyCell", for: MyCell.self) ``` -------------------------------- ### Leading Swipe Actions Configuration Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewDelegate.html Provides the configuration for swipe actions that appear on the leading edge of a row. ```APIDOC ## UITableViewDelegate tableView(_:leadingSwipeActionsConfigurationForRowAt:) ### Description Asks the delegate for the configuration of swipe actions that appear on the leading edge (left side for left-to-right languages) of a row. This allows customization of swipe gestures. ### Method `open func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?` ### Endpoint N/A (Delegate Method) ### Parameters - **tableView** (UITableView) - The table view requesting the configuration. - **indexPath** (IndexPath) - The index path of the row. ### Response #### Success Response (UISwipeActionsConfiguration?) - **UISwipeActionsConfiguration?** - An object that configures the swipe actions, or `nil` if no actions should be displayed. ### Response Example ```swift let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { (action, view, completionHandler) in // Handle delete action completionHandler(true) } return UISwipeActionsConfiguration(actions: [deleteAction]) ``` ``` -------------------------------- ### Using UICellConfigurationState with UIHostingConfiguration Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/SwiftUI.md Illustrates how to access and utilize the `UICellConfigurationState` within a `UIHostingConfiguration` closure. This enables the SwiftUI view to adapt its appearance based on the cell's state, such as whether it is selected. ```swift manager.registerHostingConfiguration(for: Post.self) { state, cell, post, indexPath in UIHostingConfiguration { PostView(post: post, isSelected: state.isSelected) } } ``` -------------------------------- ### Swift: Deprecated vs. New Cell Configuration Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/8.0 Migration Guide.md Compares the old method of configuring cells using separate 'configureCell' calls with the new approach using a 'handler' closure directly within the registration method. The new syntax is preferred for its conciseness. ```swift // previous releases manager.register(PostCell.self) manager.configureCell(PostCell.self) { cell, model, indexPath in cell.selectionStyle = .none } // 8.x release manager.register(PostCell.self) { cell, model, indexPath in cell.selectionStyle = .none } ``` -------------------------------- ### Configuration Properties Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Structs/TableViewConfiguration.html API properties for managing table view section header and footer sizing and visibility logic. ```APIDOC ## Configuration Properties ### semanticFooterHeight - **Description**: Controls self-sizing table view footer behavior. Set to false to optimize performance when using estimated footer heights. - **Type**: Bool ### minimalHeaderHeightForTableView - **Description**: Defines a closure to determine the minimal header height required to hide the header when a section is empty. - **Type**: (UITableView) -> CGFloat ### minimalFooterHeightForTableView - **Description**: Defines a closure to determine the minimal footer height required to hide the footer when a section is empty. - **Type**: (UITableView) -> CGFloat ### Usage Example ```swift // Example configuration manager.configuration.semanticFooterHeight = false manager.configuration.minimalHeaderHeightForTableView = { tableView in return .zero } ``` ``` -------------------------------- ### Implementing Delegate Methods for Hosted Cells Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/SwiftUI.md Shows how to implement standard `UITableViewDelegate` methods, such as `willDisplay`, when using SwiftUI hosted cells with `dttableviewmanager`. This ensures that delegate callbacks are correctly forwarded and can be utilized for cell-specific logic. ```swift manager.registerHostingCell(for: Post.self) { model, _ in PostSwiftUICell(model: model) } mapping: { mapping in mapping.willDisplay { cell, model, indexPath in } } ``` -------------------------------- ### Configure Header and Footer Visibility Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/TableViewConfiguration.md Controls whether section headers and footers are displayed when their associated data models are nil. Setting these properties to false hides empty sections. ```swift manager.configuration.displayHeaderOnEmptySections = false manager.configuration.displayFooterOnEmptySections = false ``` -------------------------------- ### Configure UITableView Animations and Lifecycle Hooks Source: https://context7.com/dentelezhkin/dttableviewmanager/llms.txt Demonstrates how to customize row and section animations, manage off-screen animation behavior, and hook into update lifecycle events using the tableViewUpdater property. ```swift class CustomAnimationsViewController: UIViewController, DTTableViewManageable { @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() manager.register(AnimatedCell.self) // Configure animations manager.tableViewUpdater?.insertRowAnimation = .fade manager.tableViewUpdater?.deleteRowAnimation = .left manager.tableViewUpdater?.reloadRowAnimation = .none manager.tableViewUpdater?.insertSectionAnimation = .top manager.tableViewUpdater?.deleteSectionAnimation = .bottom manager.tableViewUpdater?.reloadSectionAnimation = .fade // Disable animations when table view is off-screen manager.tableViewUpdater?.animateChangesOffScreen = false // Custom reload behavior (update cell without animation) manager.tableViewUpdater?.reloadRowClosure = manager.updateCellClosure() // Hooks for update lifecycle manager.tableViewUpdater?.willUpdateContent = { update in print("Will update content") } manager.tableViewUpdater?.didUpdateContent = { update in print("Did update content") } } } ``` -------------------------------- ### Registering Views from XIB Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Registration.md Explains how DTTableViewManager automatically uses XIB files for view registration and how to specify custom XIB names. ```APIDOC ## Registering Views from XIB ### Description Register reusable views using XIB files. By default, `DTTableViewManager` looks for a XIB file with the same name as the registered view class. You can specify a different XIB file name in the mapping closure. ### Method `register(_:mapping:)` or `register(_:for:mapping:)` ### Endpoint N/A (This is a programmatic API call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```swift // If "PostCell.xib" exists, it will be used automatically manager.register(PostCell.self) // If "CustomPostCell.xib" exists, it will be used manager.register(PostCell.self) { mapping in mapping.xibName = "CustomPostCell" } // For headers/footers inheriting from UIView (not UITableViewHeaderFooterView) // They will also be loaded from XIB with the specified name. // Note: Event attachment is not supported for these custom UIView registrations. manager.registerHeader(MyCustomHeaderView.self) { mapping in mapping.xibName = "MyCustomHeader" } ``` ### Response N/A ``` -------------------------------- ### Registering Event Closures with ViewModelMapping Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/8.0 Migration Guide.md Demonstrates the new event registration syntax where events are defined within a mapping closure, allowing for scoped event handling based on mapping conditions. ```swift manager.register(PostCell.self) { mapping in mapping.didSelect { cell, model, indexPath in // tableView(_:didSelectRowAt:) } mapping.willDisplay { cell, model, indexPath in // tableView(_:willDisplay:forRowAt:) } } manager.register(PostCell.self) { mapping in mapping.condition = .section(0) mapping.didSelect { cell, model, indexPath in // Only called for section 0 } } ``` -------------------------------- ### MemoryStorage Data Manipulation Operations in Swift Source: https://context7.com/dentelezhkin/dttableviewmanager/llms.txt Demonstrates various methods for manipulating table view data using MemoryStorage, such as setting all items, setting items for specific sections, adding new items, inserting items at specific index paths, removing items, moving items, and reloading items. It also shows how to access items and retrieve counts. ```swift class DataManipulationViewController: UIViewController, DTTableViewManageable { @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() manager.register(ItemCell.self) } // Set all items (replaces existing) func setAllItems() { manager.memoryStorage.setItems([item1, item2, item3]) } // Set items for specific section func setSectionItems() { manager.memoryStorage.setItems([item1, item2], forSection: 0) manager.memoryStorage.setItems([item3, item4], forSection: 1) } // Add items to end func addItems() { manager.memoryStorage.addItems([newItem1, newItem2]) manager.memoryStorage.addItems([newItem3], toSection: 1) } // Insert item at specific index path func insertItem() { manager.memoryStorage.insertItem(newItem, to: IndexPath(row: 0, section: 0)) } // Remove items func removeItems() { // Remove specific items manager.memoryStorage.removeItems([item1, item2]) // Remove at index paths manager.memoryStorage.removeItems(at: [IndexPath(row: 0, section: 0)]) // Remove all items manager.memoryStorage.removeAllItems() } // Move items func moveItem() { let from = IndexPath(row: 0, section: 0) let to = IndexPath(row: 2, section: 0) manager.memoryStorage.moveItem(at: from, to: to) // Move without animation (useful in move delegate callbacks) manager.memoryStorage.moveItemWithoutAnimation(from: from, to: to) } // Update/reload items func reloadItem() { manager.memoryStorage.reloadItem(item1) } // Access items func accessItems() { // Get item at index path let item = manager.memoryStorage.item(at: IndexPath(row: 0, section: 0)) // Get all items in section let sectionItems = manager.memoryStorage.items(inSection: 0) // Get number of sections let sectionCount = manager.memoryStorage.numberOfSections() // Get number of items in section let itemCount = manager.memoryStorage.numberOfItems(inSection: 0) } } ``` -------------------------------- ### Update Memory Storage Items Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/CHANGELOG.md Demonstrates the method rename for adding items to memory storage, moving from a table-specific naming convention to a more generic one. ```objective-c // Old method signature -(void)addTableItems:(NSArray *)items; // New method signature -(void)addItems:(NSArray *)items; ``` -------------------------------- ### Register Menu and Action Callbacks Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/docsets/DTTableViewManager.docset/Contents/Resources/Documents/Classes/DTTableViewManager.html Methods to manage menu visibility and perform actions on table view cells. These enable interaction with specific cell types and their associated models. ```swift open func shouldShowMenu(for cellClass: Cell.Type, _ closure: @escaping (Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UITableViewCell, Cell : ModelTransfer open func canPerformAction(for cellClass: Cell.Type, _ closure: @escaping (Selector, Any?, Cell, Cell.ModelType, IndexPath) -> Bool) where Cell : UITableViewCell, Cell : ModelTransfer open func performAction(for cellClass: Cell.Type, _ closure: @escaping (Selector, Any?, Cell, Cell.ModelType, IndexPath) -> Void) where Cell : UITableViewCell, Cell : ModelTransfer ``` -------------------------------- ### Load UIView from XIB by Name Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Extensions/UIView.html Loads a UIView instance from a XIB file with a specific name located in the bundle of the current class. Returns an optional UIView if the loading is successful. ```swift static func dt_loadFromXibNamed(_ xibName: String) -> UIView? ``` -------------------------------- ### Register SwiftUI Views as TableView Cells Source: https://context7.com/dentelezhkin/dttableviewmanager/llms.txt Shows how to use HostingTableViewCell to render SwiftUI views inside a UIKit UITableView. It includes configuration for estimated height, appearance, and custom hosting controller injection. ```swift class SwiftUIHostingViewController: UIViewController, DTTableViewManageable { @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView.rowHeight = UITableView.automaticDimension manager.registerHostingCell(for: Contact.self) { contact, indexPath in ContactSwiftUIView(contact: contact) } mapping: { mapping in mapping.estimatedHeightForCell { contact, indexPath in return 80 } mapping.configuration.backgroundColor = .systemBackground mapping.configuration.selectionStyle = .none mapping.configuration.hostingControllerMaker = { rootView in CustomHostingController(rootView: rootView) } } manager.memoryStorage.setItems(contacts) } } ``` -------------------------------- ### Initialize and Set Items with MemoryStorage in Swift Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Datasources.md Demonstrates how to use MemoryStorage, the default storage for DTTableViewManager, to set items in memory. MemoryStorage provides methods for adding, inserting, removing, replacing, moving, and searching items. ```swift manager.memoryStorage.setItems([1,2,3]) ``` -------------------------------- ### Configuring Cells and Handling Events Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/4.0 Migration Guide.md Utilizes the new event-based API to configure cells and handle selection events with type-safe closures. ```swift manager.configureCell(PostCell.self) { postCell, post, indexPath in // Configure PostCell at concrete indexPath } manager.whenSelected(PostCell.self) { postCell, post, indexPath in // Some action } manager.registerCellClass(PostCell.self, whenSelected: { postCell, post, indexPath in }) ``` -------------------------------- ### Customizing UIHostingConfiguration Margins Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/SwiftUI.md Shows how to customize the margins for the content within a `UIHostingConfiguration` used for table view cells. This allows for precise control over the spacing and layout of the SwiftUI view inside the cell. ```swift manager.registerHostingConfiguration(for: Post.self) { cell, post, indexPath in UIHostingConfiguration { PostView(post: post) }.margins(.horizontal, 16) } ``` -------------------------------- ### Registering Table View Cells Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/Documentation/Migration guides/4.0 Migration Guide.md Demonstrates the simplified registration syntax for cells in DTTableViewManager 4.0 compared to previous versions. ```swift // Old version: registerCellClass(PostCell.self, forModelClass: Post.self) // New version: manager.registerCellClass(PostCell) ``` -------------------------------- ### UITableViewDelegate: previewForDismissingContextMenu Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewDelegate.html Provides a preview for dismissing the context menu. This method is part of the UITableViewDelegate protocol and is used to customize the visual appearance of the context menu when it's dismissed. ```Swift open func tableView(_ tableView: UITableView, previewForDismissingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? ``` -------------------------------- ### Header and Footer Display Lifecycle Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/docsets/DTTableViewManager.docset/Contents/Resources/Documents/Extensions/ViewModelMapping.html Methods to hook into the display lifecycle of table view headers and footers. ```APIDOC ## Lifecycle Methods ### Description These methods register closures to be executed during the UITableViewDelegate lifecycle events for headers and footers. ### Methods - willDisplayHeaderView((View, Model, Int) -> Void) - willDisplayFooterView((View, Model, Int) -> Void) - didEndDisplayingHeaderView((View, Model, Int) -> Void) - didEndDisplayingFooterView((View, Model, Int) -> Void) ### Parameters - **closure** (escaping closure) - Required - A closure taking (View, Model, Int) to handle display events. ### Request Example manager.header(for: MyHeaderView.self).willDisplayHeaderView { view, model, section in print("Displaying header for section \(section)") } ``` -------------------------------- ### Handle Drop Placeholder Context Source: https://github.com/dentelezhkin/dttableviewmanager/blob/main/docs/Classes/DTTableViewManager.html Convenience method to drop items into a placeholder, returning a context that automatically handles insertion via MemoryStorage and dispatches to the main queue. ```Swift open func drop(_ item: UIDragItem, to placeholder: UITableViewDropPlaceholder, with coordinator: UITableViewDropCoordinator) -> DTTableViewDropPlaceholderContext ```