将Objective-C语法转换为Swift 3

将Objective-C语法转换为Swift 3,objective-c,swift,Objective C,Swift,以下Objective-C方法在Swift中的语法是什么 -(id)init { Viewcontroller static *vc=nil; if(!vc) { vc=[super init]; return vc; } else return vc; } 以下是Swift 3的语法 override init() { var vc: Viewcontroller? = nil if vc == nil

以下Objective-C方法在Swift中的语法是什么

-(id)init
{
    Viewcontroller static *vc=nil;
    if(!vc)
    {
        vc=[super init];
        return vc;
    }
    else return vc;
}

以下是Swift 3的语法

override init() {
    var vc: Viewcontroller? = nil
    if vc == nil {  
        vc = super.init()
        return vc!
    }
    else {    
        return vc!
    }
}

这不是免费的代码翻译服务。请自己尝试转换代码。用您尝试过的内容更新您的问题,并清楚地解释您遇到的问题。先生,静态关键字在哪里?@ManzoorHusain当您在类中定义静态var/let时,该信息将在所有实例(或值)之间共享。它是“var”还是“let”?使用可使您成为常量对象,使用Var可使您成为可变对象