WIP: Podcast App

As mentioned before, I enjoy podcasts. More often than not, my AirPods will be in my ears and I’ll be listening to ATP, Cortex, or The Adventure Zone. While my current podcast app of choice is wonderful, I wanted to figure out how to make a podcast app myself. Off and on since February I’ve been working on this surprisingly complex little app. The basics of the app are public and available on GitHub, though I forked the repo and continued on privately a few months ago.

Currently, the app has the ability to search the iTunes podcast database, parse through each podcast’s RSS feed, subscribe to a podcast, download, play, and delete episodes, skip silences, and a few other small features. There’s still quite a bit I want to complete, such as side loading files through iCloud, custom animations, and more advanced audio processing. It’s been a fun project.

Overriding Swift String’s Subscript Operator

UPDATE: The extension below always felt a bit dirty. There had to be a reason for the guardians of Swift not to provide simple access to characters via an integer subscript. In doing some research, I have found that I committed a terrible sin:

[As] simple as this code looks, it’s horribly inefficient. Every time s is accessed with an integer, an O(n) function to advance its starting index is run. Running a linear loop inside another linear loop means this for loop is accidentally O(n²) — as the length of the string increases, the time this loop takes increases quadratically.

Please forgive me.


With Swift 4, strings are once again a collection of characters. Maybe it’s my C++ upbringing, but an array of characters just feel right. Unfortunately, referencing a specific character in a Swift string isn’t as easy as using the subscript operator for an array. Instead of passing an integer into square brackets, iterating through the characters of a string requires the use of String.index. Simply writing myString[0] won’t work, we have to write:

let index = self.index(self.startIndex, offsetBy: (0))
mySelf[index]

I never remember this. Again, maybe it’s my C++ traumatized brain, but it just doesn’t sit right. So I made the equivalent of programatic comfort food with this little extension, overriding String’s subscript operator to accept a plain old Int:

extension String {
    subscript(i: Int) -> String {
        get {
            let index = self.index(self.startIndex, offsetBy: (i))
            return String(self[index])
        }
    }
}

And with that, myString[i] works and I don’t have to think too hard next time I reference a character.

Custom Transitions in iOS

The other night I had the opportunity to present on custom animations and transitions at the monthly San Antonio iOS Developer Meetup. I created a Playground that goes over the basics of animation in iOS as well as a prototype for duplicating this fancy transition from the App Store:

In the same repo, there’s also a partially complete project, detailing how to implement your own transition from one view to another. Feel free to play around with the code.