Tomas Gudmundsson
Tomas Gudmundsson

Reputation: 223

Define a typealias for the whole project

In which file can I define a typealias that works in the whole project, etc.

typealias S = String

Upvotes: 14

Views: 4430

Answers (2)

Ravi Raja Jangid
Ravi Raja Jangid

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

Ismail
Ismail

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

Related Questions