Last active
November 19, 2017 21:39
-
-
Save moshegutman/5e91f6b892f5ac1e4fbedc86c95e58f9 to your computer and use it in GitHub Desktop.
An NSFormatter subclass written in Swift for converting strings to uppercase.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<AnyObject?>?, for string: String, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool { | |
obj?.pointee = string as AnyObject | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment