vendredi 30 octobre 2015

use self with if condition before super.init(nibName:)

I would like to use self with an if condition in init() method... (before the super.init()).

Here is my example I can't use (self before super.init) :

init()
{
    if #available(iOS 8.0, *) {
        if self.traitCollection.horizontalSizeClass == .Regular
        {
            super.init(nibName: ProductDetailsIdentifier, bundle: NSBundle.mainBundle())
        }
        else
        {
            super.init(nibName: ProductDetailsIdentifierIphone, bundle: NSBundle.mainBundle())
        }
    }
}

required init?(coder aDecoder: NSCoder)
{
    super.init(coder : aDecoder)
}

Aucun commentaire:

Enregistrer un commentaire