If you've written Swift for even a short time, you've already used Generics —whether you realized it or not. Types like Array , Dictionary , Set , and even Optional are all built using generics. Generics are one of Swift's most powerful language features because they help us write reusable, type-safe, and maintainable code . Let's understand them step by step. Why Do We Need Generics? Imagine writing separate functions for every data type. func printInt(_ value: Int) { ... } func printString(_ value: String) { ... } func printDouble(_ value: Double) { ... } The logic is identical, but we're repeating code simply because the data types are different. One option is to use Any . func printValue(_ value: Any) { print(value) } While this works, it comes with a drawback—you lose compile-time type safety and often need runtime type casting ( as? or as! ). Generics solve this problem by allowing us to write code once and reuse it with different data types without sacr...
Long waiting is over. !! iOS 12 brings Autofill for OTP text field which is close to Android provided a decade back. Previously in iOS we used to toggle between OTP text screen and message inbox. Which was hard to remember and time consuming resulting a bad user experience. Personally, I have been asked from the client/customer couple of times to implement autocompletion for OTP field and took me a lot of time to convey that it is not possible in iOS. Why Autofill was not possible previously? We all know that Apple gives at most care for user privacy. When we see iOS architecture, each individual app is like a separate island. There is no inter-app bridge between apps (exception for Keychain and URLSchemes APIs which gives very limited scope). Thus we cannot read message content from inbox. Where to start Autofilling? First of all, the target SMS need to have the OTP Code with prefix string "Code" or "Passcode"on its message content. Beware of OTP c...