Cerrado

Write custom NSTextField class to work with Measurement in Swift

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.

Habilidades: Objective C, Swift

Ver más: custom write, work opencart custom footer, moodle custom write query, wordpress custom write panel, wordpress custom write table, write custom forum software, custom properties macro write, write custom scripts trixbox, excel write custom xml, write custom web server

Información del empleador:
( 131 comentarios ) Bonita Springs, United States

ID de proyecto: #12157646

2 los freelancers están ofertando un promedio de $79 para este trabajo.

xiaomingming

How are you? Thanks for your checking my bid. I am a Mobile & Web developer who have 10 years experience of program develop and 5 + years in mobile. also I have rich develop experience with XCode, Android studio, Más

$133 USD en 1 día
(7 comentarios)
5.5
gamnetmobile

Hi, My name is Gabriel and I'm ready to help you with your project! I'm full stack Xcode/Android Certified developer and software engineering. I'm new on freelancer and full motivated for success here! We dev Más

$150 USD en 1 día
(7 comentarios)
5.2
$80 USD en 1 día
(16 comentarios)
4.4
$25 USD en 1 día
(0 comentarios)
0.0
$23 USD en 6 días
(0 comentarios)
0.0