Swift Substring Slicing

I was toying around with the ‘Natural Language’ Framework for iOS when I got a warning about a deprecated line.


fromString.substring(with: tokenRange)

Code screenshot showing warning

substring(with:) is deprecated: Please use String slicing subscript.

This produced the warning: substring(with:) is deprecated: Please use String slicing subscript.

I looked up the new docs on String slicing and it looked as though I could just put the range in brackets and get what I wanted.


I thought, hey this is easy.


But that produced a hard error: Subscript ‘subscript(_:)’ requires the types ‘String.Index’ and ‘Int’ be equivalent.

I broke out the range into its lower and upper bounds. It gave the same error.


I printed out the type and it showed Subscript. Of course, it was the wrong type. These substring methods are very interesting and are basically just a reference to the original String. There is even a warning on the Apple docs for Substring.

Don’t store substrings longer than you need them to perform a specific operation. A substring holds a reference to the entire storage of the string it comes from, not just to the portion it presents, even when there is no other reference to the original string. Storing substrings may, therefore, prolong the lifetime of string data that is no longer otherwise accessible, which can appear to be memory leakage.

So I actually just needed to cast it into a String from that Substring:


So, for my purposes:

wholePoem.substring(with: tokenRange)
Just needed to be rewritten to this:

Here is a playground showing this.

Data Model Speed Run

This is my first foray into making videos of live-programming. I am learning more and more about OBS and close-captioning every day so I know that as I continue to develop videos they’ll improve immensely.

This is a speed-run of me creating a Data model for a board that I found to be really interesting. Sadly I do not get together with my gaming group so I’ve not played it yet. I hope this gives a good idea about how to manage data and state for a game.

Check out this game on Board Game Geek: Nidavellir

Gaming for All

I am trying to find the nytimes link for this article. Until I find it. This is the text as transcribed by me. I thought it was great to see accessibility for games covered in the nytimes. Please help me find the digital link!

Gaming For All by Melissa Hart Dec 27, 2020 NYTimes

Flashing lights. Small text. No subtitles. These are a few of the features that can make video games really hard for some kids to play. That’s why the gamer Courtney Craven started Can I Play That?, a website that reviews video games for people with disabilities and teaches developers how to create more accessible Games.

Craven, who is nonbinary and uses they/them pronouns, lost their hearing in both ears several years ago, which made it harder to play video games that relied on sounds as cues. It also made the games less fun to play: “If controls aren’t accessible, if subtitles are poorly done,” Craven says, “disabled kids won’t get to experience any of the benefits.”

                On Can I play That?, video games are reviewed by gamers with disabilities who give scores between 1 and 10, based on how easy and fun the games are to play. Craven started the website two years ago, and there are hundreds of game reviews, including for Fortnite (10/10 for deaf accessibility) and Animal Crossing (6.4/10 for blind and low vision accessibility). Here are several audiences Craven and their team consider when reviewing a game, plus recommendations from the website.

1. Deaf or Hard-of-Hearing

Players with hearing loss need captions at the bottom of the screen in plain black type, so they can read what characters are saying. A good game will have descriptions of every sound, from an enemy rustling in the grass to footsteps racing down an alley. If a game’s dramatic moments – like explosions – are paired with a controller’s vibration, that’s even better. 

Recommended: “Immortals Fenyx Rising” (“Will have Deaf and hard-of-hearing players living their best Greek hero lives.”)

2. Blind or Visually Impaired

Lighting is really important for players who are visually impaired (this means their eyesight can’t be fixed with glasses). The best games let players turn the brightness up fo they can tell different shapes apart; large text and bold outlines around objects can help, too. Blind players need an option to add a screen reader, which lets them follow along in Braille.

Recommended: “Timecrest” (“The most accessible interactive-fiction game to date.”)

3. Motor or Physical Disabilities

Not everyone can grip or easily use a game controller. Players with motor challenges have a hard time using their hands or fingers, so they need games that provide alternate controls like using a mouse or a keyboard. If a player can’t hold down a button to allow a character to run, they should be able to do the same thing by pressing multiple keys instead.

Recommended: “Fall Guys: Ultimate Knockout” (“Unlike traditional battle royal, there are no ridiculous kill ceilings.”)

4. Cognitive Disabilities

Players with cognitive challenges like autism and dyslexia process words and sounds differently. They need games that let them control everything they hear and see onscreen, from music and sound effects to what the characters are saying. Players also need easy-to-read text and the ability to turn off flashing images, which can cause migraines or even seizures.

Recommended: “Moving Out” (“You really can play the game however you need to and not be shamed or penalized.”)