Use Measurement for input in NSTextFieldCell
<p>I want to be able to nicely use a Measurement and MeasurementFormatter for output and input with a NSTextFieldCell.</p>

<p>I am able to display the measurement correctly with...</p>

<pre><code>let areaFormatter = MeasurementFormatter()
areaFormatter.unitStyle = .medium 
areaFormatter.unitOptions = .providedUnit

let area = Measurement&lt;UnitArea&gt;( value: 123.43, unit: .squareInches)

let editInput = NSTextFieldCell

editInput.objectValue = area
editInput.formatter = areaFormatter
</code></pre>

<p>This displays something like</p>

<pre><code>123.43 in^2
</code></pre>

<p>The problem starts when I want to read this back in with</p>

<pre><code>var inputArea = editInput.objectValue as! Measurement&lt;UnitArea&gt;
</code></pre>

<p>I think because the get Object value of the Measurement Formatter is not defined.</p>

<pre><code>open func getObjectValue(_ obj: AutoreleasingUnsafeMutablePointer&lt;AnyObject?&gt;?, for string: String, errorDescription error: AutoreleasingUnsafeMutablePointer&lt;NSString?&gt;?) -&gt; Bool
</code></pre>

<p>Is my understanding correct? Are there any examples in Swift where this function has been defined for measurements?</p>

<p>Right now the user can edit the entire string including the text in the units. Is there a good way to block the units in the NSTextFieldCell? I would like the user to be able to edit the number but not the units and then return the measurement with </p>

<pre><code>var inputArea = editInput.objectValue as! Measurement&lt;UnitArea&gt;
</code></pre>

<p>so this gets displayed</p>

<pre><code>123.43 in^2
</code></pre>

<p>but only the 123.43 can be edited.</p>