0
我正在嘗試使我可以在我的應用程序中使用的全局變量。我想我可以把東西放在AppDelegate類中,並且隨處可用,如果你知道更好的方法,請告訴我。Swift AppDelegate結構用法
當我嘗試製作一個結構體時,我遇到了問題。我的代碼:
struct category {
let one: UInt32 = 0x1 << 1
let two: UInt32 = 0x1 << 2
let three: UInt32 = 0x1 << 3
let four: UInt32 = 0x1 << 4
}
,當我嘗試訪問任何類我得到的錯誤
Instance member 'one' cannot be used on type 'category'
我使用也試過:
struct category {
let one: UInt32 {
get {
return 0x1 << 1
}
}
}
而且也不能工作。
非常感謝! –