One Quickie


Accessing a class method from an instance. (General->Swift)
Say you have an instance, and you want to call a class method, similar to objc where you could do something like self.class.insets.left. Use type(of: self).methodName()
class Bargle {
    static func greeble() {
        print("Blargle greeble")
    }

    func oopack() {
        type(of: self).greeble()
    }
}

let bargle = Bargle()
bargle.oopack()
This will cause Blargle greeble



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com