Hello, I am a student who is making an application using swift. I'll ask you a question right away.
The current situation is that some initial values are given after a structure declaration in one table view We're trying to get the structure that gave us the initial value back together and make it into an array. There is no problem with the playground, but if you write it on the project, an error occurs like the picture shown below. I looked it up on the Internet and it seems to be okay if you write it inside the override func... I want to use this array as a global variable. Is there any way?
swift ios
I think you can initialize the value in the viewDidLoad() method.
struct Zone {
var name : String
var controller : [controllerType]
enum controllerType {
case LG_TV
var typeTitle : String {
get {
let titleString : String
switch self {
case .LG_TV:
titleString = "LG TV"
}
return titleString
}
}
}
}
var Room1 = Zone(name : "ROOM1", controller : [.LG_TV, .LG_TV, .LG_TV])
var Room2 = Zone(name : "ROOM2", controller : [])
var Room3 = Zone(name : "ROOM3", controller : [])
var Zones : [Zone] = []
override func viewDidLoad() {
super.viewDidLoad()
Zones = [Room1, Room2, Room3]
print(Zones)
//or
Zones.append(Room1)
Zones.append(Room2)
Zones.append(Room3)
print(Zones)
}
If I misunderstand the question or if there is anything wrong, please leave a request for editing or comment :)
+++++++++++++ Add++++++++++++++++++++
728 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
548 Who developed the "avformat-59.dll" that comes with FFmpeg?
540 Uncaught (inpromise) Error on Electron: An object could not be cloned
550 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.