Ipados

Parsing Tricky JSON With Codable in Swift

Published on

If you have been writing Swift in the past couple of years, you have probably been using Codable (which is really just the composition of Decodable and Encodable in the same protocol).

If you have been writing iOS apps for longer, you likely know about JSONSerialization as well, which is the backbone of Codable and it allows you to do more manual work when parsing JSON, seemingly giving you more control.

If you know JSONSerialization, you have probably found times in which Codable seemingly doesn’t give you the flexibility you need, and you may have been tempted to drop Codable in favor of JSONSerialization when parsing very specific or even corrupted JSON.


A More Practical Custom Formatter

Published on

I had announced that I wouldn’t be able to write an article this week due to it being Elections Day in my country. that said I just can’t leave you guys without article, so this is a short one.

We will write another NSFormatter subclass. It will allow us to compose E-mails easily. This should also help show that formatters can format string into anything else really.

In short, we will be able to “compose” emails using raw strings, like this:


Silvianna for Anilist

Published on

Silvianna is the best Anilist client for iOS.

Anilist is the popular website for anime and manga fans, where you can keep track of your favorite series, or discover something new to watch or read.

Silvianna comes packed with power features for list management. The app allows you to modify anything about items on your list as long as it is supported by Anilist.

FEATURES:

  • Friendly on the smallest iPhone and the biggest iPad.
  • Keep track of series that are currently airing easily. Series that you haven’t watcheda all the episodes of and are currently airing will have a visible red banner telling you how many episodes behind you are, making it easy to keep track of everything you watch.
  • When you finish watching a series, you will automatically be prompted for the rating. You no longer need to navigate through different screens if you weren’t able to rate something you watched.
  • When rating a series, it will use the rating system currently set in your Anilist account. It doesn’t matter if you are using the standard 10 point system, 10 point decimal system, 5-star system, or even the Emoji system - Silvianna supports all the rating systems provided by Anilist.
  • If your rating system supports Advanced Scoring, Silvianna will grab your parameters and you will be able to also perform advanced scoring according to your custom parameters.
  • You have access to your Anilist profile, so you can access your Manga and Anime lists easily and quickly.
  • Multiwindow support on the iPad.
  • You can search the entire Anilist database for Anime and Manga.

This is just the initial release of Silvianna, and we are excited to make the project grow with your feedback and ideas.


Writing Custom NSFormatters in Swift

Published on

Last year we explored some NSFormatters and how to use them. We also explored some formatters introduced in iOS 13. Finally, a few weeks ago we learned about yet more formatters, and how to better use the ones we already had. In short, we have explored how powerful NSFormatter is. One thing we haven’t done yet though, is to write our own custom NSFormatter subclass.

NSFormatter

NSFormatter is an abstract class. All formatter classes inherit from it. In Swift, everything we need about it is open, so we can create our own NSFormatters with ease.


Benchmarking Your App with MetricKit

Published on

Sometimes we may be interested on how well our app is performing out there in the world. After all, our apps may be running in different environments that are hard to test or that Instruments may not catch.

For this purpose, Apple introduced MetricKit back in WWDC2019. MetricKit allows us to aggregate and analyze this benchmark data on a per-device basis, and not only does it include information on performance and battery usage, but also on exceptions and crash reports.


Formatting Notes and Gotchas

Published on

A year ago, we talked about using NSFormatter for formatting data in a human readable format. WWDC2020 brings some updates and changes to the NSFormatter APIs that we need to be aware of. This article will complement the NSFormatter article from last year with best practices and things to look out for.

Improvements for Combinations of Languages and Regions.

NSFormatter always does its best to format the data according to the user’s language and region where relevant. Apple is improving the combinations for this because it’s highly common for people to set their phones in a language that is not commonly used in a given region. This is pretty exciting for me, because I live in Bolivia where people speak Spanish, but I have used my devices in English for as long as I can remember.


A Short Guide to Localization on Apple Platforms

Published on

Translating our apps in different languages helps us reach wider audiences of different cultures. This reach can increase our app usage considerably and offer more monetization properties.

In this short article we will mention the features Apples gives us to translate our apps to different languages, namely NSLocalizedString and and stringsdict files. You will also understand when you will want to use each, as they have different use cases and an app that takes localization seriously will use both.


WWDC2020: What's new in CryptoKit

Published on

CryptoKit, introduced in WWDC2019, allows us to perform cryptographic operations very easily.

While CryptoKit still doesn’t offer many algorithms and functionality, it’s still growing, and this year CryptoKit and do more.

HKDF

Key derivation functions have been available from day one, but it wasn’t possible to derive keys independently. It was only possible to do so if you were using elliptic curve key agreement protocols.

To do this, there is a new HKDF object with static methods. One such method is deriveKey with multiple overloads:


Logging Messages With the Unified Logging System on Apple Platforms

Published on

Last time we talked about the basics of the Unified Logging System, we set the basic concepts and code we need to write logs, along with the different logging levels, and more.

In this article we will talk about actually logging messages, how the framework is “smart enough” to strip out sensitive user info by default, and how we can control what gets stripped.

Logging Messages

The framework supports interpolated strings right out of the box when you are using the new system in Swift.


Using ASWebAuthenticationSession with SwiftUI

Published on

Working with REST APIs you have no control over can be a little monotonous. This is especially for OAuth 2.0 API that need you to do a little bit of setup, get your API keys with the service provider, and then you need to do the setup on your app’s size: Configure your URL scheme, deal with that URL Scheme, and write code that does something when your app gets called with that URL.