Swift - what 'class var' means

A class variable is like a static variable in that you access it by calling MyClass.myVar however static variables can't be overwritten in subclasses, while class variables can be.


That's not a class variable, it's a class computed property, which is currently supported.

// Playground - noun: a place where people can play

class A {
    // Fine:
    class var computed: String {
        return "Woo"
    }
    // Not supported (yet):
    class var realVariable: String = "Woo"
}

Tags:

Swift