I have a very simple class in Swift 2.0.
import UIKit
class ConsoleViewController: UIViewController {
static let DEFAULT_Y_MARGIN: Float = 10.0
var margin: Float = DEFAULT_Y_MARGIN
func clear() {
margin = DEFAULT_Y_MARGIN
}
}While the margin class variable seems okay, the compiler seems to have a problem with the setting the margin variable in the clear() method. I get the error message ConsoleViewController.swift:17:18: 'ConsoleViewController' does not have a member named 'DEFAULT_Y_MARGIN'. Is that a bug?
Alternatively, is there a better way to have static constant class variables that I'm missing? I'd like to be able to give constants a name, so I can use the much more readable DEFAULT_Y_MARGIN over 10.0. Is there a way to set this up where that variable is scoped to the class and I can use it like that?