Here's a quick way to come up with
·Use ENUM
·Create a Define class
That's it.
What should I do?
swift
If you want to create a special class, I think you should use structure.
Swift's class cannot have a class constant to hold the value, but it is possible if it is struct.
// Compile without problems
US>structure ConstStruct{
static let nameMax = 32
static let imageMargin —CGFloat=10.0
staticlet defaultName="NO NAME"
}
// get a compilation error
classConstClass{
static let nameMax = 32
static let imageMargin —CGFloat=10.0
staticlet defaultName="NO NAME"
}
"If you give ""let"", I think you can treat anything as a constant.
If you don't forget the style of C language, you may not be able to feel it right.
As for "where", I think it would be independent of the implementation of classes, structures, etc.
897 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
568 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
601 GDB gets version error when attempting to debug with the Presense SDK (IDE)
568 Who developed the "avformat-59.dll" that comes with FFmpeg?
611 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.