Reputation: 223
In which file can I define a typealias that works in the whole project, etc.
typealias S = String
Upvotes: 14
Views: 4430
Reputation: 935
typealias
is used to alias existing data types. Its access scope is the same as a variable: If it's declared inside the block, like class, struct, protocol etc., then its visibility also remains inside that block only. It can not be used outside to declare new variables of that type.
Upvotes: 0
Reputation: 2818
the typealias
works the same way as variables. If you want to be global put it outside the class scope at any file.
Upvotes: 29