Reputation: 31
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?
Upvotes: 2
Views: 204
Reputation: 2252
If all the constants are of the same type an enum
could be the right way
Upvotes: 0
Reputation: 7067
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?
Upvotes: 2