@@ -25,30 +25,24 @@ The following are deprecated and will be removed in a future version:
2525
2626| Deprecated | Replacement | Reason |
2727| ------------| -------------| --------|
28- | ` init(data:headerTitles:) ` | ` init(columns:) ` | No diffing support, manual array conversion |
2928| ` SwiftDataTableDataSource ` protocol | Direct data pattern | Boilerplate-heavy, no diffing |
3029| ` reload() ` method | ` setData(_:animatingDifferences:) ` | Resets scroll, no animations |
3130| ` .largeScale() ` | ` .automatic(estimated:prefetchWindow:) ` | Renamed for clarity |
3231| ` dataTable(_:highlightedColorForRowIndex:) ` | ` defaultCellConfiguration ` | More flexible per-cell styling |
3332| ` dataTable(_:unhighlightedColorForRowIndex:) ` | ` defaultCellConfiguration ` | More flexible per-cell styling |
3433
35- ### Array-Based Initializer
34+ ## Choosing an API
3635
37- The array-based initializer is deprecated because:
38- - No automatic diffing (can't track which rows changed)
39- - Manual conversion required (model → array)
40- - No type safety (easy to mix up column order)
36+ SwiftDataTables offers two approaches:
4137
42- ** Before (deprecated):**
38+ | Approach | Best For |
39+ | ----------| ----------|
40+ | ** Type-safe API** | Model-backed data, animated updates, dynamic content |
41+ | ** Array-based API** | Static displays, quick prototyping, schema-less data |
4342
44- ``` swift
45- let data: [[DataTableValueType]] = items.map { item in
46- [.string (item.name ), .int (item.age )]
47- }
48- let table = SwiftDataTable (data : data, headerTitles : [" Name" , " Age" ])
49- ```
43+ ### Type-Safe API (Recommended for Dynamic Data)
5044
51- ** After (recommended): **
45+ Use when you have model types and want animated updates:
5246
5347``` swift
5448let columns: [DataTableColumn<Item>] = [
@@ -59,7 +53,28 @@ let table = SwiftDataTable(columns: columns)
5953table.setData (items, animatingDifferences : true )
6054```
6155
62- For dynamic data (CSV, JSON, database queries), see < doc:WorkingWithData > .
56+ Benefits:
57+ - Animated diffing (insertions/deletions animate)
58+ - Type safety (compiler catches errors)
59+ - Scroll position preserved on updates
60+
61+ ### Array-Based API (Simple Static Displays)
62+
63+ Use for quick prototyping or truly static data:
64+
65+ ``` swift
66+ let data = [[" Alice" , " 25" ], [" Bob" , " 30" ]]
67+ let table = SwiftDataTable (data : data, headerTitles : [" Name" , " Age" ])
68+ ```
69+
70+ Benefits:
71+ - No model types required
72+ - Minimal setup for simple cases
73+ - Works with any data source
74+
75+ Note: Array-based tables don't support animated diffing - updates replace all content.
76+
77+ For dynamic data without predefined models (CSV, JSON, database queries), see < doc:WorkingWithData > .
6378
6479## Migration Path
6580
0 commit comments