2

In Objective-C, we used to do the following in our class files:

In the header:

extern NSString* const kSTRING_CONSTANT;

In the implementation:

NSString* const kSTRING_CONSTANT = @"a_string_constant";

What is the Swift equivalent of this?

Luke
  • 11,400
  • 43
  • 61
  • 68

2 Answers2

2

The best way to deal with that type of constants is to create a Struct

struct GlobalConstants {
    static let someNotification = "TEST"
}
println(GlobalConstants.someNotification)

For further reference, refer to Swift Offical Guide or see the following link

How to create a global variable?

Community
  • 1
  • 1
Anuj
  • 6,717
  • 3
  • 19
  • 25
0

If all the constants are of the same type an enum could be the right way

DeFrenZ
  • 2,126
  • 1
  • 20
  • 19