UIMenu is a new set of APIs that were originally introduced in iOS 13. The API allows us to add menus to different parts of our UIs, including binding actions to key combinations when using your iOS or iPadOS device with a keyboard. Starting on iOS and iPadOS 14 (and ported to macOS Catalyst), this object is more prevalent in the UI thanks to the fact it can be invoqued from different actions.
I hate that my first WWDC article is going to be as lazy as this, but I thought I’d write about it anyway so as to at least give an starting point to devs who will want to try creating their own default web browser or e-mail client on iOS and iPadOS.
Please note the vast majority of my thoughts here are based on a very short response I received on the dev forums. I may be awfully wrong. I am leaving a link to my original question in the dev forums so you can check it out, and reach your own conclusions. The link can be viewed by anyone and it’s not locked behind an Apple Developer membership.
Earlier this week I was scrolling through my Twitter feed as usual and I found this tweet that made me realize I may have been handling errors incorrectly in Swift all my life. This prompted me to research a bit more about error handling in Swift, and it turns out there’s many specialized Error protocols you can conform to, and you should probably be using them over the default Error provided by the language. All these specializations conform to Error themselves. In this article, we will explore a few specializations we can use when dealing with errors in Swift.
June 18, 2020 at 10:24 PM EST: I have made contact with a human at Apple after they reached to me via Resolution Center. We are working on solving the issues, and while I have not been told “yes, your account will not be terminated”, I believe in good faith we will work something out. Yes, the issue was my fault after all, but they are being very understanding and are letting me redeem myself by uploading a new binary. A proper update on this issue will come at a later date.
It is amazing what we can do with smartphones these days. Document scanning and text recognition are nothing new. But being able to have such a functionality in our pockets is pretty neat. These days we can create apps that have such features very quickly thanks to the push Apple has been doing to promote Machine Learning and Artificial Intelligence on their devices.
Starting on iOS 11, we can natively scan documents with a system framework called VisionKit, and we can perform operations on images using a framework called Vision. It wasn’t until iOS 13 that we finally had the ability to recognize text on images ourselves using the Vision framework, without leveraging third party libraries. In this article we will explore how we can use the VisionKit framework to scan documents and the Vision framework to detect text as two separate tasks, so you can see how easy these two tasks are and you can learn to put them together.
If you have been using the keychain on your iOS apps you may want to start using Face ID/Touch ID to let your user access your app and their data. This is a common use case but it’s very easy to do incorrectly.
Apple introduced Touch ID all the way back in 2013, and ever since then, every iOS device has come with some sort of biometric authentication method, be it Touch ID or Face ID. This has allowed developers to implement convenient unlocking into their apps to access sensitive data without having to ask for the passcode. If your app “locks” access in any way your users are probably expecting to “unlock” with their finger or Face ID, so it is your responsibility to implement in a way that is secure and can’t be vulnered.
This article is an entirely rewritten version of an old tutorial I wrote years ago titled “Using the iOS Keychain”. Originally written in Objective-C, the old version has been archived but it is accessible here.
The Keychain is the place where you would store sensitive data. As secure as iOS currently is, the keychain is the right place to store passwords, authentication tokens, and other sensitive data. You should not store this kind of data in UserDefaults, even if iOS has made it harder to access that data for normal users in the latest versions.
A few years ago, Apple introduced the Content Blocking APIs to Safari. Using these APIs, developers are able to write extensions that allow Safari to block content users do not want to see.
Most commonly used for ads, content blockers are not really ad blockers. While they can, and commonly do, block ads, developers can write content blockers for all kind of content, including profanity, or other questionable content.
Content Blocking VS Ad Blocking.
Content Blockers are actually very limited in terms of what they can do. We cannot really achieve the level of functionality especialized extensions such as AdBlock Plus have to offer. Apple’ implementation has two main focuses in mind:
Every iOS developer has written a line of code like this one at least once:
classDollInfoViewController: UIViewController {
vardollModel: Doll?
overridefuncviewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view. }
}
Or in the worst case, you may have seen code like this:
vardollModel: Doll!
Then, when you want to create a view controller of that type you’d do:
// First we need to check if we can actually instantiate the view controller.guardletdollInfoVc = storyboard?.instantiateViewController(withIdentifier: "DollInfo") as? DollInfoViewController else {
fatalError("Unable to load view controller.")
}
// Then we pass in the data we want to work with. dollInfoVc.dollModel = doll
Code like this is very error prone. The worst part is that up untul iOS 13, it was pretty much necessary to pass data around from view controller to view controller. It’s not possible to do this in any different way in different iOS versions.
If you have been programming for a few years, you have undoubtedly come across the term Reflection. This feature allows us to inspect and work with the members of a type.
if this doesn’t make sense, suppose you wanted to check what members a type has. How would you do this? Ideally you’d like to iterate over its members and print them. This is a very basic application of Reflection, but it should let think of other potential uses for it.