Закритий

Write custom NSTextField class to work with Measurement in Swift

Цей проект отримав 5 заявок від талановитих фрілансерів з середньою заявкою у $82 USD.

Отримайте безкоштовно цінові пропозиції на схожі проекти
Роботодавець працює
Бюджет проекту
$10 - $30 USD
Усього заявок
5
Описання проекту

See stackoverflow question here: [url removed, login to view]

Looking for a custom NSTextField class (or NSTextFieldCell class) where I can read and write measurements to where the user can not edit the measurement text.

I want to be able to nicely use a Measurement and MeasurementFormatter for output and input with a NSTextFieldCell.

I am able to display the measurement correctly with...

let areaFormatter = MeasurementFormatter()

[url removed, login to view] = .medium

[url removed, login to view] = .providedUnit

let area = Measurement<UnitArea>( value: [url removed, login to view], unit: .squareInches)

let editInput = NSTextFieldCell

[url removed, login to view] = area

[url removed, login to view] = areaFormatter

This displays something like

[url removed, login to view] in^2

The problem starts when I want to read this back in with

var inputArea = [url removed, login to view] as! Measurement<UnitArea>

I think because the get Object value of the Measurement Formatter is not defined.

open func getObjectValue(_ obj: AutoreleasingUnsafeMutablePointer<AnyObject?>?, for string: String, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool

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

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

var inputArea = [url removed, login to view] as! Measurement<UnitArea>

so this gets displayed

[url removed, login to view] in^2

but only the [url removed, login to view] can be edited.

Хочете заробити?

  • Визначте бюджет та часові рамки
  • Виділіть Вашу пропозицію
  • Отримайте оплату за Вашу роботу

Найняти фрілансерів, які також подавали заявки в цей проект

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online