swift中的Init方法3

时间:2016-11-22 10:01:11

标签: swift swift3

Ext.application({
    name : 'Fiddle',

    launch : function() {
        Ext.create({
            xtype:'window',
            width:300,
            height:200,
            items:[
                {
                    xtype:'combo',
                    store:['Yes','No','']
                },
                {
                    xtype:'button',
                    text:'reset',
                    listeners:{
                        click:function(button){
                            var combo=button.prev();
                            combo.setValue('');
                        }
                    }

                }
                ]
        }).show();
    }
});

我在Swift 2.3中使用这个类,它运行良好。但我无法使用Swift 3.我遇到了编译错误:

  

初始化程序不会覆盖指定的初始值设定项   超

     

'超'成员不能在根类中引用

我该如何修复它们?

1 个答案:

答案 0 :(得分:5)

您可以通过不调用super.init()来解决此问题。您的类未声明为从另一个基类继承,因此无法调用super.init()

顺便说一句,对于你的共享实例我只会做

static let sharedInstance = MissionControl()