IOS_Swift_enum枚举步骤

IOS_Swift_enum枚举方法
本博文为子墨原创,转载请注明出处!
http://blog.****.net/zimo2013/article/details/50116811

enum Type: Int{
    case A=1
    case B=3
    
    //普通方法
    func toString()->String{
        var info=""
        
        switch self{
        case .A:
            info = "一"
            
        case .B():
            info = "三"
        }
        return info
    }
    
    //静态方法
    static func toString(let type:Type)->String{
        return "toString() -> \(type)"
    }
    
    // 成员
    var description:String{
        var info=""
        switch self{
        case .A:
            info = "一"
            
        case .B():
            info = "三"
        }
        return "description field = \(type)"
    }
}

let type = Type.B

print(Type.toString(type))
print(type.description)

//toString() -> B
//description field = B


3楼u010786678昨天 23:29
博文末尾进行一些总结,会更好!
2楼u010927640昨天 22:55
没有文字?。。。
1楼u012466304昨天 19:03
解释性语言有些少呀