Giter VIP home page Giter VIP logo

Comments (6)

rentzsch avatar rentzsch commented on June 30, 2024

I can't speak to the Swift devil-in-the-details, but this addition would fit in very well with mogenerator's general thrust of generating obvious code for obvious situations to lubricate Core Data's gears.

from mogenerator.

radianttap avatar radianttap commented on June 30, 2024

On vacation atm, so not sure am I missing something obvious...

  1. Why the property must be binary..?

  2. Approach with Codable looks like proper solution for what I tried to do with CoreDataRepresentable which works with any attribute type

from mogenerator.

atomicbird avatar atomicbird commented on June 30, 2024

Hi @radianttap. It's binary because that's how the built-in coders work and because binary is a type that Core Data understands. JSONEncoder/JSONDecoder and PropertyListEncoder/PropertyListDecoder each convert to/from binary data. It's a good choice to handle any possible Codable, since they can be more complex than the simple enumeration I used as an example. This also parallels how transformables work, which is the behavior I'm aiming for.

from mogenerator.

atomicbird avatar atomicbird commented on June 30, 2024

Commit 28c0a72 includes an implementation of this.

from mogenerator.

radianttap avatar radianttap commented on June 30, 2024

Like I said previously, I use CoreDataRepresentable protocol to map custom enums and structs into Core Data supported types. That works rather well in the last year or so.

I never used 'binary' type for the attribute thus when you said it can't be used in predicates it rang a pretty big bell. I went through the largest project I'm maintaining to see just how much I use these attributes in predicates. Ends up – a lot. Most use cases for custom types is to map enums which represent attributes used for filtering. Thus I have a lot of predicates using exactly those types

NSPredicate(format: "%K == %d", Attributes.sportCode, sportCode.coredataValue)

Hence is not an option for me to lose this.

(I'll need to go over other proposed changes in 376, 377)

from mogenerator.

atomicbird avatar atomicbird commented on June 30, 2024

Hey @radianttap, I'm giving CoreDataRepresentable a try and it looks really good, but I think maybe we're mixing up two different but related things. For this issue I'm aiming for a general implementation of Codable. I included an example of an enum because it's a simple, easy to understand example. It may have been a bad choice though, because this issue isn't intended to be specific to enum. It seems like CoreDataRepresntable would be a good idea for better support of enums, but the more general case of Codable properties includes things that may not conform to RawRepresentable and are not enums at all. I think the best approach is probably to use the code in 28c0a72 for this issue but then also look at using CoreDataRepresentable for enum-specific improvements. Does that make sense?

from mogenerator.

Related Issues (20)

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.