A type alias defines an alternative name for the existing data type.
For example, using the built-in types you can specify the data type for variables like this:
var customerID : UInt32 var customerName: String
However, it would be more useful if you could provide a more meaningful and contextually relevant name using the typealias keyword:
typealias CustomerIDType = UInt32 typealias CustomerNameType = String
Here, CustomerIDType is the alias for the UInt32 type, and CustomerNameType is the alias for the String type.
You can use the aliases as if they are the data types, like this:
typealias CustomerIDType = UInt32 typealias CustomerNameType = String var customerID : CustomerIDType var customerName: CustomerNameType customerID = 12345//from w ww . j a v a 2 s.c o m customerName = "Json" print(customerName);