Comments (6)
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.
On vacation atm, so not sure am I missing something obvious...
-
Why the property must be binary..?
-
Approach with Codable looks like proper solution for what I tried to do with CoreDataRepresentable which works with any attribute type
from mogenerator.
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.
Commit 28c0a72 includes an implementation of this.
from mogenerator.
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.
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)
- Add nullability annotation for primitive setters HOT 2
- scalar methods do not respect the signed types that Core Data forces
- Swift generated code creates NSNumber for boolean types HOT 1
- Generated code crashes with Xcode 8.3 HOT 3
- Issue with setPrimitive...: for Transformable attributes HOT 1
- Inherited entities and compundIndex
- Changes on swift42 break `attributeValueScalarType` for enumerations HOT 4
- Implement Codable support for NSManagedObject subclasses HOT 13
- Use scalar properties for primitive data types HOT 3
- generate NSFetchRequest without executing it HOT 3
- There is mo mogenerator's folder in /Library/Application Support after successful installation. HOT 2
- Trying to find swift template files outside of template-group HOT 8
- Attribute's userInfo dictionary HOT 1
- Feature Request: MacPorts support HOT 1
- Swift module name breaks things HOT 1
- Wiki for Template Variables - abstract should read isAbstract
- Is this project maintained? HOT 1
- Transformable property for [NSString] get error.
- mogenerator --configuration does nothing now HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mogenerator.