Easier Core Data Setup with Persistent Containers

Apple has made a number of changes in iOS 10 to ease the pain of setting up and using Core Data. In this post I look at how to use the new persistent container class to remove a lot of the boilerplate Core Data setup code. If you are still relying on the old Xcode template code for Core Data in your app delegate you should take a look at NSPersistentContainer.

Read On →

Swift 3 and Comparing Optionals

One of the more challenging aspects of learning and using Swift is keeping up with the changes. I wrote a post about a year and a half ago on sorting an array of dictionaries. I updated that post for the latest Swift syntax last year but I recently realised it was out of date again when Swift 3 removed the ability to directly compare two optional values.

Read On →

Core Data Code Generation

When working with Core Data it is common to create subclasses of NSManagedObject for each entity in the data model for easy property access and other helper methods. Starting with Xcode 8 the default for new entities is for Xcode to automatically create these files for you when the model changes. Is it worth the trouble? Here are my notes on how to use or disable the feature.

Read On →

Batch Updating of Constraints

Since Apple introduced Auto Layout way back in iOS 6 the API has allowed you to add constraints one at a time or as a batch. Most of the code samples on this blog have tended to add constraints one at a time for ease of explanation at the possible expense of run-time efficiency. In this post I want to be sure to show the alternative, mention a Swift bug that might bite you and what is perhaps a more pragmatic reason to prefer the batch approach.

Read On →

Stack View Constraint Conflicts When Hiding Views

The Stack View is a great timesaver when it comes to Auto Layout but it is not totally pain free. Having a stack view create and manage the constraints for you is great until something goes wrong. Debugging an unable to simultaneously satisfy constraints error is hard when you don’t know what the stack view is doing. A common cause of stack view auto layout conflicts is hiding views that have an explicit size constraint.

Read On →
Archives Categories
No time to watch WWDC videos?

Sign up to get my iOS posts direct to your inbox and I will send you a free PDF of my iOS Size Classes Cheat Sheet.

Unsubscribe at any time.