title: How to get a swift enum's associated value regardless of the enum case
body: <p>I have an object FormField which has two properties: a String <code>name</code>, and a <code>value</code> which can accept any type--hence I've made it <code>Any!</code>. However, I've been told in <a href="https://stackoverflow.com/questions/25863694/swift-if-let-evaluates-successfully-on-optionalnil">a separate question</a> to use an enum with associated values instead of <code>Any!</code>.</p>
  
  <pre><code>enum Value {
      case Text(String!)
      case CoreDataObject(NSManagedObject!)
  }
  
  class FormField {
      var name: String
      var value: Value?
      // initializers...
  }
  </code></pre>
  
  <p>This approach makes it awfully verbose to check for nullity however. If I wanted to display an alert view for all the missing fields in the form, I'll have to repeat a nil check for every case in a switch statement:</p>
  
  <pre><code>for field in self.fields {
      if let value = field.value {
          switch value {
          case .Text(let text):
              if text == nil {
                  missingFields.append(field.name)
              }
          case .CoreDataObject(let object):
              if object == nil {
                  missingFields.append(field.name)
              }
          }
      }
  }
  </code></pre>
  
  <p>Is there a shorter way of accessing the enum's associated value, regardless of the type? If I make FormField.value an <code>Any!</code> the above code would be as easy as:</p>
  
  <pre><code>for field in self.fields {
      if field.value == nil {
          missingFields.append(field.name)
      }
  }
  </code></pre>