From the course: Swift 5: Protocol-Oriented Programming
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Designing with classes: First try
From the course: Swift 5: Protocol-Oriented Programming
Designing with classes: First try
- [Instructor] In Swift, you can follow the object-oriented way of thinking or try to adopt the new protocol-oriented approach. You can even rely on generic and functional programming. Swift blurs the line between the various programming paradigms. In the following videos, I'll walk you through some examples that show the benefits of the protocol-oriented programming over the class-based approach. Let's say that we need to create types that fulfill the following requirements. Store data along with a unique identifier, provide file system storage and restoration capabilities, and return a Base64-encoded representation. Let's open up Xcode. I create a new playground called Tagged Data. Let me clean up the generated code, and I'm going to make it full screen. We need the foundation framework, as usual, and let's implement a class-based solution first. I start by declaring a class called Tagged Data. Next, I add to properties…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.