Rotate a UIImageView using Gyroscope:
Continue reading “Swift – Rotate image using Gyroscope”Swift – Read automatically pin-code from SMS / OneTimeCode
Very often you should insert a pin-code in a UITextField that some service in order to verify your identity sends you via SMS (generally for a 2FA, two-factor authentication).
Continue reading “Swift – Read automatically pin-code from SMS / OneTimeCode”Connect to Wifi network from code – Swift
With the NetworkExtension framework, you can customize and extend the core networking features of iOS and macOS. Specifically, you can:
- Change the system’s Wi-Fi configuration
- Integrate your app with the hotspot network subsystem (Hotspot Helper)
- Create and manage VPN configurations, using the built-in VPN protocols (Personal VPN) or a custom VPN protocol
- Implement an on-device content filter
- Implement an on-device DNS proxy
The NetworkExtension framework is available in macOS and iOS, but not all features are available on both platforms and some features have specific restrictions (for example, some features only work on supervised iOS devices). The documentation for each feature describes these restrictions.
Swift – Battery level and charger status
Apple offer the batteryState in the UIDevice class:
Swift – UIDevice orientations using iOS12
In iOS12 Apple introduced a new way to check if your device is in “flat” mode, or better is on your desk.
Let’s take a look at the reference:
Continue reading “Swift – UIDevice orientations using iOS12”
Swift – Natural language recognizer
Hi!
with iOS 12, Apple released a new framework for language recognition and other interesting stuff. Is called NLLanguageRecognizer.
Use the Natural Language framework to perform tasks like language and script identification, tokenization, lemmatization, parts-of-speech tagging, and named entity recognition. You can also use this framework with Create ML to train and deploy custom natural language models.
Swift – Access list items from Struct, Class and Enum using Subscript
Classes, structures, and enumerations can define subscripts, which are shortcuts for accessing the member elements of a collection, list, or sequence. You use subscripts to set and retrieve values by index without needing separate methods for setting and retrieval. For example, you access elements in an
Array
instance assomeArray[index]
and elements in aDictionary
instance assomeDictionary[key]
.You can define multiple subscripts for a single type, and the appropriate subscript overload to use is selected based on the type of index value you pass to the subscript. Subscripts are not limited to a single dimension, and you can define subscripts with multiple input parameters to suit your custom type’s needs.
Continue reading “Swift – Access list items from Struct, Class and Enum using Subscript”
Swift – Chaining methods
Very often in Swift, you can see various methods called one each other and linked by a dot “.”.
These methods are called chained methods. Probably using Alamofire you already have seen this behaviour:
Swift | macOS – How to make cool desktop apps using Cocoa
So, what I want to share today is how to make windows with cool UI in a macOS application written in Cocoa/Swift.
This an example of what you see when create a new project from scratch in XCode and run it:
Continue reading “Swift | macOS – How to make cool desktop apps using Cocoa”
Swift – Use generics [T] with closures
Let’s make an example to understand better the scope of this tutorial.
You want to:
- increment all numbers in array by 1
- double all numbers in array
- check if the numbers in array are even or odd
- multiply all numbers in array
- more and more…
How many functions should you create to do this?