首页 > 代码库 > swift 枚举类型

swift 枚举类型

import UIKit/***枚举类型*/enum direction{    case North    case Sourth    case East    case West}//不会被默认为整数类型var d = direction.Eastd = .Westswitch d{    case .North:    println("North")case .West:    println("West")default:    println("default")}//指定类型enum number{    case one(Int)//指定为int类型的值    case two(Int)    case three(Int)}var _one = number.one(1)//初始化_one = number.two(2)switch _one{case .one:    println("1")case .two:    println("2")default:    println("3")}

 

swift 枚举类型