Refactoring CoreData files

XCdataModeld

I've got no idea what that last "d" is for in the extension for Main.xcdatamodeld - do you? I did learn a bit from the Generating Code doc. The first thing I learned is that deleting the derivedData directories is the hard-way to get Xcode to regenerate the managed objects - try the Editor > Create NSManagedObjects Subclass... menu item when the Main.xcdatamodeld is selected. OK - that's the easy-way; worth the price of admission.


One day soon I will have to learn all about Lightweight Migration - but today - it's just additions to the model.

So far I've not found any tools that help with refactoring the data model. Have you?

I've found that I am best served by making ONE change in the model and then tracking down all the compile errors that result from the ONE change - like renaming: creationDate to purchasedDate - only around 20+ changes in the code. But the compiler is way faster at finding them than I am. And it requires several passes - I don't know why this is the case in Xcode - do you?

Apple has a simple overview of CoreData in there docs - but I recommend Donny Wals book: Practical Core Data.

Udemy Course

I bought this Udemy course - it was just $10 on a deep discount - but I don't recommend it. I found the author's repeated non-sense phrases "go ahead and..." bugged me. Maybe I should be able to move past that, yet with more than a dozen examples per video... well - now I've ruined it for you also.

In videos 20 & 21 he talks more about the Mocks he is NOT going to write than about the fundamentals of the code he did just write. For example, the unwrapping of a property wrapper's stored value. Never even notes this unique and non-typical syntax.

_model = StateObject(wrappedValue: CoffeeModel(webservice: webservice))

So what's up with that underscore-model? Does anyone know why this is done - and why bypassing the wrapped object is an OK thing to do? I know just the superficial bit, the underscore syntax allows you to bypass the wrapper and access the underlying variable. Now, why is that desired?

This is just one of the many examples throughout the whole course. I found that when I wanted to know more about an area... he was just glossing over the surface and I'd have to go elsewhere to find answers.

MV Design Pattern in iOS by Mohammad Azam

Hacking with Swift

A better introduction may be Paul Hudson's Hacking with Swift. I joined up and did the HWS+ subscription for a year or more, and really learned lots from his videos and books. I highly recommend Paul's work.

Introduction to using Core Data with SwiftUI by Paul Hudson @twostraws


Big Mountain Studio

When it comes to learning - a visual approach is often best for everyone. If this is you - then head over to the Big Mountain Studio for the best SwiftUI books.

I wish Apple would hire Mark and chain him to a desk until he's rewritten all the Swift Docs. Start with the missing Charts - how to!

Here is how Mark discusses the @AppStorage wrappedValue issue.