Skip to content

Commit b968b29

Browse files
committed
updated
1 parent b956408 commit b968b29

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

Example/Example/OutlineSidebarViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class OutlineSidebarViewController: NSViewController {
6767

6868
let rootItems: [OutlineItem] = ["Root 1", "Root 2", "Root 3", "Root 4", "Root 5"]
6969
snapshot.append(rootItems)
70-
snapshot.expand(rootItems)
70+
7171
rootItems.forEach { rootItem in
7272
let childItems = (1...5).map { OutlineItem("\(rootItem.title).\($0)") }
7373
snapshot.append(childItems, to: rootItem)

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,31 @@ An extended `NSCollectionViewDiffableDataSource that provides:
165165

166166
## TableViewDiffableDataSource
167167

168-
Simliar to CollectionViewDiffableDataSource.
168+
Simliar to `CollectionViewDiffableDataSource`.
169169

170170
## OutlineViewDiffableDataSource
171+
172+
A diffable data source for `NSOutlineView` simliar to `CollectionViewDiffableDataSource`.
173+
174+
Example usage:
171175

172-
Simliar to CollectionViewDiffableDataSource.
176+
```swift
177+
let dataSource = OutlineViewDiffableDataSource<String>(outlineView: outlineView, cellRegistration: cellRegistration)
178+
179+
var snapshot = OutlineViewDiffableDataSourceSnapshot<String>()
180+
let rootItems ["Root 1", "Root 2", "Root 3", "Root 4", "Root 5"]
181+
snapshot.append(rootItems)
182+
183+
rootItems.forEach { rootItem in
184+
let childItems = (1...5).map { "\(rootItem).\($0)" }
185+
snapshot.append(childItems, to: rootItem)
186+
childItems.forEach { childItem in
187+
let grandchildItems = (1...5).map { "\(childItem).\($0)" }
188+
snapshot.append(grandchildItems, to: childItem)
189+
}
190+
}
191+
dataSource.apply(snapshot, .withoutAnimation)
192+
```
173193

174194
## Quicklook for NSTableView & NSCollectionView
175195

@@ -213,7 +233,7 @@ collectionViewItem.quicklookPreview = URL(fileURLWithPath: "someFile.png")
213233

214234
## Installation
215235

216-
Add `AdvancedCollectionTableView` to your app's `Package.swift` file, or selecting `File -> Add Package Dependencies` in Xcode:
236+
Add `AdvancedCollectionTableView` to your app's `Package.swift` file, or selecting `File -> Add Package Dependencies in Xcode:
217237

218238
```swift
219239
.package(url: "https://github.com/flocked/AdvancedCollectionTableView")

0 commit comments

Comments
 (0)