Philly ETE 2019 – Rob Napier – Generic Swift: It Isn’t Supposed to Hurt

by
Tags: , , , ,
Category:

Abstract

They said Swift is “protocol oriented,” so you wrote protocols. But you wanted them to be generic, so you added associated types. But your collections broke, so you added type-erasers. But your “as”-casts broke, so you switched to Any. But then everything broke, so you read about Mirror. And the tears began. Why did it have to be so hard to make an array?

It doesn’t have to be so hard. But it’s very easy to use the wrong tools to solve the wrong problems. In this session I’ll help you reevaluate what it means to write generic Swift and how to choose the right tools for the job. Whether your goal is reusable view controllers, flexible networking, data-driven UI, effective unit testing, or just the joy of elegant data structures, you’ll learn how to work with Swift and not fight the compiler.

This talk assumes familiarity with Swift syntax for generics, protocols, extensions, enums, and first-class functions (such as completion handlers), as well as the basic differences between Swift structs and classes. More advanced topics, including protocols with associated types, enums with associated data, closures, and functions as return types, will be introduced and explained.

About Rob Napier

Rob is co-author of iOS Programming Pushing the Limits, and maintainer of the RNCryptor encryption format. Before coming to Cocoa, he made his living sneaking into Chinese facilities in broad daylight. Today, he shapes music over Bluetooth for Logitech, explores old ideas in new languages, and tries to figure out how all of this applies to Swift.