Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建一个应用程序,我必须在其中将一些常量声明为全局。在 Obj CI 中可以使用 pch 文件,但我不知道如何在 Swift 中定义?例如
如果我声明,在 Obj C .pch 文件中
然后它通过应用程序工作。
您需要做的就是创建一个Constants.swift(或您想要命名的)文件,然后将您需要的任何常量添加到其中。
Constants.swift
let myVariable = "Some Value" let myOtherVariable = "Something Else"
然后,它们将在您的整个应用程序中可用。