What if you could rename complicated types with a single word and save hours of work?
Why Typealias for custom naming in Swift? - Purpose & Use Cases
Imagine you are writing a program that uses long, complicated type names everywhere, like Dictionary<String, Array<Int>>. You have to write this long type again and again in your code.
Writing long type names repeatedly is tiring and easy to mess up. It makes your code hard to read and update. If you want to change the type later, you must find and fix every place manually, which wastes time and causes mistakes.
Using typealias lets you create a simple, custom name for a complex type. You write the long type once, give it a short name, and then use that short name everywhere. This makes your code cleaner, easier to read, and faster to update.
var scores: Dictionary<String, Array<Int>> = [:] var names: Dictionary<String, Array<Int>> = [:]
typealias ScoreList = Dictionary<String, Array<Int>> var scores: ScoreList = [:] var names: ScoreList = [:]
It enables you to write clearer, simpler code and easily update complex types in one place.
Think of a recipe book where every recipe calls for '1 cup of finely chopped fresh basil leaves'. Instead, you write 'basil' once on a label and use that label everywhere. If you want to change it to 'dried basil', you just change the label once.
Long type names are hard to write and maintain.
Typealias creates a simple, custom name for complex types.
This makes code easier to read and update.