title: Creating a Key Path from a computed var in Swift 4
body: <p>I have a <code>fetchedResultsController</code> where I'd like to add a keypath for <code>Date</code> so I don't have a section for every second of the day. Simple enough, I thought...I'll create an <code>extension</code> for <code>MyEntity</code></p>
  
  <pre><code>extension MyEntity {
  
    var dateForSection: String {
      get {
        let dateFormatter = DateFormatter()
        dateFormatter.dateStyle = .long
        if let time = self.time {
          return dateFormatter.string(from: time)
        }
        return "Unavailable Date"
      }
    }
  }
  </code></pre>
  
  <p>Then, on <code>MyViewController</code> in the <code>fetchedResultsController</code> lazy var declaration, I declare the <code>frc</code> as follows:</p>
  
  <pre><code>let frc = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: managedObjectContext, sectionNameKeyPath: #keyPath(MyEntity.dateForSection), cacheName: nil)
  </code></pre>
  
  <p>I get this compiler error:</p>
  
  <blockquote>
    <p>Argument of '#keyPath' refers to non-'@objc' property 'dateForSection'</p>
  </blockquote>
  
  <p>In Googling the issue saw some Swift bug reports from 2016, but I haven't seen any solutions to this. How would I get around this?</p>
  
  <p><strong>Addendum</strong></p>
  
  <p>I've tried adding <code>@objc</code> in front of the <code>var</code> declaration. I've also tried adding <code>@objc dynamic</code>, closing Xcode, nuking derived data from the command line, rebooting Xcode, rebooting my machine, etc.</p>