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, […]

Force Unwrapping Swift Optionals: Code Smell!

Do you find your Swift code riddled with !‘s? I’m becoming more and more uncomfortable with seeing ! throughout my Swift code. It’s just a matter of time before it’s going to bite me. Often, I do it because it’s the “easy thing” to do at the time. But it’s dangerous. Swift optionals are trying […]

Is Protocol Oriented Swift Better than Object Oriented Swift?

A question was asked on Reddit and showed up in my feed as I was browsing this weekend: What does protocol oriented programming mean, and why is it better than OOP? I really like a few things that were said in one of the top “Explain Like I’m 5” comments that was posted in response […]