Swift Non-Nil Values In An Array Of Optionals

I find it hard to remember the different ways you can use case with Swift beyond the familiar switch. Here is one useful example for when you need to do something with the non-nil values in an array of optionals.

Read On →

Changing Xcode Header Comment

Have you ever wanted to change the standard header comment that Xcode automatically puts at the top of ever new source file you add to a project? Maybe you just don’t like the default or need to include your own copyright or license text. Xcode 9 added a FILEHEADER text macro to allow you to do just that.

Read On →

Table View Separator Inset

The table view separator is that thin line drawn by default between table view cells. You control how far it extends to the leading and trailing edges with the seperatorInset property. Since iOS 7 this has been an inset based on the table cell margins. In iOS 11 Apple changed that to inset from the cell edges by default. That makes it easier to extend to the full table width but if you have been using an inset you may want to check how it now looks on iOS 11.

Read On →

URLSession Waiting For Connectivity

If you use URLSession to start a task with iOS 10 and the network is not available the connection fails at once with an error. There was a small change in iOS 11 that means you can now tell your URLSession to wait until network connectivity is available before trying the connection.

Read On →

Swift Codable With Custom Dates

How do you decode a JSON feed that has several custom date formats? If you are lucky using a dateDecodingStrategy might be enough. Unfortunately it has limited support for the .iso8601 format and you can only set one strategy at a time so it does not help when you have two or more different date formats.

Read On →
Archives Categories