mercredi 21 juin 2017

Accessing enum values in struct with if statement

Having struct like this:

struct ScrollTableViewColumn {
    var ContentType: ContentType

    enum ContentType {
        case String
        case Numeric(sum: Double, width: CGFloat)
    }
}

I can access the numbers stored in content type with switch statement like this:

switch column.ContentType {
case .Numeric(let sum, let width):
   // do something with sum and width…

How can I achieve similar thing with if statement?

Aucun commentaire:

Enregistrer un commentaire