Need to have an NSTextField with a text limit of 4 characters maximum and show always in upper case but can\'t figure out a good way of achieving that. I\'ve tried to do it
I needed a Formatter to convert to uppercase for Swift 4. For reference I've included it here:
import Foundation
class UppercaseFormatter : Formatter {
override func string(for obj: Any?) -> String? {
if let stringValue = obj as? String {
return stringValue.uppercased()
}
return nil
}
override func getObjectValue(_ obj: AutoreleasingUnsafeMutablePointer?, for string: String, errorDescription error: AutoreleasingUnsafeMutablePointer?) -> Bool {
obj?.pointee = string as AnyObject
return true
}
}