A Swift Implementation of the Core Data Stack Using NSPersistentContainer

If you’re targeting iOS 10 and above, you’ve got the opportunity to pick your poison when it comes to creating the Core Data stack. You could opt for the process I described in Creating the Core Data Stack with Backwards Compatibility in Swift — that process still works perfectly fine in iOS 10+. Alternatively, you […]

Why Do We Need to Annotate Escaping Closures in Swift?

Why Do We Need to Annotate Escaping Closures?

My last entry on escaping closures ended up having way more interaction than I anticipated! It goes to show that you never know what the impact of a piece of writing will have. But that’s a different story… :] Several readers commented here and on Medium with the question, “Why? Why do we need to […]

What in the World is an “Escaping Closure” in Swift?

Escape

If you’re mostly in the business of coding up closures to pass off to other functions as callbacks, you may not have run into the concept of an “escaping closure” yet. When you step out of the role of consuming other peoples’ APIs in to the realm of creating your own (and you do this […]

Core Data Model Attributes and NSManagedObject Property Types Must Match!

Jump to… Data model Attributes and NSManagedObject property types – Match ’em! Optionals are Types Lessons learned Was this article helpful? Please share! Learning Core Data? Watch my course, Core Data Fundamentals with Swift! I admit – it might have taken me less time to figure out my runtime exception if I hadn’t just migrated […]

How to Unwrap Multiple Optionals with One If-Let in Swift

What do you do when you’ve got two (or more) optionals that you need to safely unwrap and work with? Code examples Suppose that you’ve got two arrays, both of which are optional. What I want to do right now is walk through a couple of scenarios where I unwrap them at the same time […]

Creating the Core Data Stack with Backwards Compatibility in Swift

In 2017, we live in a world where there are still non-iOS 10 devices out in the wild. If your app is targeting an iOS version earlier than iOS 10, or macOS Sierra (10.12), you’ll be unable to take advantage of Core Data’s latest “stack creation” class called NSPersistentContainer. So what can you do? While […]

Swift Tip – Accessing a User’s Documents Directory with URL Extension

When you need to access the documents directory on a user’s device, what do you do? In the past, I know I’ve gotten used to typing out the same set of code over and over throughout my apps. I know, I know – DRY – don’t repeat yourself. One way to simplify this is to […]

Core Data Fundamentals with Swift

Core Data is an extremely powerful framework for managing and persisting data on your users’ devices. And let’s face it: saving data to your users’ devices is inevitable. The question is, which data management and persistence technology you use when the time comes for you to tackle this challenge? I’ve been hard at work on […]

Core Data: Solving Ambiguous Type / Redeclaration of Type

I just finished roasting some coffee from Peru. I’ve never had it before, but it got me thinking about my Roaster On the Go “app” as I thought about the context that I could use to show you the solution to the compiler error described in the title. I used this to demonstrate Working with […]

Using a Core Data Model in Swift Playgrounds

Did you know that you can tinker with Core Data inside of Swift playgrounds in Xcode? You can! Jeremiah Jessel, author at http://www.learncoredata.com, wrote up an article in 2015 detailing how you can use the Core Data framework inside a playground. He shows how you can do everything from setting up the Core Data stack, […]