Using Switch Statements for Type Checking in Swift

January 16, 2016 | Swift, Control Flow, iOS, macOS, tvOS, watchOS

One thing that bothers many developers about using if statements for type checking in Objective-C is that it suggests a specific order of importance. For example, here's how you might use type checking in an Objective-C prepareForSegue method . . .

Swift Enums: Initialization with Associated Values from a Server Response

January 10, 2016 | Swift, Enumerations, iOS, macOS, tvOS, watchOS

Swift Enumerations with Associated Values are a powerful way to represent a group of related values that may be associated with different types. The Apple documentation on enums uses the example of an inventory tracking system with different types of barcodes, UPCA and QR. UPCA and QR codes are both "Barcode" values so . . .