Swift

Figuring Out Frame Layouts in Swift

Confession time. I forgot to write an article last week as promised, but I think this one is worth the wait. Today we are back to talk about some frame layouts. We are going back to the days before Auto Layout and showing you how to make a subview with nothing more than your will, wit, and a bit of math. Let’s layout!

The first step is to create a view subclass to work with. Here is a simple example:

»

Cool Codable Coding

We are back! Wow has it really been two years? Ironically our last post was celebrating the one year mark with new things to come and then… radio silence.

Alas, we missed y’all and are back with a fresh new design and content. This week I wanted to cover Swift 4’s Codable protocol. I know, I can hear your groans now about another Codable article, but I wanted to use this article to showcase Codable in a practical HTTP API setting. Plus it gives me the excuse to show off the new version 3 of SwiftHTTP and to officially deprecate JSONJoy (Apple decided to create even more joy, lame pun intended).

»

Swift, Labels, Default Parameters, oh my!

The other day I was working on Jazz and got to fully appreciate the convenience of default parameters in Swift. Default parameters combined with labels gives a simple and flexible method signature. This is in stark contrast to some other method signatures in other development environments. methods in these environments can have an upwards of 10 parameters, all with arbitrary names. Let’s take a look at an example of such methods:

»

Numbers and Swift

2 + 2 = 4. Aren’t numbers grand? They are the basic building blocks for all data we work with and Swift is no exception. Speaking (or typing) of numbers, I was working on SwiftLog the other day and came across a NSFileManager call that returned a NSNumber in Objective-C and a UInt64 in Swift. The different types inspired me to write this article. Objective-C only has NSNumber for a number object, while Swift has a whole list:

»