Subclassing NSObject in Swift - Best Practice with Initializers

If someProperty can be nil, then I think you want to define the property as:

var someProperty: NSString?

This also eliminates the need for a custom initializer (at least, for this property), since the property doesn't require a value at initialization time.


I'm not Swift ninja but I would write MyClass as:

class MyClass: NSObject {
    
    var someProperty: NSString // no need (!). It will be initialised from controller 
    
    init(fromString string: NSString) {
        self.someProperty = string
        super.init() // can actually be omitted in this example because will happen automatically.
    }
    
    convenience override init() {
        self.init(fromString:"John") // calls above mentioned controller with default name
    }        
}

See the initialization section of the documentation