Swift Gotcha’s

I want an ongoing place to keep track of issues I find with Apple’s programming language, Swift. So here it is. Note that I generally like Swift. I just want a record of issues I run into. Of course the nature of issue is IMHO. The ordering here is the reverse of my adding them. The most recent are at the top.

  1. 6/17/16. In Xcode 7.3.1, why can’t you use let constants, which have statically assigned constants, to initialize String raw valued enums? Xcode’s error is “Raw value for enum case must be a literal”.

    Screen Shot 2016-06-17 at 4.45.15 PM

    The definition for userTypeOwning is:
    public static let userTypeOwning = "OwningUser"

  2. 5/30/16. In Xcode 7.3.1, why can’t you directly create arrays with dot types? For example, see result in the following:example
    Note that SMImageTextVew.ImageTextView element is an enum type. I find it necessary to create a type alias and then create the array. Odd.
  3. 5/30/16. You can’t throw from setters/getters in computed properties.
  4. Issues with Comparison Operators and Optional Chaining, e.g.,
    self.instance?.value < 0