1 Reply
      Latest reply on Sep 15, 2016 4:10 AM by eskimo
      plarson Level 1 Level 1 (0 points)

        Is there a workaround for value(for component: Calendar.Component) seemingly being broken? Or a dynamic way to call the property version?


        func dateComponentsValueShouldBeNil() { 
            let dateComponents = DateComponents(month: 3) 
            debugPrint("Month", dateComponents.month) // "Month" Optional(3)
            debugPrint("Property", dateComponents.hour) // "Property" nil
            debugPrint("Enumeration", dateComponents.value(for: .hour)) // "Enumeration" Optional(9223372036854775807)
        • Re: Broken func value(for component: Calendar.Component) -> Int?
          eskimo Apple Staff Apple Staff (13,335 points)
          // "Enumeration" Optional(9223372036854775807)

          This value is NSNotFound, which is what you’d get when if you called the Objective-C API.  You should be able to write a wrapper that looks for that value and returns nil instead.

          Also, please make sure you file a bug about this, and post the bug number, just for the record.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"