title: How to use derived attributes in Core Data
body: <p>I'm working with Core Data. I have a field called <code>date</code> that could contain a date or nil.</p>
  
  <p>I want to make a second field called <code>sortDate</code> that will use the date value from the <code>date</code> field if there is one. If the <code>date</code> field is nil, I want to return the current date. I need this to be a core data attribute (not a computed property) because I need to sort fetched records based on this value.</p>
  
  <p>I think the way to do this is with derived attributes but I can't find any information on <strong>how</strong> to use them. I selected the checkbox called "Derived". This shows the "Derivation expression" field, but I have no idea what to enter here. There is no link to documentation on the Xcode UI. </p>
  
  <p>Despite the comment below, I cannot locate any documentation for this feature. I've searched the documentation many times and can't find a single word from Apple about this other than <a href="https://developer.apple.com/videos/play/wwdc2019/230/" rel="noreferrer">this WWDC session</a> where they <em>mention</em> documentation but do not link to it to say how to find it.</p>
  
  <p>I'm not the only one failing to find this: <a href="https://forums.developer.apple.com/thread/120159" rel="noreferrer">Documentation on core data derived attributes</a></p>