Quantcast
Channel: Core Data – Michael Tsai
Viewing all articles
Browse latest Browse all 217

Generating Core Data Swift

$
0
0

Human Friendly:

There are two [Xcode] generation options, with “Use scalar properties for primitive data types” you get usefully typed integers, floats, doubles and bools but lose the expression to express optionals/nil values. This is presumably due to the limitations of the Objective-C based API. It also expresses date types as NSTimeIntervals (Doubles) rather than NSDates. The other option will generate with objects so you will get NSDates but for number values and Booleans you will get NSNumbers which lose information about whether it is a floating point type, integer or boolean.

[…]

The Core Data model file is actually a very simple XML file and parsing it is relatively straightforward. I’ve written a quick (but brittle so far) parser using NSXMLParser. This means that I can easily get at the key information (Entities, Attributes and the relationships) to generate the code I need.

See also: mogenerator.


Viewing all articles
Browse latest Browse all 217

Latest Images

Trending Articles



Latest Images