UITextField — Restrict textfield to a certain character (iOS)

// MARK: - UITextFieldDelegatelet allowedCharacters = CharacterSet(charactersIn:”0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz”).invertedfunc textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {let components = string.components(separatedBy: allowedCharacters)
let filtered = components.joined(separator: "")if string == filtered {
return…

--

--

--

iOS Developer, Triple graduated, Passionate, Love workout, blogger

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Tenorshare UltData for iOS 9.4.9.3 Free Download

UITesting iOS

XCTest Methods

Creating a Heart-Shaped Hole in an Icon in SwiftUI

More appealing Slack notifications thanks to Zapier?

Day 80 — Implementing Lives and Respawning

Escaping and Non-escaping Closures

GCD (Grand Central Dispatch) iOS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mr.Javed Multani

Mr.Javed Multani

iOS Developer, Triple graduated, Passionate, Love workout, blogger

More from Medium

What is CollectionView ?

SwiftUI with Coordinator Flow Controllers

Setting up Jazzy for your Swift app project on Apple Silicon (M1)

MVVM-C Xcode Template to reduce development time