ios - Using enum With Integers in Swift -


i'd know how can limit set of values can pass function argument (or class property). or, in other words, logic want implement, actually, make function or class accept particular values. i've come idea use enum it. caveat here can't use pure integers 'case' so:

enum measure {     case 1, 2, 3 } 

is there way implement want?

enum measure:int{     case 1 = 1     case 2 = 2     case 3 = 3 }  //accept argument func mymethod(measure:measure){     switch measure {         case .one:...         case .two:...         case .three     } }  //call method raw data mymethod(measure(rawvalue:1)!) //or call method  mymethod(measure.one) 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -