Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit a59ad08

Browse files
committed
- Added UIKit-Sharing to Readme
- Added Screenshots for Readme
1 parent 02ddb26 commit a59ad08

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

.github/README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ ExportManager.toCSVDocument(people) { result in
103103

104104
#### SwiftUI
105105

106+
To save the generated file from your SwiftUI-App in the file system, you need to use the `fileExporter()`-Modifier and reference the generated `CSVDocument` by calling `ExportManager.toCSVDocument(:_)`
107+
108+
<img src="assets/save_macos.jpeg" width="120">
109+
106110
```Swift
107111
struct ContentView: View {
108112
@State private var document: CSVDocument?
@@ -143,8 +147,30 @@ struct ContentView: View {
143147

144148
#### UIKit
145149

146-
```Swift
150+
For sharing and saving the file in your UIKit-App, you can use our `.share(:_)`-Function from any `UIViewController`. It creates and opens automatically an `UIActivityViewController`.
147151

148-
```
152+
<img src="assets/sharesheet_uikit.jpeg" width="120">
149153

154+
```Swift
155+
class ViewController: UIViewController {
156+
157+
func exportCSV() {
158+
let people: [Person]
150159

160+
// fill array with content
161+
162+
ExportManager.saveAsCSV(people, fileName: "MyCSVFile.csv") { result in
163+
switch result {
164+
case .success(let url):
165+
print("Saved successfully at \(url)")
166+
// Open ActivityViewController
167+
ExportManager.share(url: url, viewController: self) {
168+
// ShareSheet was closed
169+
}
170+
case .failure(let error):
171+
print(error.localizedDescription)
172+
}
173+
}
174+
}
175+
}
176+
```

.github/assets/save_macos.jpeg

16.6 KB
Loading

.github/assets/sharesheet_uikit.jpeg

439 KB
Loading

Sources/CSVCodable/ExportManager+UIKit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import UIKit
1212

1313
extension ExportManager {
1414
/**
15-
Opens AcitivityViewController for Sharing- and Saving-Options
15+
Opens ActivityViewController for Sharing- and Saving-Options
1616
*/
1717
public static func share(url: URL, viewController: UIViewController, completion: (() -> Void)? = nil) {
1818
let activityVC = UIActivityViewController(activityItems: [url], applicationActivities: nil)

0 commit comments

Comments
 (0)