[iOS][Swift] 意外と知らない? スマートなグローバル変数ファイルの作り方
以下のように構造体を作成してから、
Constant.swift
struct K {
struct UserDefaultsKey {
static let Settings = "kSetings"
}
struct NotificationKey {
static let Welcome = "kWelcomeNotif"
}
struct Path {
static let Documents = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
static let Tmp = NSTemporaryDirectory()
}
}
以下のように使うだけ。
K.UserDefaultsKey.Settings
K.Path.Documents
Author And Source
この問題について([iOS][Swift] 意外と知らない? スマートなグローバル変数ファイルの作り方), 我々は、より多くの情報をここで見つけました https://qiita.com/4q_sano/items/41cbbe265bc71d4f81ec著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .