Swiftpack.co - alekseyn/EasyDocument as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by alekseyn.
alekseyn/EasyDocument 0.5.1
Deep copy of Core Data managed objects, and export/import of object snapshots as shareable data.
⭐️ 1
🕓 17 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/alekseyn/EasyDocument.git", from: "0.5.1")

EasyDocument

MIT License Swift Package Manager

=== This package provides an easy way to perform deep copies of Core Data objects, and an easy way to export and import deep-copied managed objects in a shareable document. It can support sophisticated Core Data object graphs with customization options.

EasyDocumentincludes support for relationships that are either ordered or unordered, and one-to-many or many-to-many. Inverse relationships are also properly configured.

Requirements

  • Swift 5.3+
  • iOS 12.0+
  • macOS 10.14+
  • tvOS 12.0+
  • watchOS 5.0+

Install

Swift Package Manager

let package = Package(
  name: ...
  dependencies: [
    .package(url: "https://github.com/alekseyn/EasyDocument")
  ],
  targets: ...
)

Usage Scenarios

Start with adding an import statement.

import EasyDocument

For best results, your Core Data model must be properly configured. In particular, entities that have an 'ownership' relationship with another entity should have a Cascade relationship deletion rule.

EasyDocument only performs a deep copy of entity relationships that are marked with a Cascade deletion rule. Related entities that have any other deletion rule are ignored. This is critical to ensure the proper ordering of ordered relationships. However, this can be customized.

1. Deep copies of managed objects

Deep copy of a managed object is straightforward.

2. Managed object archives for copy and paste

3. Exporting and importing managed objects

Customization

Common Pitfalls

1. Managed objects that automatically create other dependent managed objects in awakeFromInsert()

2. Not implementing proper cascade deletion rules.

3. Forgeting to add duplicated managed objects into the existing object graph.

4. Ordered Sets

Unit Tests

You can find unit tests in EasyDocumentTests target. Press ⌘+U to run tests in Xcode.

GitHub

link
Stars: 1
Last commit: 17 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics