vendredi 8 juillet 2016

how to simplify and make it better using enum, swift learning, enum


I am defining some of ranges by following

let range0_15   =   0 ..< 15
let range15_30  =   15 ..< 30
let range30_45  =   30 ..< 45
let range45_60  =   45 ..< 60

I really want to use Enum for this by trying

enum range : Range<Int> {
    range0_15   =   0 ..< 15
    range15_30  =   15 ..< 30
    range30_45  =   30 ..< 45
    range45_60  =   45 ..< 60
}

And I am getting an error

Type 'CoreDataStach.range' does not comform to protocol RawRepresentable

Is it possible to define an enum like above and if it is yes, what I am missing right here.


Aucun commentaire:

Enregistrer un commentaire