In this video, I want to introduce you to KeyPaths and how you can use them in your Swift projects.
We will start by looking a what a KeyPath is and how you can use them to reference to a property of an object or a struct and then look at some examples of how you might apply them in your code.
This will include using keyPaths for sorting and mapping arrays, we will look at the DynamicMemberLookup attribute and two very practical examples for using KeyPaths to simplify your code
We will finish with a short explanation of how keyPaths are used in Lists for SwiftUI
If you want to support my work, you can buy me a coffee :)
[ Ссылка ]
Table of Contents:
0:00 Introduction
1:14 The Basics
5:40 KeyPathComparator
8:22 KeyPaths for Mapping
9:46 DynamicMemberLookup
15:50 Practical Examples
22:52 KeyPaths in Swift Lists
Starter Project Files:
(If you are having problems downloading zip files, use Safari. Chrome restricts zip files by default)
[ Ссылка ]
Completed Project:
[ Ссылка ]
References mentioned in video:
What is Swift KeyPath in Swift
[ Ссылка ]
How to Use DynamicMemberLookup in Swift
[ Ссылка ]
Higher order Function Videos
map, compactMap, flatMap
[ Ссылка ]
contains, forEach, Sorted
[ Ссылка ]
reduce, filter, removeAll
[ Ссылка ]
Other References:
Stewart Lynch's YouTube Channel:
[ Ссылка ]
Stewart Lynch on Mastodon:
[ Ссылка ]
Stewart Lynch on Twitter:
[ Ссылка ]
Stewart Lynch on LinkedIn
[ Ссылка ]
Ещё видео!