Swiftpack.co -  alekseyn/EasyDocument as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
alekseyn/EasyDocument
Deep copy of Core Data managed objects, and export/import of object snapshots as shareable data.
.package(url: "https://github.com/alekseyn/EasyDocument.git", from: "0.4.0")

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: 0
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

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