Swift Const file


Const File

Creating application, there are a lot of fix parameters.

Of course, if this is only in file, we just use top of file.

But in application, parameters are used a lot of places.

struct and static

Let’s explain the example

We can create one file


struct Constants {

    static let ABC = "abc"
    struct Nested {
        static let CD = "cd"

We can use struct and static let in codes.

Also, we can use nested type.

How to use?

let abc = Constants.ABC
let cd = Constants.Nested.CD

We can use above codes in any places in your application. It’s simple.

Professional Programmer2