Git Product home page Git Product logo

shufflingb / swiftui-foreach-drag-core-data Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 701 KB

iOS SwiftUI app that demonstrates the ForEach component being used with a Core Data Entity that has a Many-to-Many relationship with itself AND uses Xcode's data modeller Arrangement Ordered option to facilitate arbitrary ordering of those relationships.

License: MIT License

Swift 100.00%
coredata draggable foreach swiftui-example

swiftui-foreach-drag-core-data's People

Stargazers

 avatar  avatar

Forkers

azuredark

swiftui-foreach-drag-core-data's Issues

ContentView.rearrangeChildItems has to clone the Core Data ordered set before it can rearrange

Issue

ContentView.rearrangeChildItems has to clone the Core Data ordered set from an NSOrderedSet to a NSMutableOrderedSet before it can (using the moveObjects to) be rearranged

There a performance impact (seems acceptable with up to ~50 items) which should not be necessary, as:

  1. According to the official documentation for the data modeller as it states: "Arrangement: Select the Ordered checkbox to specify that the relationship has an inherent ordering, and to generate an ordered mutable set.".
  2. The App's Core Data model uses that option for its children and parent relationships.

And yet XCode's (11.6 and 12 Beta 3) Editor> Create NSManagedObjectSubclass Subclass... generates accessors for the sets in Item+CoreDataProperties, it creates items that return immutable NSOrderedSet.

Misc

In the hope that Core Data's mapping was simple screwy, I tried:

  1. casting to NSMutableOrderedSet in ContentView.rearrangeChildItems.
  2. Changing the returned type in Item+CoreDataProperties for the lists ``NSMutableOrderedSet`

Neither worked, and from memory, built, allowed rearrangement, but then silently i.e. no exceptions or warnings, failed to persist the data.

With many screens of data, always snaps to first on successful drag end operation

Issue

With a many item paged lists, a successful drag operation always results in the screen of items displayed snapping back to the first page of data regardless of on what screen the moved item was actually dropped.

Expected behaviour would be that the moved item would remain visible post move.

Replicate

XCode 11.6
iOS 13.6

  1. Create a couple of screenfuls of data by pressing the add item button. i.e. to view the end of it requires scrolling.
  2. Scroll to the end of the list and note its UUID
  3. Move the end item up one spot in the list and observe that the:
    a. Screen is showing the the top of the list
    b. Moved item's UUID is no longer visible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.