GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
The Swift compiler in Xcode Beta 3 still doesn't play well with the Cocoa classes produced by mogenerator. It requires us to use KVC exclusively to get or set any property in an NSManagedObject entity, and that is a major burden on us lowly devs.
In Objective-C, the .h/.m files generated by mogenerator produce type-safe convenience getters and setters of the form "myPropertyValue". But those are all missing from the Swift template in 1.28.
Please consider adding these unless there's a good reason not to. :)
Actually now I think the Swift template should be declaring numeric values as NSNumber — not Int16, Int32, Int64, Double, Float, etc. This is causing major problems.
Checking the template for Cocoa, NSValue was used. Not sure why you guys would think Swift should be different...
Now I'm not so sure which way is better. Certainly there is a consistency issue with the Obj-C legacy, which used NSValue. But the scalars are proving to be cleaner in Swift.
Perhaps a mogenerator option is warranted here? I think I saw someone else mention that too.
The (working) Swift templates on the 1.28 branch is using NSNumber?. This allows things like setting the attribute to nil, which otherwise Swift won't allow.
Now I'm thinking even the Swift templates need *Value boxing/unboxing convenience methods.
if the model has the attribute designated as optional, use a normal optional scalar type like Int?
if the model has the attribute designated as non-optional, use an implicitly unwrapped optional scalar like Int!
Agreed, right now I just get crashes since swift tries to access nil non-optionals
We are working on adjusting how we generate Swift in #302. If you have feedback, let's put it there.