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

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -