Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ClampedString Property Wrapper
@propertyWrapper
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
You can’t perform that action at this time.