Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ClampedString Property Wrapper
struct ClampedString {
let max: Int
var value: String
init(wrappedValue: String, max: Int) {
value = wrappedValue
self.max = max
var wrappedValue: String {
get { value }
set { value = String(newValue.prefix(max)) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment