Watchos

Tokenizing Natural Language into Semantic Units in iOS

Published on

Working with Natural Language is possible thanks to machine learning. Starting on iOS 12, Apple has provided many APIs just for this task. In this article we will explore how to use NLTokenizer to separate natural language text into its proper units.

Introduction to Natural Language Tokenizing

If you are not familiar with the inner workings of Natural Language processing, tokenizing simply means that we separate a string and analyze it to find its semantic units. If you are writing a program that processes text, you may be tempted to split the string using a separator. For example, if you wanted to get all the words in a natural sentence string in an array, you would write something like this:


Matching Natural Language Text for Predefined Data Patterns on Apple's Devices

Published on

iOS has a lot of APIs that deal with natural language detection. One such class is NSDataDetector. This class allows you to match different kinds of data in text, including dates, time, links, and more. This class, actually introduced a very long time ago (in the iOS 4.0 days!) makes it very easy to find this kind of data in strings. In this article we will explore how to use this very old class - whose documentation is Objective-C only at this time - in Swift, and how to do common tasks with it.


Recognizing Speech Locally on an iOS Device Using the Speech Framework

Published on

As iOS becomes more advanced, features that we thought belonged to the long future start becoming more common place in today’s software. One such feature is speech recognition, which allows a device to take verbal input from a user, transcribe it into text, and do something with it.

In iOS, we can do this using a framework called Speech, and an object called SFSpeechRecognizer. With this class, you can perform all kinds of speech recognition tasks.


Generating Feedback Haptics with UINotificationFeedbackGenerator

Published on

A few weeks ago, we talked about how we could play custom haptic feedbacks with CHHapticEngine. We saw how powerful and flexible that class is, letting us create different haptics for any context.

Sometimes though, you want to play simpler haptics to let the user know that something has occurred. The CHHapticEngine class can be overkill, and finding the right parameters to have interaction feedback can be very time consuming.

There is a subclass of UIFeedbackGenerator that actually exists since way before we got all the power CHHapticEngine: UINotificationFeedbackGenerator contains pre-made haptics to let users know when an action finished successfully, with an error, or a “warning” in the context of your app.


CryptoKit and the Secure Enclave

Published on

CryptoKit and the Secure Enclave

Apple’s CryptoKit introduced this year is full of amazing features. Not only does it offer very easy to use cryptography, but it also offers an interface to a security feature that Apple introduced less than a decade ago: The Secure Enclave.

The Secure Enclave is a hardware feature for helping the system work with cryptographically secure data. In this article, we will build upon our previous CryptoKit knowledge (see the article linked above), and we will also learn what the Secure Enclave is all about.


Implementing Parametrizable Shortcut Actions for your iOS Apps

Published on

All the way back to 2016, a group of very talented iOS developers released Workflow, a very popular app to let users create actions of different kinds within the system’s constraints. You could create and automate different tasks, such as controlling a server via SSH, downloading all the images from a website, and more… Much, much more.

Apple saw the power of the app and acquired it in March 2017. This was very exciting, but we didn’t hear anything from the app since. Until WWDC 2018. Apple revealed a new app: Shortcuts. This app was built on top of Workflow, and as an Apple app, it allowed it to do many things that Workflow just wasn’t allowed to do, such as toggling system settings, integrating it with other apps (!!), and it was also natively integrated into Siri.


Modern Backgrounds Tasks in iOS 13

Published on

In the article from last week, we explored the basic background execution APIs introduced since iOS 7. We explored how we could request additional time for a task to complete after entering the background, how we could defer downloads with URLSession, and how we could use silent push notifications to trigger background tasks.

The story with background tasks does not end there. iOS 13 introduced more APIs to do better background tasks, and that allow you to do things that weren’t possible before. Apple gave us the new shiny BackgroundTasks framework on WWDC2019. This framework gives developers more flexibility and less constraints to execute code while their apps are in the background. Not only that, but the old Background App Refresh APIs have now been deprecated in favor of a new, modern way to perform them for your app. This changes unifies with the new Background Processing tasks which lets you do more work in the background, while a device is charging, and more.


Formatting Relative Dates With RelativeDateTimeFormatter

Published on

Formatting Relative Dates With RelativeDateTimeFormatter

A few weeks ago we talked about formatting content with NSFormatter, an abstract class from which multiple formatting classes inherit from to allow you to format different kinds of data in a human-readable form. NSFormatter is not only a class you can inherit from yourself, but as iOS evolves, more formatters will be added to its family. This week, we will explore a new member of this family introduced in iOS 13: RelativeDateTimeFormatter.


UserDefaults and Property Wrappers

Published on


**Important Note**

Soon after I published this article, Christian Tietze wrote a fair criticism of this idea here.

Once you understand how property wrappers work, you can use this article to apply it to user defaults. The main idea is that property wrappers allow you to store your values differently and even externally. That said, you may or may not want to implement this in a real app. I recommend you read this article first, and then go back to Christian’s to see more downsides of this idea other than the ones I mentioned below.


Intercepting Network Traffic with mitmproxy

Published on

If you have been programming mobile apps for a while, you must have used a web based API - JSON based or otherwise - and you have had to deal with bugs related to your requests and responses to a web service. You have likely asked yourself why some parsing code is not working as expected, or why a request seems to have an invalid format. Intercepting your own network calls with a proxy can help you find the answer to these questions.